New version available at Zooz Z-Wave JS Light Handler v2. The new version is not 100% compatible with this version, which is why I created a new post.
Zooz light switch handler for the Z-Wave JS Integration. Requires scene control to be enabled on the switch. Supports all scene events from the switch, and both old and new scene IDs. If the top button is triggering the actions you have on the bottom button, toggle the Old Firmware switch. Optionally can send refresh commands to node IDs on single press and release events to support associated devices that don’t properly report their status back to the controller (this requires Z-Wave JS to be connected to HA with MQTT in addition to the websocket, and will be updated once Z-Wave JS natively supports refreshing).
blueprint:
name: 'Zooz Light Switch'
description: Trigger actions from button presses
domain: automation
input:
light_switch:
name: Zooz Light Switch
description: The Zooz Light Switch that will trigger the actions
selector:
device:
integration: zwave_js
manufacturer: Zooz
associations:
name: Refresh Associated Nodes
description: Optional comma separated list of nodes id numbers to refresh after switch is pressed. Currently depends on ZwaveJS2MQTT being configured.
default: ""
selector:
text:
refresh_delay:
name: Refresh Delay
description: Number of seconds to wait after switch press to issue refresh
default: 5
selector:
number:
unit_of_measurement: seconds
mode: box
min: 0
max: 60
old_firmware:
name: Old Firmware
description: Enable if the Up and Down actions are reversed
default: false
selector:
boolean:
press_up_1x:
name: 1x Press Up
description: Pick an action for when the light switch UP button is pressed once.
default:
selector:
action:
press_up_2x:
name: 2x Press Up
description: Pick an action for when the light switch UP button is pressed twice.
default:
selector:
action:
press_up_3x:
name: 3x Press Up
description: Pick an action for when the light switch UP button is pressed three times.
default:
selector:
action:
press_up_4x:
name: 4x Press Up
description: Pick an action for when the light switch UP button is pressed four times.
default:
selector:
action:
press_up_5x:
name: 5x Press Up
description: Pick an action for when the light switch UP button is pressed five times.
default:
selector:
action:
up_held:
name: Up Held
description: Pick an action for when the light switch UP button is held.
default:
selector:
action:
up_released:
name: Up Released
description: Pick an action for when the light switch UP button is released.
default:
selector:
action:
press_down_1x:
name: 1x Press Down
description: Pick an action for when the light switch DOWN button is pressed once.
default:
selector:
action:
press_down_2x:
name: 2x Press Down
description: Pick an action for when the light switch DOWN button is pressed twice.
default:
selector:
action:
press_down_3x:
name: 3x Press Down
description: Pick an action for when the light switch DOWN button is pressed three times.
default:
selector:
action:
press_down_4x:
name: 4x Press Down
description: Pick an action for when the light switch DOWN button is pressed four times.
default:
selector:
action:
press_down_5x:
name: 5x Press Down
description: Pick an action for when the light switch DOWN button is pressed five times.
default:
selector:
action:
down_held:
name: Down Held
description: Pick an action for when the light switch DOWN button is held.
default:
selector:
action:
down_released:
name: Down Released
description: Pick an action for when the light switch DOWN button is released.
default:
selector:
action:
mode: parallel
max: 10
trigger:
- platform: event
event_type: zwave_js_event
event_data:
command_class: 91
device_id: !input "light_switch"
action:
- variables:
scene_id: "{{ trigger.event.data.property_key_name }}"
scene_value: "{{ trigger.event.data.value }}"
associations: !input associations
associated_devices: "{{ associations.split(',') }}"
old_firmware: !input old_firmware
up_scene: "{% if old_firmware == true %} 002 {% else %} 001 {% endif %}"
down_scene: "{% if old_firmware == true %} 001 {% else %} 002 {% endif %}"
- choose:
- conditions:
- "{{ scene_id == up_scene }}"
- "{{ scene_value == 'KeyPressed' }}"
sequence: !input press_up_1x
- conditions:
- "{{ scene_id == up_scene }}"
- "{{ scene_value == 'KeyPressed2x' }}"
sequence: !input press_up_2x
- conditions:
- "{{ scene_id == up_scene }}"
- "{{ scene_value == 'KeyPressed3x' }}"
sequence: !input press_up_3x
- conditions:
- "{{ scene_id == up_scene }}"
- "{{ scene_value == 'KeyPressed4x' }}"
sequence: !input press_up_4x
- conditions:
- "{{ scene_id == up_scene }}"
- "{{ scene_value == 'KeyPressed5x' }}"
sequence: !input press_up_5x
- conditions:
- "{{ scene_id == up_scene }}"
- "{{ scene_value == 'KeyHeldDown' }}"
sequence: !input up_held
- conditions:
- "{{ scene_id == up_scene }}"
- "{{ scene_value == 'KeyReleased' }}"
sequence: !input up_released
- conditions:
- "{{ scene_id == down_scene }}"
- "{{ scene_value == 'KeyPressed' }}"
sequence: !input press_down_1x
- conditions:
- "{{ scene_id == down_scene }}"
- "{{ scene_value == 'KeyPressed2x' }}"
sequence: !input press_down_2x
- conditions:
- "{{ scene_id == down_scene }}"
- "{{ scene_value == 'KeyPressed3x' }}"
sequence: !input press_down_3x
- conditions:
- "{{ scene_id == down_scene }}"
- "{{ scene_value == 'KeyPressed4x' }}"
sequence: !input press_down_4x
- conditions:
- "{{ scene_id == down_scene }}"
- "{{ scene_value == 'KeyPressed5x' }}"
sequence: !input press_down_5x
- conditions:
- "{{ scene_id == down_scene }}"
- "{{ scene_value == 'KeyHeldDown' }}"
sequence: !input down_held
- conditions:
- "{{ scene_id == down_scene }}"
- "{{ scene_value == 'KeyReleased' }}"
sequence: !input down_released
- choose:
- conditions:
- "{{ (associations != '') and ((scene_id == up_scene or scene_id == down_scene) and (scene_value == 'KeyPressed' or scene_value == 'KeyReleased'))}}"
sequence:
- repeat:
while:
- condition: template
value_template: '{{ repeat.index <= associated_devices|length() }}'
sequence:
- service: mqtt.publish
data:
topic: zwave/_CLIENTS/ZWAVE_GATEWAY-zwavejs2mqtt/api/pollValue/set
payload_template: >-
{ "args": [ { "nodeId": {{associated_devices[repeat.index - 1]}}, "commandClass": 37, "property": "currentValue" } ]}
- delay:
seconds: !input refresh_delay
- repeat:
while:
- condition: template
value_template: '{{ repeat.index <= associated_devices|length() }}'
sequence:
- service: mqtt.publish
data:
topic: zwave/_CLIENTS/ZWAVE_GATEWAY-zwavejs2mqtt/api/pollValue/set
payload_template: >-
{ "args": [ { "nodeId": {{associated_devices[repeat.index - 1]}}, "commandClass": 38, "property": "currentValue" } ]}