Seems we're interested in this bit of the payload:
- Code: Select all
u'sensors': [{u'comp': u'humid', u'value': 53.310001373291016}, {u'comp': u'temp', u'value': 78.0980010986328}, {u'comp': u'voc', u'value': 397.0}, {u'comp': u'dust', u'value': 75.30000305175781}, {u'comp': u'co2', u'value': 661.0}]
This payload component is a list of dictionaries. What I'm understanding you to say is that sometimes the temperature value is the second dictionary in the list and sometimes its in another position. If you ask me, that's bad form on the part of the data service. These data elements *should* always at least be in the same position. Not sure why they would've done it this way.
Finding the temperature value with a Python script or a purpose-built plugin would be extremely straightforward. Unfortunately, the GhostXML plugin is always going to parse the data in the way you see it now and I don't know how we can adequately handle your situation. As you can imagine, trying to code something to handle every possible data construction isn't something that's likely to be possible. Wish I had better news.
But you should be able to locate another custom state called something like
'data_0_sensors_X_comp' which will have the value of 'temp'. This will be your key to know which position the temperature value is located. That said, a custom script may be the easier path for you..