Here’s a revised version of the automation. The lights variable is now simply a list instead of dict (thereby avoiding the complication caused by the Automation Editor’s quirk).
alias: dice controls
description: ""
trigger:
- platform: mqtt
topic: zigbee2mqtt/mydice1
condition:
- "{{ action in actions }}"
action:
- choose:
- conditions: "{{ action in ['slide', 'fall'] }}"
sequence:
- service: light.turn_off
target:
entity_id: "{{ light if action == 'slide' else lights }}"
- conditions: "{{ action == 'shake' }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ lights }}"
data:
brightness_pct: 100
default:
- service: light.turn_on
target:
entity_id: "{{ light }}"
data:
brightness_step_pct: "{{ bp.get(action, 50) }}"
variables:
actions:
- slide
- tap
- fall
- shake
- rotate_left
- rotate_right
action: "{{ trigger.payload_json.action }}"
lights:
- light.room0
- light.room1
- light.room2
- light.room3
- light.tradfri_bulb_22
- light.room5
light: "{{ lights[trigger.payload_json.side] | default(lights[0]) }}"
bp:
rotate_left: -10
rotate_right: 25
mode: single
NOTE
If you’re interested, there’s an existing Blueprint for handling all of the cube’s actions: