How do I make a power meter from a switch, I know the power consumption of the device, the home assistant probably knows its operating time. How do I make it so that I can add this device to the power panel and display how much it spent in a day? With the help of chatgpt for the third day trying different options nothing works, all that turned out is through configuration.yaml make a switch.
sensor:
- platform: template
sensors:
toilet_warm_floor_heater_power:
friendly_name: "Heater power"
unique_id: id_toilet_warm_floor_heater_power
unit_of_measurement: 'W'
value_template: >
{% if is_state('switch.tepliy_pol_tualet', 'on')%}
{% else%}
0
{% endif %}
Everything related to the integrated object and utility meter is not working properly, and there is no power panel on my device to add. Can someone tell me how to do it right?