I have a zigbee power meter which is working perfectly.
My problem is to be able to track energy in the new energy dashboard of HA, my sensor needs to have a measurement class definition, which I can’t set using the new format.
This is my configuration.yaml file:
sensor: !include_dir_merge_list sensors/
And this is the file boiler.yaml inside sensors/ directory:
- platform: template
- sensor:
- name: "Consumption today kW"
unit_of_measurement: "kW" # or W depending on your daily energy sensor
device_class: energy
state_class: measurement
state: >
{% set hrs = [ now().hour + now().minute/60, 0.01]|max %} {# this template only updates every minute so we don't have to worry about seconds, we do have to worry about it being zero though #}
{{ (states('sensor.daily_energy_consumption')|float(0) / hrs )|round(2) }}
availability: "{{ states('sensor.daily_energy_consumption')|is_number and (now().hour + now().minute/60) > 0 }}"
Having this in my config, I receive the following error:
Error loading /config/configuration.yaml: while parsing a block mapping
in "/config/sensors/boiler.yaml", line 23, column 3
expected <block end>, but found '-'
in "/config/sensors/boiler.yaml", line 24, column 3
I want to use the new modern template sensor format but also including a directory with more sensors.
I modified as follows but continue giving the same error:
- platform: template <---------- error here
- sensor:
- name: "Consumption today kW"
unit_of_measurement: "kW" # or W depending on your daily energy sensor
device_class: energy
state_class: measurement
state: >
{% set hrs = [ now().hour + now().minute/60, 0.01]|max %} {# this template only updates every minute so we don't have to worry about seconds, we do have to worry about it being zero though #}
{{ (states('sensor.daily_energy_consumption')|float(0) / hrs )|round(2) }}
availability: "{{ states('sensor.daily_energy_consumption')|is_number and (now().hour + now().minute/60) > 0 }}"
Error loading /config/configuration.yaml: while parsing a block mapping
in "/config/sensors/boiler.yaml", line 23, column 3
expected <block end>, but found '-'
in "/config/sensors/boliler.yaml", line 24, column 3