I have a couple of entities which track energy costs (in GBP/kWh) from my gas and electricity smart meters. Currently they only change when my tariff changes, but it’s not impossible I will end up on time-of-use tariffs shortly, leading to them changing multiple times per day.
Currently, these valuese are not held in statistics, because they have a device_class=“monetary” and when I set state_class=“measurement”, HA complains and tells me I can’t do this.
I’d like these values stored in statistics, so need state_class=“measurement” set. How do I do this and keep everything working? Will the Energy dashboard complain if I remove the device_class attribute?
If I uncomment the state_class declaration, I get this error: Entity sensor.smart_meter_electricity_import_unit_rate (<class ‘homeassistant.components.mqtt.sensor.MqttSensor’>) is using state class ‘measurement’ which is impossible considering device class (‘monetary’) it is using; expected None or one of ‘total’; Please update your configuration if your entity is manually configured, otherwise create a bug report at GitHub · Where software is built
Since adding the state_class entry and removing it again (because of the above error), HA is now complaining and raising a repair…
OK - thanks. For the monetary entities (both GBP/kWh for consumption and GBP for daily fixed charge) I’ve removed device_class=monetary and reinstated state_class=measurement and had no errors on restart. So, good news.