Move temperature conversions to sensor base class (3/8)#54469
Move temperature conversions to sensor base class (3/8)#54469emontnemery merged 3 commits intohome-assistant:devfrom
Conversation
|
Why not moving some of these towards _attr ? |
|
@dgomes _attr shorthand is supported for the new attributes, but migrating integrations to use _attr should be done with one PR for each integration. |
| @property | ||
| def state(self) -> StateType: | ||
| def native_value(self) -> StateType: | ||
| """Return sensor state.""" |
There was a problem hiding this comment.
Just an example from huawei_lte, this patch will leave lots of native_value methods behind whose docstring talks about returning the state, which feels a bit off. Better would be to have them mention returning the native value instead. And it also feels similarly off to have a return type named StateType for a method named like this.
Not that big of a deal, but thought I'd mention it. Docstrings would likely need manual work to fix, and StateType thing probably not worth the churn.
There was a problem hiding this comment.
It's a valid point @scop, we could try to improve most/some docstrings in follow-up PRs depending on how many variations there really are.
Proposed change
Move temperature conversions to sensor base class
SensorEntity(3/8)Temperature conversion will only be done for sensors with device class set to
temperature.Temperature conversion will still be done for other sensor entities during a transition period, which will end with Home Assistant Core 2022.3.0.
Temperature conversion for non sensor entities is unaffected by this PR.
This PR migrates sensors in integrations f-h to be compatible with unit conversion in
SensorEntity.Additional PRs will be opened to migrate sensors from other integrations
Type of change
Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: