You can only have one definition for the template sensors in that file.
- platform: template
sensors:
totaal_aantal_lampen_aan:
friendly_name: 'Totaal Aantal lampen aan'
value_template: "{{ states.light | selectattr( 'state', 'eq', 'on') | list | count }}"
totaal_aantal_lampen_uit:
friendly_name: "Totaal Aantal lampen uit"
value_template: "{{ states.light | selectattr( 'state', 'eq', 'off') | list | count }}"
totaal_aantal_lampen_niet_beschikbaar:
friendly_name: "Totaal Aantal lampen niet beschikbaar"
value_template: "{{ states.light | selectattr( 'state', 'eq', 'unavailable') | list | count }}"
Also make sure your indentation is correct. The “sensors” and the the “friendly_name” of your second sensor and the" value_template" of your third sensor is not correct.
That is not true. You can have as many as you want or need to make the code readable. I usually have one template platform per device, with as many sensors under that as needed. e.g. One template platform for energy sensors, one for my media player sensors, one for my water leak sensors etc…
Check your spacing carefully, it’s all over the place. This is how it should be:
- platform: template
sensors:
totaal_aantal_lampen_aan:
friendly_name: 'Totaal Aantal lampen aan'
value_template: "{{ states.light | selectattr( 'state', 'eq', 'on') | list | count }}"
- platform: template
sensors:
totaal_aantal_lampen_uit:
friendly_name: "Totaal Aantal lampen uit"
value_template: "{{ states.light | selectattr( 'state', 'eq', 'off') | list | count }}"
- platform: template
sensors:
totaal_aantal_lampen_niet_beschikbaar:
friendly_name: "Totaal Aantal lampen niet beschikbaar"
value_template: "{{ states.light | selectattr( 'state', 'eq', 'unavailable') | list | count }}"