Selecting / Skipping different scenes with the Hue Dimmer Switch

I will use an automation for skipping scenes for the playlists (Relax-Scene or Party-Scene) on my Sonos. When a button is clicked on the hue switch dimmer a new (not all scenes together; only one scene) scene should be selected. I use deconz with the hue switch dimmer, look here: Deconz and remote control with hue dimmer switch

My Problem is how I edit the Template.

- id: '1335944752293'
  alias: 'Select a Playlist'
  initial_state: 'on'
  trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      id: dimmschalter
      event: 2001
  action:
  - service: scene.turn_on
    data_template:
      entity_id: scene.relax
  - service: scene.turn_on
    data_template:
      entity_id: scene.party

What’s wrong with what you have there?

I think I must work with “data_template:”, but I don’t know how.

You don’t have to if that script works, which it sounds like it will based on your use case.

Let me explain it to you. I want use the Hue Dimmer Switch with Deconz. I change now the code to

- id: '1335944752293'
  alias: 'Select a Playlist'
  initial_state: 'on'
  trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      id: dimmschalter
      event: 2001
  action:
  - service: scene.turn_on
    data_template:
      entity_id: scene.relax
  - service: scene.turn_on
    data_template:
      entity_id: scene.party

Scenes are always in state ‘scening’ so you can’t tell what scene is on, but presuming you were correct about the input booleans…

- id: '1335944752293'
  alias: 'Select a Playlist'
  initial_state: 'on'
  trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      id: dimmschalter
      event: 2001
  action:
  - service: homeassistant.turn_on
    data_template:
      entity_id: >
        {% if is_state('input_boolean.party' , 'on' ) %} scene.party
        {% else %} scene.relax {% endif %} 
  - service: homeassistant.toggle
    entity_id:
      - input_boolean.party
      - input_boolean.relax

Although personally I would switch the opposing input_boolean off in the scene.

Let me check it, ok.

When I click the button all the scenes are activated, I will have activated only one scene.

Let me explain again. If I press the button the scene Relax should be activated. If I press the button again, the scene party should be activated.

My Mistake I think its working now… Sorry.

Another question would be if I can add more scenes, e.g. Videogame or Bedgame

Yes, but then a better option would be to use an input_select instead of the booleans and name the entries the same as the scenes, then just bump it to the next entry each time.

Ok, let me check it.

I enter this now, something is wrong :frowning:

input_select:
  playlist:
    name: playlist
    options:
      - relax
      - party
      - videogame
      - bedgame
    initial: relax

and

- id: '1335944752293'
  alias: 'Select a Playlist'
  initial_state: 'on'
  trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      id: dimmschalter
      event: 2001
  action:
  - service: homeassistant.turn_on
    data_template:
      entity_id: >
        {% if is_state('input_select.playlist' , 'party' ) %} scene.party
        {% elif is_state('input_select.playlist', 'relax') %} scene.relax
        {% elif is_state('input_select.playlist', 'videogame') %} scene.videogame
        {% else %} scene.bedgame {% endif %} 
  - service: homeassistant.toggle
    entity_id:
      - input_select.playlist

You can’t toggle an input select, you need the service “input_select.select_next” to change the input select to the next option.
You can see the available services under Developer Tools -> Services

Ok, i rewrite now. Many thanks guys!!!

- id: '1335944752293'
  alias: 'Select a Playlist'
  initial_state: 'on'
  trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      id: dimmschalter
      event: 2001
  action:
  - service: homeassistant.turn_on
    data_template:
      entity_id: >
        {% if is_state("input_select.playlist", "party") %}
          scene.party
        {%-elif is_state("input_select.playlist", "relax") %}
          scene.relax
        {%-elif is_state("input_select.playlist", "videogame") %}
          scene.videogame
        {%-elif is_state("input_select.playlist", "bedgame") %}
          scene.bedgame
        {% else %}
          none
        {% endif %}
  - service: input_select.select_next
    data:
      entity_id: input_select.playlist
- id: '1335944752293'
  alias: 'Select a Playlist'
  initial_state: 'on'
  trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      id: dimmschalter
      event: 2001
  action:
  - service: homeassistant.turn_on
    data_template:
      entity_id: "scene.{{ states('input_select.playlist') }}"
  - service: input_select.select_next
    entity_id: input_select.playlist
2 Likes

Thanks. This helps.