Adds the AirVisual air quality sensor platform#9320
Conversation
| @property | ||
| def pollution_info(self): | ||
| """Define a property to access the pollution information.""" | ||
| return self._pollution_info # pylint: disable=syntax-error |
There was a problem hiding this comment.
at least two spaces before inline comment
MartinHjelmare
left a comment
There was a problem hiding this comment.
In general looks very good I think. Some comments below.
| @@ -0,0 +1,304 @@ | |||
| """Define sensors for AirVisual air quality information.""" | |||
There was a problem hiding this comment.
Look at another sensor platform (eg DHT) for our default way of writing the module docstring. It should contain a link to the docs.
| ATTR_COUNTRY = 'country' | ||
| ATTR_POLLUTANT_SYMBOL = 'pollutant_symbol' | ||
| ATTR_POLLUTANT_UNIT = 'pollutant_unit' | ||
| ATTR_STATE = 'state' |
There was a problem hiding this comment.
I was under the impression that const.py was for generally-useful constants, and that attributes applying to certain platforms only should exist in those platform files. I could see country and state being generally-useful, but what about the two pollutant ones?
There was a problem hiding this comment.
You're correct, you shouldn't add non general constants to const.py. I'm only talking about ATTR_STATE which already exists in const.py.
| @property | ||
| def state(self): | ||
| """Define a property to access the state.""" | ||
| return self._state |
There was a problem hiding this comment.
Consider making all these properties regular instance attributes instead, since you don't seem to need any more logic than returning the attribute.
| if self._data: | ||
| return merge_two_dicts(super().device_state_attributes, { | ||
| ATTR_POLLUTANT_SYMBOL: self._symbol, | ||
| ATTR_POLLUTANT_UNIT: self._unit |
There was a problem hiding this comment.
Don't you want to have a unit of measure for these sensors? Why not overwrite the unit_of_measurement property?
There was a problem hiding this comment.
I see you're working on that now. 😉
There was a problem hiding this comment.
Would love your thoughts here:
- The Air Quality Index doesn't really have a unit; I want to add something so I get a nice graph, but not sure what it would be.
- The Air Quality Level doesn't have a unit, since its values are strings like "Good".
- Same for the Main Pollutant.
There was a problem hiding this comment.
Maybe use 'PSI' as unit for the pollution index?
There was a problem hiding this comment.
PSI isn't quite right, as we're not specifically measuring pressure. Sadly, the EPA specifically states that AQI:
Ranges from 0 to 500 (no units)
Check out my latest push; not sure if you'll approve, but if I return an empty string for that sensor's unit_of_measurement property, I get the bar chart that I want and the unit_of_measurement attribute is the technically correct value: nothing.
There was a problem hiding this comment.
I was referring to pollutant standard index:
https://en.m.wikipedia.org/wiki/Pollutant_Standards_Index
An empty string could be OK, if we make that standard for all unit less measurements that should have a line chart.
* Adds the AirVisual air quality sensor platform * Updated .coveragerc * Removed some un-needed code * Adding strangely-necessary pylint disable * Removing a Python3.5-specific dict combiner method * Restarting stuck coverage test * Added units to AQI sensor (to get nice graph) * Making collaborator-requested changes * Removing unnecessary parameter from data object
Description:
Adds a sensor platform for AirVisual air quality and pollution data.
Related issue (if applicable): N/A
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#3321
Example entry for
configuration.yaml(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests passREQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.If the code does not interact with devices:
- [ ] Local tests withtoxrun successfully. Your PR cannot be merged unless tests pass- [ ] Tests have been added to verify that the new code works.