New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically map state class, device class and UoM in ZHA smart energy metering sensor #107685
Dynamically map state class, device class and UoM in ZHA smart energy metering sensor #107685
Conversation
Hey there @dmulcahey, @Adminiuga, @puddly, @TheJulianJES, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
The changed test needs to be reviewed by a code owner. The rest looks good. |
@MartinHjelmare i think your review is stale? Still okey with this change? |
scale=1000, | ||
), | ||
0x0B: SmartEnergyMeteringEntityDescription( | ||
native_unit_of_measurement="unitless", device_class=None, state_class=None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: unitless is not a valid unit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None would be right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but we shouldn't change it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Proposed change
Currently, the status class and the device class are statically assigned for the ZHA sensors 'SmartEnergyMetering' and 'SmartEnergySummation', which leads to inadmissible use, e.g. the device class 'Energy' is assigned for a sensor measuring liters.
This PR creates a additional mapping for state class and device class besides the unit of measurement.
Noticed while doing #107639
In addition, these attributes are set in the
__init__
to prevent them from being looked up again and again.Type of change
Additional information
Checklist
ruff format 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
.To help with the load of incoming pull requests: