netmanchris/pyawair

Fix querying

Opened this issue · 4 comments

These references for the ['sensors'] should be dynamic instead of purely the order (0-6), which might be wrong when sensors are missing for some devices.

pyawair/pyawair/objects.py

Lines 113 to 126 in 85a1bdb

if "temp" in DEVICE_SENSORS[self._type]:
self._data['temp'] = data[-1]['sensors'][0]['value']
if "humid" in DEVICE_SENSORS[self._type]:
self._data['humid'] = data[-1]['sensors'][1]['value']
if "co2" in DEVICE_SENSORS[self._type]:
self._data['co2'] = data[-1]['sensors'][2]['value']
if "voc" in DEVICE_SENSORS[self._type]:
self._data['voc'] = data[-1]['sensors'][3]['value']
if "dust" in DEVICE_SENSORS[self._type]:
self._data['dust'] = data[-1]['sensors'][4]['value']
if "pm25" in DEVICE_SENSORS[self._type]:
self._data['pm25'] = data[-1]['sensors'][5]['value']
if "pm10" in DEVICE_SENSORS[self._type]:
self._data['pm10'] = data[-1]['sensors'][6]['value']

It was based upon the data guide by the way.

@deanlyoung Not to co-opt this issue, but is the link @danielsjf posted above up to date with the new API changes? What's your guidance on moving to the new endpoints? Are we still ok to be using the beta calls for awhile or should we be working on a plan to get to the new endpoints?

C

@netmanchris not 100% sure what you mean by “new endpoints”... are you referring to a previous thread about changing some of them? We steered away from that and reorganized the docs, but not endpoints should have changed, except PUT device settings endpoints.

Speaking of changes, there is one critical one that we’ll need to make, but hopefully shouldn’t be a breaking change if we pull it off right. We won’t be able to support the ?limit=### parameter anymore (timing TBD). Instead, timestamp parameters will still be optional, but if they aren’t supplied, each air data endpoint will default to their max limits, for example raw = 30 (i.e. 5 minutes of 10 second interval data). If passed a limit parameter, the parameter will be ignored and it will just return the data points from the last 5 minutes. Latest will still behave the same.

@danielsjf @deanlyoung Coming back to this. Where are we at with this? Close it? Fix it?