Using a switch to toggle between scenes

I have a physical switch (Operating via Zigbee) and several Philips Hue Lights controlled by Scenes. I would like to use the switch as a toggle to switch between 2 scenes.

The scenes are working fine but I cant see how to get the Automation, when the switch is pressed, to say:

If Light 1 is on
Run Scene 1
else
Run Scene 2

Is there a way to do this?

Thanks

Trigger on the switch, then use a choose action, to determine which scene gets turned on. The condition for the choose action is your light’s state.

Thanks Tom

I thought there must be a way but couldn’t see it

Hello there,
I found a way.

My setting:

  • Two Hue Play lamps
  • 3 scenes (Hal, Magneto and Vapor…)
  • A Bosch switch

I want to switch the scene every time I press the switch. In other words, all scenes one after the other.

The trick is to query the attribute value “rgb_color” and then activate the scene depending on it. I have created three automations for this purpose:

  • If scene Hal is currently set, then activate scene Vapor.
  • If Scene Vapor is set, activate Scene Magneto.
  • If scene Magneto is set, activate scene Hal.

In this way, one automation always reacts to the keystroke and switches on the next scene.

Since I have a different RGB value on lamp 1 for each scene, it was sufficient for me to only take this value into account.

Here is my example of the first automation:

alias: Sitzecke Hal-Vapor aktivieren
description: ""
trigger:
  - platform: device
    device_id: #################################
    domain: bosch_shc
    type: PRESS_SHORT
    subtype: UPPER_BUTTON
condition:
  - condition: and
    conditions:
      - condition: or
        conditions:
          - condition: device
            type: is_on
            device_id: #################################
            entity_id: light.hue_play_1
            domain: light
          - condition: device
            type: is_on
            device_id: #################################
            entity_id: light.hue_play_2
            domain: light
      - condition: state
        entity_id: light.hue_play_1
        attribute: rgb_color
        state: 255, 124, 98
action:
  - service: scene.turn_on
    target:
      entity_id: scene.sitzecke_beleuchtung_vapor_wave
    metadata: {}
mode: single

I found a way to handle it with one automation (instead three):

alias: Sitzecke Szene wechseln
description: ""
trigger:
  - platform: device
    device_id: #################################
    domain: bosch_shc
    type: PRESS_SHORT
    subtype: UPPER_BUTTON
condition: []
action:
  - choose:
      - conditions:
          - condition: template
            value_template: >-
              {{ state_attr('light.hue_play_1', 'rgb_color') == (255, 124, 98)
              }}
        sequence:
          - service: scene.turn_on
            target:
              entity_id: scene.sitzecke_beleuchtung_vapor_wave
            data: {}
      - conditions:
          - condition: template
            value_template: >-
              {{ state_attr('light.hue_play_1', 'rgb_color') == (82, 253, 255)
              }}
        sequence:
          - service: scene.turn_on
            target:
              entity_id: scene.sitzecke_beleuchtung_hal
            data: {}
      - conditions:
          - condition: template
            value_template: >-
              {{ state_attr('light.hue_play_1', 'rgb_color') == (255, 176, 41)
              }}
        sequence:
          - service: scene.turn_on
            target:
              entity_id: scene.sitzecke_beleuchtung_magneto
            data: {}
mode: single
1 Like

Which is exactly what I said to do.

Exactly and thank you very much for that. This answer inspired me.
The last step for me was to find out which scene is active for the lamp based on the RGB values and to switch accordingly.

1 Like