I’m new with homeassistant (i used jeedom).
I read a lot, but i’m still lost with entities, template, sensor… After reading pages and pages, I still don’t understand the difference between all that kind of things.
Now, I have a mysensors device, whcich give me energy information.
What I want to to is configure the energy dashboard. I need an energy sensor, and can chose it, but it’s not the right Unit. The value must be divided by 1000 to obtain Wh
I have create a sensors.yaml file (which I include in configuration.yaml.)
I put this inside sensors.yaml, but I still can’t use it in energy dashboard :
What am I doing wrong ?
# Example configuration entry
sensor:
platform : template
sensors :
- name : Conso Totale Perso
device_class: energy
state_class: total_increasing
unit_of_measurement: 'Wh'
value_template: "{{states('sensor.energie_active_soutiree')|float / 1000}}"
You were trying to set up a legacy format (old) template sensor. It would still be valid, but modern format is recommended.
Modern format, as per the doc, is under the template: header, not under sensor:. You can put the code directly in configuration.yaml or you can reference another file with:
template: !include templates.yaml
If you do that, your templates.yaml file will start with (for example):
- sensor:
- name: my sensor
You don’t need the template: header because it’s already in the line above.
Because you defined the Template Sensor using what is known as legacy format which doesn’t support the inclusion of the state_class attribute in its configuration.
May I ask why you didn’t choose to configure the Template Sensor using the first format that is described in the documentation? The legacy format you used is buried near the very end of the documentation.