Open jnasholm opened 1 year ago
I have added the "state_class" and "device_class" property to the following file: sensor.zip Copy the "sensors.py" file into the "...HomeAssistant\custom_components\ebus" folder and restart Home Assistant. I have not tested the new properties. Please let me know if the problem is resolved.
Thank you! I will test this and report back.
The new sensor.py
works fine with state_class: measurement
and the recorder stores sensor history values.
One slight modification was needed to avoid state_class
being added to every defined sensor by default. Sensors with non-numeric values, for example data_type: 2
, cause a system log warning and history values are shown as plotted graphs instead of value bars. The modified sensor.py
according to the diff below is currently under further testing.
Looks very promising!
--- sensor.py.1
+++ sensor.py
@@ -48,7 +48,7 @@
vol.Optional(CONF_DATA_TYPE, default=0): cv.positive_int, #0='float value', 1='time-schedule', 2='switch ON/OFF', 3='string', 4='value;status'
vol.Optional(CONF_TIME_TO_LIVE, default=None): vol.Any(None, cv.positive_int), #read request: ebusd returns cached value if age is less 'time to live' in seconds
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
- vol.Optional(CONF_STATE_CLASS, default=SensorStateClass.MEASUREMENT): STATE_CLASSES_SCHEMA
+ vol.Optional(CONF_STATE_CLASS): STATE_CLASSES_SCHEMA
}
]
}
Would it be possible to add "state_class: measurement" for sensors defined in "platform: ebus"?
When I try this to get statistics recorded for plotting the following error is displayed:
Invalid config for [sensor.ebus]: [state_class] is an invalid option for [sensor.ebus]. Check: sensor.ebus->sensors->6->state_class.
The current workaround is to process the ebus sensor data through a template sensor.