Open envy opened 1 month ago
That sounds like a good idea 👍
For reference, here is the initial implementation discussion about state_class in KNX sensor entities - and why it defaults to None
(the state_class requirements / restrictions have been a bit different back then) https://github.com/home-assistant/core/pull/53996#discussion_r683016047
Removing a state_class would be harder, maybe setting the config option to false could remove it?
setting it explicitly to None
/ null
could be an option too.
If I understand the code correctly, the device_class is actually set in XKNX based on the sensor type/DPT.
Yes, but I'd like to move away from that. I think it would be better to keep HA-specifics in the HA integration and KNX specifics in xknx.
When configuring a sensor, the
state_class
is optional. This can cause issues where the state_class of a sensor is not set even though it should be set.I propose that certain types set certain
state_class
es if the config omits them, similar to how this is done withdevice_class
[1].Examples:
type: temperature
should probably always have astate_class: measurement
. Same forpower
,brightness
,illuminance
,current
, etc...type: active_energy
should probably alway havestate_class: total_increasing
.Overriding the
state_class
would still be possible. Removing astate_class
would be harder, maybe setting the config option tofalse
could remove it?[1] If I understand the code correctly, the
device_class
is actually set in XKNX based on the sensor type/DPT.