Hello, i am new to HomeAssistant, and not a native English speaker, so upfront sorry for the stupid question and the language errors!
I try to create a sensor that shows the total kWh from a day.
in the configuration.yaml file I create a rule “sensor: !include sensors.yaml”
In the same folder is create a file “sensors.yaml”
In the sensors.yaml file I add the following config: ( I got this from the documentation [Template - Home Assistant]
template:
- sensor:
- name: "Totaal kWh vandaag"
unit_of_measurement: "kWh"
state: >
{% set import1 = states('sensor.total_power_import_t1') | float %}
{% set import2 = states('sensor.total_power_import_t2') | float %}
{% set export1 = states('sensor.total_power_export_t1') | float %}
{% set export2 = states('sensor.total_power_export_t2') | float %}
{{ ((import1 + import2) - (export1 + export2))| round(1, default=0) }}
The total_power sensors are created with the utility meters and giving the right data
When I put it in the template (graphical interface) it give me the right number.
When I put it in the config file it give the error: “Invalid config for [sensor]: required key not provided @ data[‘platform’]. Got None.”
I also tried to ad the config direct into the configuration.yaml file → same result.
I am bumping my had to this, can someone put me in the right direction?