#template sensor

1 messages · Page 1 of 1 (latest)

rugged relic
#

Can anyone tell me why the sensor is not added?

#

`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) }}"`
#

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:

nimble pawn
#

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

rugged relic
#

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) }}"`
nimble pawn
#

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

rugged relic
rugged relic
rugged relic
#

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:`
nimble pawn
#

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

rugged relic
#

Now I will deal with the calculation of energy.

rugged relic
#

From all this, I realized that normal energy metering devices are needed, because the home assistant will not provide uninterrupted metering.