fastender
(Fastender)
October 24, 2019, 6:11pm
1
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?
fastender
(Fastender)
October 24, 2019, 6:45pm
3
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.
fastender
(Fastender)
October 24, 2019, 6:53pm
5
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.
fastender
(Fastender)
October 24, 2019, 7:15pm
7
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.
fastender
(Fastender)
October 24, 2019, 7:39pm
8
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.
fastender
(Fastender)
October 24, 2019, 8:04pm
10
Ok, let me check it.
I enter this now, something is wrong
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
fastender
(Fastender)
October 24, 2019, 8:35pm
12
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