Closed alexdelprete closed 2 years ago
Hi. I have the same "Problem". Please add this attributes to a new Version.
And thanks to alexdelprete: With this i have now my Smartmeter in HA Energy :-)
Thx for this great work to zachowj.
Regards Hermann
I discussed about it with @zachowj on discord: he told me he will work on it.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@zachowj Jason, from a quick look at the code, in order to add those two properties, only __init__.py
has to be updated right?
If you can confirm, I can try to submit a PR tomorrow.
They should be added to the sensor class, in sensor.py, as I believe they only apply to sensors.
For another component, I added state_class
like this:
from homeassistant.components.sensor import SensorEntity
class ABBPowerOnePVISunSpecSensor(SensorEntity):
"""Representation of an ABB SunSpec Modbus sensor."""
def __init__(
self, platform_name, hub, device_info, name, key, unit, icon, device_class, state_class
):
"""Initialize the sensor."""
self._platform_name = platform_name
self._hub = hub
self._device_info = device_info
self._name = name
self._key = key
self._unit_of_measurement = unit
self._icon = icon
self._device_class = device_class
self._state_class = state_class
@property
def device_class(self):
"""Return the sensor device_class."""
return self._device_class
@property
def state_class(self):
"""Return the sensor state_class."""
return self._state_class
But the code I see in sensor.py is much different. I guess I'll wait for you to implement it. :)
Currently, how config properties are implemented it's not possible to update them from input into an entity node. Would this be bad for last_reset
? You would have to manually edit the node and deploy for this value to be changed.
Would this be bad for
last_reset
? You would have to manually edit the node and deploy for this value to be changed.
Well, right now that's how I'm making it work: editing the node and adding the state_class as an attribute, then deploy. I expect the only difference to be, if implemented, that we find state_class in the optional Home Assistant Config" section, instead of the Attributes section:
So it wouldn't change anything...if I understood correctly your post.
Thanks for this Jason. Can I test it installing version "main" of the custom component?
Yes, but you'll also need the latest version, v0.40.0, of the HA nodes.
Updated everything. Seems to be working...I'll monitor the sensors...
In the release notes of 1.0.0 I read:
Using attributes for state_class and last_reset on the entity node will no longer show these properties in Home Assistant. There are now config fields for these properties.
But I cant find any new config fields after update from 0.5.4 to 1.0.1.
Where should I move the attribute state_class
to in the following sensor?
But I cant find any new config fields after update from 0.5.4 to 1.0.1. Where should I move the attribute
state_class
to in the following sensor?
Like Jason wrote here: you need to update HA nodes to v0.40.0, from the NR "Manage Palette".
Oh, thanks for the swift answer! Will do.
Hi,
in recent HA releases, in order to support long-term statistics, devs have updated sensors' properties, introducing
last_reset
andstate_class
: https://developers.home-assistant.io/docs/core/entity/sensor/Could you please update the component adding those two properties? They are needed in particular for the new Energy Integration. I use node-red to pull data from my energy meters, as a workaround I added
state_class
as an attribute key, but it would be nice to have it as a default property likedevice_class
in the Home Assistant Config section.Thanks a lot for your work.
Alessandro