Checking what state caused the trigger

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 %}

How about

- 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 is_state('sensor.xiaomi_switch_lobby_click', '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 is_state('sensor.xiaomi_switch_lobby_click', '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 %}

Not work ;(

How about different automations? Also use a seperate template condition.

Different automations its work, but I like the whole algorithm to be worked out in one automation, given the automation is very large and complex.
I figured out the problem, now everything works as it should!

- alias: switch_lobby
  initial_state: true
  trigger:
  - platform: state
    entity_id:  sensor.xiaomi_switch_lobby_click
    to: 'single'
  - platform: state
    entity_id:  sensor.xiaomi_switch_lobby_click
    to: 'double'
  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 %}