This is why I was asking you about this stuff. I went off your code, and based on your code this should work. So if the sensor itself is only momentary, then you’ll have to approach it slightly differently. However my second example will work every time because the sensor just selects the configuration and the state is provided by you or the trigger.
You’d just have to filter out sensor states that are blank.
automation:
- alias: Double-switch automation
mode: parallel
trigger:
- platform: state
entity_id:
- sensor.living_room_wall_switch_action
condition:
- condition: template
value_template: "{{ trigger.to_state.state not in ['unavailable', 'unknown', ''] }}"
action:
- service: script.my_over_complicated_setup
data:
sensor: "{{ trigger.entity_id }}"
expected: "{{ trigger.to_state.state }}"
script:
my_over_complicated_setup:
mode: parallel
fields:
sensor:
description: sensor being used
example: sensor.living_room_wall_switch_action
expected:
description: expected state
example: left
variables:
config:
sensor.living_room_wall_switch_action:
left_light: light.living_room_tv_light
right_light: light.living_room_table_light
left: scene.living_room_only_tv_light
right: scene.living_room_only_dining_light
both: scene.living_room_only_full_light
no_switches: scene.living_room_no_lights
continue: >
{{ config.get(sensor) is not None }}
target_scene: >
{{ config.get(sensor, {}).get(expected) }}
sequence:
- condition: template
value_template: "{{ continue }}"
- service: scene.turn_on
target:
entity_id: "{{ target_scene }}"
tap_action:
action: call-service
service: script.my_over_complicated_setup
service_data:
sensor: sensor.living_room_wall_switch_action
expected: left