>- {%- if is_state('light.all', 'on') -%} There are {%- for state in states.light if state.state == 'on' -%} {% if loop.last %} {{ loop.index }} {% endif %} {%- endfor -%} lights turned on right now. {%- else -%} There are no lights turned on right now. {%- endif -%}