I am not a YAML developer but I am trying to do a project to set up a dashboard with the Auto Entity card to see lights which are on and off.
To achieve this I set up a label Lights_Group and added it to the light entities.
Then I created a template with the code below but it does not work. I created the code in templates.yaml
I should be able to go to Settings >> Entities and search sensor.lights I should see the custom sensors, but I don’t see anything except Home Assistant Lights.
Also HA will restart, but I get a notification immediately after
• Invalid config for ‘template’ at templates.yaml, line 1: expected a dictionary ‘’, got ‘name:“lights_on_count” unique_id:82cac54b-acf0-427e-8f6c-44bbe105e23a icon:mdi:lightbulb state:> {{states.light| rejectattr('entity_id','in',label_entities('GROUP')) | rejectattr('entity_id','in',label_entities('LED')) | rejectattr('entity_id','in',label_entities('SECURITY')) | selectattr('state','eq','on') | list | count}}’
• Invalid config for ‘template’ at templates.yaml, line 10: expected a dictionary ‘’, got ‘name:“lights_off_count” unique_id:fc35325d-f934-4aa6-8978-9061b64399f1 icon:mdi:lightbulb-off state:> {{states.light| rejectattr('entity_id','in',label_entities('GROUP')) | rejectattr('entity_id','in',label_entities('LED')) | rejectattr('entity_id','in',label_entities('SECURITY')) | selectattr('state','eq','off') | list | count}}’
Can anyone assist me with what may be wrong with the code?
Templates.yaml
- name:“lights_on_count”
unique_id:82cac54b-acf0-427e-8f6c-44bbe105e23a
icon:mdi:lightbulb
state:>
{{states.light| rejectattr(‘entity_id’,‘in’,label_entities(‘GROUP’))
| rejectattr(‘entity_id’,‘in’,label_entities(‘LED’))
| rejectattr(‘entity_id’,‘in’,label_entities(‘SECURITY’))
| selectattr(‘state’,‘eq’,‘on’)
| list | count}} - name:“lights_off_count”
unique_id:fc35325d-f934-4aa6-8978-9061b64399f1
icon:mdi:lightbulb-off
state:>
{{states.light| rejectattr(‘entity_id’,‘in’,label_entities(‘GROUP’))
| rejectattr(‘entity_id’,‘in’,label_entities(‘LED’))
| rejectattr(‘entity_id’,‘in’,label_entities(‘SECURITY’))
| selectattr(‘state’,‘eq’,‘off’)
| list | count}}