Hi.
I’m trying to set up telegram trigger automation and had question.
This is my code:
- alias: tg test
initial_state: 'on'
trigger:
platform: event
event_type: telegram_command
event_data:
command: '/air'
action:
- service: notify.tg_alex
data_template:
message: >
{% if trigger.event.data['args'][0]|float >= 16 and trigger.event.data['args'][0]|float <= 30 %}
Включаю кондиционер.
Температура: {{ trigger.event.data['args'][0] }}°C
Режим: {{ trigger.event.data['args'][1] }}
Интенсивность: {{ trigger.event.data['args'][2] }}
{% elif trigger.event.data['args'][0] == "off" %}
Выключаю кондиционер
{% elif trigger.event.data['args'][0] == "state" and states.climate.air.state != "off" %}
Включен, {{states.climate.air.attributes.temperature}}°C, {{states.climate.air.attributes.fan_mode}}
{% elif trigger.event.data['args'][0] == "state" and states.climate.air.state == "off" %}
Выключен
{% else %}
Пример: /air 20 cool high, /air off, /air state
{% endif %}
“/air args” works as expected
but “/air” return nothing.
How to get “Пример: /air 20 cool high, /air off, /air state” after “/air”?
log
2019-09-27 16:09:50 DEBUG (dispatcher) [homeassistant.core] Bus:Handling <Event telegram_command[L]: user_id=xx, from_first=xx, chat_id=xx, command=/air, args=[]>
2019-09-27 16:09:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event automation_triggered[L]: name=tg test, entity_id=automation.tg_test>
2019-09-27 16:09:50 INFO (MainThread) [homeassistant.components.automation] Executing tg test
2019-09-27 16:09:50 INFO (MainThread) [homeassistant.helpers.script] Script tg test: Running script
2019-09-27 16:09:50 INFO (MainThread) [homeassistant.helpers.script] Script tg test: Executing step call service
2019-09-27 16:09:50 ERROR (MainThread) [homeassistant.helpers.service] Error rendering data template: UndefinedError: list object has no element 0
How can I solve error “no element 0”? I can add new one automation without [args] but I want make only one for each command. Please!