I have a compensation sensor translating voltage to litres for a water tank level sensor. This is working great, but I would like to get long term graphs to display on my dashboards using statistics.
It sounds like it is a feature request to make it work natively, but one of the workarounds mentioned was “The integration isn’t designed to work with it yet. You can add state_class: measurement and a device_class: measurement via customize.yaml to get it to work with statistics.”
I don’t quite understand what that means. I am taking that I need to reference the Compensation sensor I have created in my configuration.yaml in the customize.yaml so that it has the device_class and state_class properties of the original voltage sensor? But I am really not sure how to do that.
Anyone else done this and could point me in the right direction? Thank you in advance!
I am keen to keep both values in Home Assistant. Now that you mention a template sensor, I wonder if that is a simpler better option instead of the customization?
I have been playing with customize.yaml and I sucessfully reloaded HA when I had :
This allowed me to reload successfully and I see what I needed to be referencing from the compensation configuration now. The Compensation area “created” a new sensor, with the name “water_tank_volume”, and that is what I needed to add a device_class and state_class to.
I do not see “sensor.water_tank_volume” as an entity in the statistics graph yet. I am assuming that is because it now needs time to build statistics, since I have just created it?
sensor.house_water_tank_tank_water_level_voltage state is not numerical
So I tried to set the attribute under the compensation sensor setup and I am a bit lost. I tried the source entity as the attribute “house_water_tank_tank_water_level_voltage” but got the same error.
Compensation sensor, with added attribute line. But really confused as to what value need to be on that line.
I am definitely learning more working through this.
I have been into Dev Tools - States and looked at the Compensation sensors in there. All show numeric values. So I am still quite confused as to why I am getting this error.
I have tried to set the attribute, as in my above reply, but every time I do that, it breaks the compensation sensor on my dashboards.
Change your manual customisation to use the correct entity id it will be one of the two ids in that screen shot. I have no idea which one.
homeassistant:
customize:
sensor.house_water_tank_volume: # <- change this it is not the correct entity id
device_class: measurement
state_class: measurement
That got me sorted I believe, it appears under statistics graph, just waiting for the data to populate.
I have two compensation sensors, one converts the voltage from the sensor to litres in the tank the other converts it to a percentage.
My naming for those sensors are terrible, the by product of me learning as I go with the sensors and building it in ESPHome. I haven’t been game enough to change the names to more logical versions as I do not want to break the tank sensor at the moment. I will do it in the future though as it is way too confusing and I am sure it has cost me time here.
Really appreciate your assistance, I have learnt a lot working through this, it all makes a lot more sense now!