I have created a sensor template, that sums total energy from multiple sockets, working with valves and pumps for my house heating. I would like to add it to Energy Dashboard, as devices usage, but I’m not able to select it from the list - all the sockets are there, but not my template sensor. My code, for the sensor looks like that:
However, you have defined this Template Sensor using what is now known as the “legacy” style which doesn’t directly support the state_class option. You will have to add it as a custom attribute in the customize.yaml file and then restart Home Assistant.
Thx a lot!
I was checking the state_class parameter, but configuration check rejected it, and I didnt know about legacy and customize options.
It works now
I have one little problem with this sensor. My WiFi lost connection few times, whit part of the measuring sockets, so the result of state was lower, then before, and in efect i got data jump in statistics. Looks like “total_increasing” in “state_class” dont block this kind of bad measurements. Is there a posibility to add a contition, that if the result i lower then last time, sensor template would keep the old value? (when WiFI gonna come backu, sum gonna be bigger and i can live with that).