Hi all,
I’m trying to make my first template sensor and I keep getting errors, not sure what my issue is after reading through the template documentation. Trying out the code in the template section of the developer tools it seems to work, but every time I put it in my config file I get an error (error text below the code)
template:
- sensor:
- name: "Minutes until next alarm on Pixel 6"
state: "{{((as_timestamp(states('sensor.pixel_6_next_alarm')) - as_timestamp(now()))/60)|int}}"
- sensor:
- name: "Average upstairs temp"
state: >
{% set bedroom = states('sensor.lumi_lumi_weather_temperature') | float %}
{% set office = states('sensor.office_temperature') | float %}
{{((bedroom + office) / 2) | round(1, default=0) }}
And this is the error that I keep getting from HA:
- Invalid config for [template]: extra keys not allowed @ data[‘state’]. Got “{{((as_timestamp(states(‘sensor.pixel_6_next_alarm’)) - as_timestamp(now()))/60)|int}}” required key not provided @ data[‘sensor’][0][‘state’]. Got None. (See /config/configuration.yaml, line 24).
- Invalid config for [template]: extra keys not allowed @ data[‘state’]. Got “{% set bedroom = states(‘sensor.lumi_lumi_weather_temperature’) | float %} {% set office = states(‘sensor.office_temperature’) | float %}\n{{((bedroom + office) / 2) | round(1, default=0) }}\n” required key not provided @ data[‘sensor’][0][‘state’]. Got None. (See /config/configuration.yaml, line 29).
Any help would be greatly appreciated!!