#template sensor
1 messages · Page 1 of 1 (latest)
`template:
- sensor:
- name: inverter0_ac_output_watthour
state_class: measurement
device_class: energy
friendly_name: inverter0_ac_output_watthour
unit_of_measurement: kWh
value_template: "{{ (states('sensor.inverter0_ac_output_active_power')|float / 3600)|round(2) }}"`
- name: inverter0_ac_output_watthour
In configuration add
homeassistant: packages: !include_dir_named includes/packages
I need to make a sensor with a measurement class, but it not possible with
- platform: template sensors:
Because you are mixing the new and legacy format
friendly_name is not valid anymore (that's name now), value_template should be state
And the state_class of an energy sensor als be total or total_increasing
Yestarday i am try this, but nothing new
`template:
- binary_sensor:
- name: inverter0_ac_output_watthour
state_class: measurement
device_class: energy
unit_of_measurement: kWh
state: "{{ (states('sensor.inverter0_ac_output_active_power')|float / 3600)|round(2) }}"`
- name: inverter0_ac_output_watthour
But, you can't convert power to energy like this
You need to use a Riemann Sum integral
That's available in the GUI under Devices & Services > Helpers
A binary sensor will be on or off and needs a template which returns true or false
Not a numeric value
As I understand it, the new built-in homemassistant function for energy accounting can do this?
I tried to change to a sensor and a binary sensor.
No, you can't
It seems like the yaml itself is connected, because if you make a mistake, it shows it.
in "/config/includes/packages/template.yaml", line 7, column 95
Also in the folder is a file according to the old scheme and it works.
`switch:
- platform: template
switches:
garage_1:`
Compare it to the speed of your car and distance traveled.
As soon as you arrived at the destination the speed will be 0, with the distance traveled will still have increased
Thanks, I changed kWh to kW and the sensor became visible. This only took 2-3 days. 🤣
Now I will deal with the calculation of energy.
From all this, I realized that normal energy metering devices are needed, because the home assistant will not provide uninterrupted metering.