I’m about to give up… I try to set up a script with fields so I can reuse it in different automations.
In my example i try to set a value for a z-wave dimmer (zooz) which is connected through z-wave js ui.
If i set the script up like this–it works (the value 99 turns the switch on––the value 0 turns it off):
alias: test - on dimmer
sequence:
- device_id: 1edf04f10640f11e11f192b7be5d964e
domain: zwave_js
type: set_value
command_class: 38
property: targetValue
value: 99
But if I try to add a field, it just does not work…
alias: test - on / off dimmer
sequence:
- device_id: 1edf04f10640f11e11f192b7be5d964e
domain: zwave_js
type: set_value
command_class: 38
property: targetValue
value: "{{ value }}"
fields:
value:
selector:
number:
min: 0
max: 99
step: 1
name: value
description: 0 = off / 99 = on
required: true
description: ""
What am I missing? Thanks in advance!
freshcoast
(Z-Wave AI Bot)
October 30, 2024, 5:16pm
2
I’m not sure that that device action supports the use of templates. You can confirm if that is true by using the integration action instead:
sequence:
- action: zwave_js.set_value
data:
entity_id:
- light.dining_room
command_class: "38"
property: targetValue
value: "{{ value }}"
I personally would avoid using Device anything in automations/scripts anyways:
Background
When you start writing automations, a device trigger seems the obvious choice. Everybody knows what a device is and it comes at the top of the UI dropdown list.
[image]
It works… but it is certainly not a “great way to start” because it is storing up problems for the future. Far better to use an entity, with state or numeric_state.
Device_id problems
The yaml will be longer and harder to follow, which may make maintenance difficult, especially a few months down the line when y…
Also, why do you need to use the low-level Z-Wave action? HA provides you with a light
entity to interact with, instead of requiring users to use protocol-specific functionality. A brightness of 0 will turn it off. You would only need to use set_value
if the percentage value rounding doesn’t work for you (it scales 1-100% into 1-99 z-wave).
action: light.turn_on
target:
entity_id: light.living_room
data:
brightness_pct: 0