I’m really new to home assistant and I’m trying to use templates to create a counter to display how many lights are currently turned on. Here is what I’ve tried:
platform: template
sensors:
current_lights_on:
friendly_name: Current lights on
unit_of_measurement: 'on'
value_template: >
{% set lights = [ states.light.lamp, states.light.light_strip,
states.light.patio, ] %} {{ lights | selectattr('state','eq','on') | list |
count }}
It keeps returning the error message “Error loading /config/configuration.yaml: mapping values are not allowed here in “/config/configuration.yaml”, line 20, column 10”
Any help would be greatly appreciated. Thankyou so much!
I tried the new format code you sent through and got the following error message: Error loading /config/configuration.yaml: while scanning a simple key in “/config/configuration.yaml”, line 19, column 1 could not find expected ‘:’ in “/config/configuration.yaml”, line 20, column 11