I can’t figure out why this automation is not working:
alias: 'Telegram command lights'
initial_state: 'on'
trigger:
- platform: event
event_type: telegram_command
event_data:
command: '/lights'
condition:
- condition: template
value_template: "{{ trigger.event.data.args|length == 0 }}"
action:
- service: telegram_bot.send_message
data_template:
message: >
{% set domain = 'light' %}
{% set entities = states['light'] | selectattr('state', 'eq', 'on') | map(attribute='name') | list | join(', ') %}
The following lights are on: {{ entities }}
It gets triggered, but I actually don’t receive anything. If I try with another operation (e.g. select some specific entity instead) it works just fine.
In the Developer tools section the template works just fine and provides the expected information.
Any ideas?
Thanks!