ReagentX / purple_air_api

Python package to get and transform PurpleAir data
https://pypi.org/project/purpleair/
GNU General Public License v3.0
50 stars 19 forks source link

Parent sensors constructed from Child IDs have incorrect identifiers #89

Closed ReagentX closed 2 years ago

ReagentX commented 2 years ago
>>> cse = Sensor(6643)
Child sensor requested, acquiring parent instead.
>>> cse.identifier
6643

The identifier should be the parent’s ID (6642), because cse is filled with the data from 6642:

https://github.com/ReagentX/purple_air_api/blob/bac87dfc1c0005e37ac60d7f0552f346ee4cddaf/purpleair/sensor.py#L66-L69

However, the library naively assigns the identifier from the Sensor.__init__() construction call, regardless of what data it gets filled with.

https://github.com/ReagentX/purple_air_api/blob/bac87dfc1c0005e37ac60d7f0552f346ee4cddaf/purpleair/sensor.py#L25