Hi all!
I have an Aqara button that has three states - ‘single’, ‘double’ and ‘hold’.
In the normal position, when the button is not pressed, the my object state ‘sensor.xiaomi_switch_lobby_click’ is empty. And only when you press the button, the ‘sensor.xiaomi_switch_lobby_click’ object status appears in the system for a very short time, after which it is empty again.
The button is connected via zigbee CC1352P.
I am writing automation using a template and I want to check in the actions section which state of the ‘sensor.xiaomi_switch_lobby_click’ object caused the trigger to fire.
But for some reason this construction does not work.
Please help and sorry for my english.
- alias: switch_lobby
initial_state: true
trigger:
- platform: state
entity_id: sensor.xiaomi_switch_lobby_click
action:
- service: input_text.set_value
data_template:
entity_id: input_text.lobby_action
value: >
{% if trigger.to_state.state == 'single' and
is_state('switch.sonoff5', 'off') and
is_state('switch.sonoff6', 'off') and
is_state('switch.sonoff7', 'off') and
is_state('switch.sonoff8', 'off') and
is_state('input_boolean.motion_lobby', 'off') %}
Yes
{% elif trigger.to_state.state == 'double' and
is_state('switch.sonoff5', 'off') and
is_state('switch.sonoff6', 'off') and
is_state('switch.sonoff7', 'off') and
is_state('switch.sonoff8', 'off') and
is_state('input_boolean.motion_lobby', 'off') %}
No
{% endif %}