Tuya TS004F: 4 Button Wireless Switch - Controlling two lights, basic dimming - Zigbee2MQTT (2023)

I wanted to use this switch to control two lights, and having some basic dimming functionality (two modes). I was hoping for continuous mode of dimming, but the hold action is so freaking long (like 3 seconds), that it’s unusable. So here is a good-enough-for-me version.

alias: Control of downstair hallway ceiling and stairs bulb with 2 gang switch
description: Control lights with switch actions
trigger:
  - platform: state
    entity_id:
      - sensor.switchtheta_action
    attribute: action
action:
  - variables:
      command: "{{ trigger.to_state.state }}"
      stairsBulb: light.bulbepsilon
      downstairCeiling: light.ceilingdownstairhallway
      transition: 0.5
      defaultBrightness: 100
      dimmedBrightness: 20
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ command == '1_single' }}"
        sequence:
          - service: light.turn_on
            target:
              entity_id: "{{ stairsBulb }}"
            data:
              transition: "{{ transition }}"
              brightness_pct: "{{ defaultBrightness }}"
      - conditions:
          - condition: template
            value_template: "{{ command == '1_double' }}"
        sequence:
          - service: light.turn_on
            data:
              brightness_pct: "{{ defaultBrightness }}"
              transition: "{{ transition }}"
            target:
              entity_id: "{{ stairsBulb }}"
      - conditions:
          - condition: template
            value_template: "{{ command == '3_single' }}"
        sequence:
          - service: light.turn_off
            target:
              entity_id: "{{ stairsBulb }}"
            data:
              transition: "{{ transition }}"
      - conditions:
          - condition: template
            value_template: "{{ command == '3_double' }}"
        sequence:
          - service: light.turn_on
            data:
              brightness_pct: "{{ dimmedBrightness }}"
              transition: "{{ transition }}"
            target:
              entity_id: "{{ stairsBulb }}"
      - conditions:
          - condition: template
            value_template: "{{ command == '2_single' }}"
        sequence:
          - service: light.turn_on
            target:
              entity_id: "{{ downstairCeiling }}"
            data:
              transition: "{{ transition }}"
              brightness_pct: "{{ defaultBrightness }}"
      - conditions:
          - condition: template
            value_template: "{{ command == '2_double' }}"
        sequence:
          - service: light.turn_on
            data:
              brightness_pct: "{{ defaultBrightness }}"
              transition: "{{ transition }}"
            target:
              entity_id: "{{ downstairCeiling }}"
      - conditions:
          - condition: template
            value_template: "{{ command == '4_single' }}"
        sequence:
          - service: light.turn_off
            data:
              transition: "{{ transition }}"
            target:
              entity_id: "{{ downstairCeiling }}"
      - conditions:
          - condition: template
            value_template: "{{ command == '4_double' }}"
        sequence:
          - service: light.turn_on
            data:
              brightness_pct: "{{ dimmedBrightness }}"
              transition: "{{ transition }}"
            target:
              entity_id: "{{ downstairCeiling }}"
mode: single