rbrennecke
(Rolf Brennecke)
January 5, 2022, 4:10pm
1
The folliwing code is starting the script if I push button 1 (property_key: '001'
).
Is it possible to run different scripts if i push button 2 (property_key: '002'
) in the same automation insted of having eight different automations.
alias: SWI - AUT - NAMRON 8 - TEST MULTI
description: Namron switch
trigger:
- platform: event
event_type: zwave_js_value_notification
event_data:
node_id: 30
device_id: 2573389a45104a1eab8a9d3d80869295
property_key: '001'
value: KeyPressed
id: '30'
condition: []
action:
- service: script.test2_45_sec_on
mode: single
tjafbe
(Tjafbe)
January 5, 2022, 4:15pm
2
Yes, using trigger ids and then the choose action. Below is an example code of a 4 button Ikea remote I use to control various things:
trigger:
- device_id: c587c817945bdbb7537be12fb598319f
domain: zha
platform: device
type: remote_button_short_press
subtype: turn_on
id: vol_up
- device_id: c587c817945bdbb7537be12fb598319f
domain: zha
platform: device
type: remote_button_short_press
subtype: turn_off
id: vol_dn
- device_id: c587c817945bdbb7537be12fb598319f
domain: zha
platform: device
type: remote_button_short_press
subtype: left
id: CC
- device_id: c587c817945bdbb7537be12fb598319f
domain: zha
platform: device
type: remote_button_short_press
subtype: right
id: xboxone
- device_id: c587c817945bdbb7537be12fb598319f
domain: zha
platform: device
type: remote_button_long_press
subtype: dim_up
id: play
- device_id: c587c817945bdbb7537be12fb598319f
domain: zha
platform: device
type: remote_button_long_press
subtype: dim_down
id: pause
- device_id: c587c817945bdbb7537be12fb598319f
domain: zha
platform: device
type: remote_button_long_press
subtype: left
id: stubru
- device_id: c587c817945bdbb7537be12fb598319f
domain: zha
platform: device
type: remote_button_long_press
subtype: right
id: spotify
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: spotify
sequence:
- service: script.play_spotify_on_chromecast
- conditions:
- condition: trigger
id: stubru
sequence:
- service: script.stubru
- conditions:
- condition: trigger
id: xboxone
sequence:
- scene: scene.audio_xbox
- scene: scene.tv_input3
- conditions:
- condition: trigger
id: CC
sequence:
- scene: scene.audio_chromecast
- scene: scene.tv_input
- conditions:
- condition: trigger
id: vol_up
sequence:
- scene: scene.vol_2
- conditions:
- condition: trigger
id: vol_dn
sequence:
- scene: scene.vol
- conditions:
- condition: trigger
id: pause
sequence:
- choose:
- conditions:
- condition: device
device_id: e80332406a3d6c6fa527e148fc1f7f93
domain: media_player
entity_id: media_player.chromecast
type: is_playing
sequence:
- service: media_player.media_pause
target:
entity_id: media_player.chromecast
- conditions:
- condition: device
device_id: 1af7dc36ce3e6e47230d29ad3420d165
domain: media_player
entity_id: media_player.xboxone
type: is_playing
sequence:
- service: media_player.media_pause
target:
entity_id: media_player.xboxone
default: []
- conditions:
- condition: trigger
id: play
sequence:
- choose:
- conditions:
- condition: device
device_id: e80332406a3d6c6fa527e148fc1f7f93
domain: media_player
entity_id: media_player.chromecast
type: is_paused
sequence:
- service: media_player.media_play
target:
entity_id: media_player.chromecast
- conditions:
- condition: device
device_id: 1af7dc36ce3e6e47230d29ad3420d165
domain: media_player
entity_id: media_player.xboxone
type: is_paused
sequence:
- service: media_player.media_play_pause
target:
entity_id: media_player.xboxone
default: []
default: []
mode: single
rbrennecke
(Rolf Brennecke)
January 5, 2022, 5:28pm
3
i tried this but get it wrong
alias: SWI - AUT - NAMRON 4 - TEST MULTI
description: Namron bryter
trigger:
- platform: event
event_type: zwave_js_value_notification
event_data:
node_id: 30
device_id: 2573389a45104a1eab8a9d3d80869295
domain: switch
value: KeyPressed
- platform: event
event_type: zwave_js_value_notification
event_data:
node_id: 30
device_id: 2573389a45104a1eab8a9d3d80869295
domain: switch
value: KeyPressed
- platform: event
event_type: zwave_js_value_notification
event_data:
node_id: 30
device_id: 2573389a45104a1eab8a9d3d80869295
domain: switch
value: KeyPressed
- platform: event
event_type: zwave_js_value_notification
event_data:
node_id: 30
device_id: 2573389a45104a1eab8a9d3d80869295
domain: switch
value: KeyPressed
condition: []
action:
- choose:
- conditions:
- condition: trigger
property_key: '001'
sequence:
- service: script.scr_x001
- conditions:
- condition: trigger
property_key: '002'
sequence:
- service: script.scr_x002
- conditions:
- condition: trigger
property_key: '003'
sequence:
- service: script.scr_x003
- conditions:
- condition: trigger
property_key: '004'
sequence:
- service: script.scr_x004
mode: single
woodmj74
(Mike Wood)
January 5, 2022, 6:01pm
4
The answer is in @tjafbe post…make sure each trigger is assigned an ID:
- device_id: c587c817945bdbb7537be12fb598319f
domain: zha
platform: device
type: remote_button_long_press
subtype: right
id: spotify
In this case its spotify
Then in your action choose, each condition references the the ID assigned to the trigger:
action:
- choose:
- conditions:
- condition: trigger
id: spotify
sequence:
- service: script.play_spotify_on_chromecast
The above action will fire now when the trigger associated to ID spotify happens. That should tie everything up for you