Feeling an absolute noob here, but can’t get this to work.
Template sensor works just fine in the template tester (developer tools tab) but only sends out ‘unknown’ when added to coniguration.yaml
Feeling an absolute noob here, but can’t get this to work.
Template sensor works just fine in the template tester (developer tools tab) but only sends out ‘unknown’ when added to coniguration.yaml
There are two ways to define a Template Sensor using YAML:
template:
- sensor:
- name: "Average temperature"
unit_of_measurement: "°C"
state: >
{{ (states('sensor.bedroom1') | float(0) +
states('sensor.bedroom2') | float(0)) / 2 %}
sensor:
- platform: template
sensors:
average_temperature:
friendly_name: "Average temperature"
unit_of_measurement: "°C"
value_template: >
{{ (states('sensor.bedroom1') | float(0) +
states('sensor.bedroom2') | float(0)) / 2 %}
The example you posted is an invalid combination of the two methods. It begins with modern by defining the template
key and then switches to legacy using things like friendly_name
and value_template
and a structure that is only used by legacy format.
Define a Template Sensor using either format but don’t blend the two formats together.
The Template Editor only evaluates templates. It doesn’t validate YAML.