ZEN32 Scene Controller - Z-Wave JS

Tags: #<Tag:0x00007fc41c1d0d70> #<Tag:0x00007fc41c1d0c08>

Just got one of these installed and couldn’t find a blueprint on the exchange. Hopefully this saves someone a little time.

blueprint:
  name: "ZEN32 (Z-Wave JS)"
  description: Create automations for the Zooz ZEN32 switch using the Z-Wave JS integration.
  domain: automation
  input:
    zooz_switch:
      name: Zooz Switch
      description: "List of available Zooz ZEN32 switches."
      selector:
        device:
          integration: zwave_js
          manufacturer: Zooz
          model: ZEN32
    ## Pressed Once
    scene_5:
      name: Scene 5 - Pressed Once
      description: "Action to run when button is pressed once."
      default: []
      selector:
        action: {}
    scene_1:
      name: Scene 1 - Pressed Once
      description: "Action to run when button is pressed once."
      default: []
      selector:
        action: {}
    scene_2:
      name: Scene 2 - Pressed Once
      description: "Action to run when button is pressed once."
      default: []
      selector:
        action: {}
    scene_3:
      name: Scene 3 - Pressed Once
      description: "Action to run when button is pressed once."
      default: []
      selector:
        action: {}
    scene_4:
      name: Scene 4 - Pressed Once
      description: "Action to run when button is pressed once."
      default: []
      selector:
        action: {}
    ## Held
    scene_5h:
      name: Scene 5 - Held
      description: "Action to run when button is held."
      default: []
      selector:
        action: {}
    scene_1h:
      name: Scene 1 - Held
      description: "Action to run when button is held."
      default: []
      selector:
        action: {}
    scene_2h:
      name: Scene 2 - Held
      description: "Action to run when button is held."
      default: []
      selector:
        action: {}
    scene_3h:
      name: Scene 3 - Held
      description: "Action to run when button is held."
      default: []
      selector:
        action: {}
    scene_4h:
      name: Scene 4 - Held
      description: "Action to run when button is held."
      default: []
      selector:
        action: {}
    ## Released
    scene_5r:
      name: Scene 5 - Released
      description: "Action to run when button is released."
      default: []
      selector:
        action: {}
    scene_1r:
      name: Scene 1 - Released
      description: "Action to run when button is released."
      default: []
      selector:
        action: {}
    scene_2r:
      name: Scene 2 - Released
      description: "Action to run when button is released."
      default: []
      selector:
        action: {}
    scene_3r:
      name: Scene 3 - Released
      description: "Action to run when button is released."
      default: []
      selector:
        action: {}
    scene_4r:
      name: Scene 4 - Released
      description: "Action to run when button is released."
      default: []
      selector:
        action: {}
    ## Pressed Twice
    scene_52:
      name: Scene 5 - Pressed 2x
      description: "Action to run when button is pressed twice."
      default: []
      selector:
        action: {}
    scene_12:
      name: Scene 1 - Pressed 2x
      description: "Action to run when button is pressed twice."
      default: []
      selector:
        action: {}
    scene_22:
      name: Scene 2 - Pressed 2x
      description: "Action to run when button is pressed twice."
      default: []
      selector:
        action: {}
    scene_32:
      name: Scene 3 - Pressed 2x
      description: "Action to run when button is pressed twice."
      default: []
      selector:
        action: {}
    scene_42:
      name: Scene 4 - Pressed 2x
      description: "Action to run when button is pressed twice."
      default: []
      selector:
        action: {}
    ## Pressed Thrice
    scene_53:
      name: Scene 5 - Pressed 3x
      description: "Action to run when button is pressed three times."
      default: []
      selector:
        action: {}
    scene_13:
      name: Scene 1 - Pressed 3x
      description: "Action to run when button is pressed three times."
      default: []
      selector:
        action: {}
    scene_23:
      name: Scene 2 - Pressed 3x
      description: "Action to run when button is pressed three times."
      default: []
      selector:
        action: {}
    scene_33:
      name: Scene 3 - Pressed 3x
      description: "Action to run when button is pressed three times."
      default: []
      selector:
        action: {}
    scene_43:
      name: Scene 4 - Pressed 3x
      description: "Action to run when button is pressed three times."
      default: []
      selector:
        action: {}
    ## Pressed Four Times
    scene_54:
      name: Scene 5 - Pressed 4x
      description: "Action to run when button is pressed four times."
      default: []
      selector:
        action: {}
    scene_14:
      name: Scene 1 - Pressed 4x
      description: "Action to run when button is pressed four times."
      default: []
      selector:
        action: {}
    scene_24:
      name: Scene 2 - Pressed 4x
      description: "Action to run when button is pressed four times."
      default: []
      selector:
        action: {}
    scene_34:
      name: Scene 3 - Pressed 4x
      description: "Action to run when button is pressed four times."
      default: []
      selector:
        action: {}
    scene_44:
      name: Scene 4 - Pressed 4x
      description: "Action to run when button is pressed four times."
      default: []
      selector:
        action: {}
    ## Pressed Five Times
    scene_55:
      name: Scene 5 - Pressed 5x
      description: "Action to run when button is pressed five times."
      default: []
      selector:
        action: {}
    scene_15:
      name: Scene 1 - Pressed 5x
      description: "Action to run when button is pressed five times."
      default: []
      selector:
        action: {}
    scene_25:
      name: Scene 2 - Pressed 5x
      description: "Action to run when button is pressed five times."
      default: []
      selector:
        action: {}
    scene_35:
      name: Scene 3 - Pressed 5x
      description: "Action to run when button is pressed five times."
      default: []
      selector:
        action: {}
    scene_45:
      name: Scene 4 - Pressed 5x
      description: "Action to run when button is pressed five times."
      default: []
      selector:
        action: {}
mode: single
max_exceeded: silent
variables:
  device_id: !input "zooz_switch"
trigger:
  - platform: event
    event_type: zwave_js_event
condition: "{{ trigger.event.data.device_id == device_id }}"
action:
  - variables:
      property_key_name: "{{ trigger.event.data.property_key_name }}"
      value: "{{ trigger.event.data.value }}"
  - service: "logbook.log"
    data:
      name: "Property Key Name"
      message: "{{ property_key_name }}"
  - service: "logbook.log"
    data:
      name: "Press Count"
      message: "{{ value }}"
  - service: "logbook.log"
    data:
      name: "Device"
      message: "{{ zwave_device }}"
  - choose:
      ### Scene 1
      - conditions: "{{ property_key_name == '001' and value == 'KeyPressed' }}"
        sequence: !input scene_1
      - conditions: "{{ property_key_name == '001' and value == 'KeyHeldDown' }}"
        sequence: !input scene_1h
      - conditions: "{{ property_key_name == '001' and value == 'KeyReleased' }}"
        sequence: !input scene_1r
      - conditions: "{{ property_key_name == '001' and value == 'KeyPressed2x' }}"
        sequence: !input scene_12
      - conditions: "{{ property_key_name == '001' and value == 'KeyPressed3x' }}"
        sequence: !input scene_13
      - conditions: "{{ property_key_name == '001' and value == 'KeyPressed4x' }}"
        sequence: !input scene_14
      - conditions: "{{ property_key_name == '001' and value == 'KeyPressed5x' }}"
        sequence: !input scene_15
      ### Scene 2
      - conditions: "{{ property_key_name == '002' and value == 'KeyPressed' }}"
        sequence: !input scene_2
      - conditions: "{{ property_key_name == '002' and value == 'KeyHeldDown' }}"
        sequence: !input scene_2h
      - conditions: "{{ property_key_name == '002' and value == 'KeyReleased' }}"
        sequence: !input scene_2r
      - conditions: "{{ property_key_name == '002' and value == 'KeyPressed2x' }}"
        sequence: !input scene_22
      - conditions: "{{ property_key_name == '002' and value == 'KeyPressed3x' }}"
        sequence: !input scene_23
      - conditions: "{{ property_key_name == '002' and value == 'KeyPressed4x' }}"
        sequence: !input scene_24
      - conditions: "{{ property_key_name == '002' and value == 'KeyPressed5x' }}"
        sequence: !input scene_25
      ### Scene 3
      - conditions: "{{ property_key_name == '003' and value == 'KeyPressed' }}"
        sequence: !input scene_3
      - conditions: "{{ property_key_name == '003' and value == 'KeyHeldDown' }}"
        sequence: !input scene_3h
      - conditions: "{{ property_key_name == '003' and value == 'KeyReleased' }}"
        sequence: !input scene_3r
      - conditions: "{{ property_key_name == '003' and value == 'KeyPressed2x' }}"
        sequence: !input scene_32
      - conditions: "{{ property_key_name == '003' and value == 'KeyPressed3x' }}"
        sequence: !input scene_33
      - conditions: "{{ property_key_name == '003' and value == 'KeyPressed4x' }}"
        sequence: !input scene_34
      - conditions: "{{ property_key_name == '003' and value == 'KeyPressed5x' }}"
        sequence: !input scene_35
      ### Scene 4
      - conditions: "{{ property_key_name == '004' and value == 'KeyPressed' }}"
        sequence: !input scene_4
      - conditions: "{{ property_key_name == '004' and value == 'KeyHeldDown' }}"
        sequence: !input scene_4h
      - conditions: "{{ property_key_name == '004' and value == 'KeyReleased' }}"
        sequence: !input scene_4r
      - conditions: "{{ property_key_name == '004' and value == 'KeyPressed2x' }}"
        sequence: !input scene_42
      - conditions: "{{ property_key_name == '004' and value == 'KeyPressed3x' }}"
        sequence: !input scene_43
      - conditions: "{{ property_key_name == '004' and value == 'KeyPressed4x' }}"
        sequence: !input scene_44
      - conditions: "{{ property_key_name == '004' and value == 'KeyPressed5x' }}"
        sequence: !input scene_45
      ### Scene 5
      - conditions: "{{ property_key_name == '005' and value == 'KeyPressed' }}"
        sequence: !input scene_5
      - conditions: "{{ property_key_name == '005' and value == 'KeyHeldDown' }}"
        sequence: !input scene_5h
      - conditions: "{{ property_key_name == '005' and value == 'KeyReleased' }}"
        sequence: !input scene_5r
      - conditions: "{{ property_key_name == '005' and value == 'KeyPressed2x' }}"
        sequence: !input scene_52
      - conditions: "{{ property_key_name == '005' and value == 'KeyPressed3x' }}"
        sequence: !input scene_53
      - conditions: "{{ property_key_name == '005' and value == 'KeyPressed4x' }}"
        sequence: !input scene_54
      - conditions: "{{ property_key_name == '005' and value == 'KeyPressed5x' }}"
        sequence: !input scene_55
2 Likes

I just got one of these set up and this makes using the scene buttons a breeze.

Thanks for putting this one together!

1 Like

Thanks for creating this. I’m trying to use it, but getting the following error in the logs:

Error while executing automation automation.zen32_z_wave_js: UndefinedError: ‘trigger’ is undefined

I see the Z wave events firing if I listen for zwave_js_event, but the actions don’t run, even if I click ‘run actions’ within the automation.

Would love to hear if anyone else has run into this. Thanks!

Sorry you’re having trouble with the blueprint. I’ve seen a similar issue if I create a scene via the UI then later delete it also via the UI. Sometimes, Home Assistant doesn’t actually delete the automation for that scene. It just replaces everything with empty strings. Check automations.yaml for automations using the blueprint zen32_zwave_js and delete any scenes with those empty strings.

Example:

      scene_1:
      - service: ''
        target:
          entity_id: ''

Thanks for the reply. I checked my automations.yaml and there is only 1 automation.

- id: '1617840180502'
  alias: ZEN32 (Z-Wave JS)
  description: ''
  use_blueprint:
    path: fxlt/zen32-scene-controller-z-wave-js.yaml
    input:
      scene_1:
      - service: light.toggle
        target:
          entity_id: light.kitchen_main_lights
      zooz_switch: 7098a49d7a1481a49cff12c2a97c8224

So I’m now getting this error in the log:

“Error while executing automation automation.zen32_z_wave_js: UndefinedError: ‘dict object’ has no attribute ‘event’”

Thanks so much again for your reply

There’s a breaking change with latest update of Z-Wave JS.

As of 2021.4.1, the blueprint needs to be updated.

Replace:

trigger:
  - platform: event
    event_type: zwave_js_event

with:

trigger:
  - platform: event
    event_type: zwave_js_value_notification
1 Like

That’s really odd… I have scene exactly like this and it just works. The only difference I could see (besides the ids) is your zooz_switch lines is at the bottom, while mine is directly under input.

I’ve fixed the breaking change, and improved the logging section:

blueprint:
  name: ZEN32 (Z-Wave JS)
  description: Create automations for the Zooz ZEN32 switch using the Z-Wave JS integration.
  domain: automation
  input:
    zooz_switch:
      name: Zooz Switch
      description: List of available Zooz ZEN32 switches.
      selector:
        device:
          integration: zwave_js
          manufacturer: Zooz
          model: ZEN32
    scene_5:
      name: Scene 5 - Pressed Once
      description: Action to run when button is pressed once.
      default: []
      selector:
        action: {}
    scene_1:
      name: Scene 1 - Pressed Once
      description: Action to run when button is pressed once.
      default: []
      selector:
        action: {}
    scene_2:
      name: Scene 2 - Pressed Once
      description: Action to run when button is pressed once.
      default: []
      selector:
        action: {}
    scene_3:
      name: Scene 3 - Pressed Once
      description: Action to run when button is pressed once.
      default: []
      selector:
        action: {}
    scene_4:
      name: Scene 4 - Pressed Once
      description: Action to run when button is pressed once.
      default: []
      selector:
        action: {}
    scene_5h:
      name: Scene 5 - Held
      description: Action to run when button is held.
      default: []
      selector:
        action: {}
    scene_1h:
      name: Scene 1 - Held
      description: Action to run when button is held.
      default: []
      selector:
        action: {}
    scene_2h:
      name: Scene 2 - Held
      description: Action to run when button is held.
      default: []
      selector:
        action: {}
    scene_3h:
      name: Scene 3 - Held
      description: Action to run when button is held.
      default: []
      selector:
        action: {}
    scene_4h:
      name: Scene 4 - Held
      description: Action to run when button is held.
      default: []
      selector:
        action: {}
    scene_5r:
      name: Scene 5 - Released
      description: Action to run when button is released.
      default: []
      selector:
        action: {}
    scene_1r:
      name: Scene 1 - Released
      description: Action to run when button is released.
      default: []
      selector:
        action: {}
    scene_2r:
      name: Scene 2 - Released
      description: Action to run when button is released.
      default: []
      selector:
        action: {}
    scene_3r:
      name: Scene 3 - Released
      description: Action to run when button is released.
      default: []
      selector:
        action: {}
    scene_4r:
      name: Scene 4 - Released
      description: Action to run when button is released.
      default: []
      selector:
        action: {}
    scene_52:
      name: Scene 5 - Pressed 2x
      description: Action to run when button is pressed twice.
      default: []
      selector:
        action: {}
    scene_12:
      name: Scene 1 - Pressed 2x
      description: Action to run when button is pressed twice.
      default: []
      selector:
        action: {}
    scene_22:
      name: Scene 2 - Pressed 2x
      description: Action to run when button is pressed twice.
      default: []
      selector:
        action: {}
    scene_32:
      name: Scene 3 - Pressed 2x
      description: Action to run when button is pressed twice.
      default: []
      selector:
        action: {}
    scene_42:
      name: Scene 4 - Pressed 2x
      description: Action to run when button is pressed twice.
      default: []
      selector:
        action: {}
    scene_53:
      name: Scene 5 - Pressed 3x
      description: Action to run when button is pressed three times.
      default: []
      selector:
        action: {}
    scene_13:
      name: Scene 1 - Pressed 3x
      description: Action to run when button is pressed three times.
      default: []
      selector:
        action: {}
    scene_23:
      name: Scene 2 - Pressed 3x
      description: Action to run when button is pressed three times.
      default: []
      selector:
        action: {}
    scene_33:
      name: Scene 3 - Pressed 3x
      description: Action to run when button is pressed three times.
      default: []
      selector:
        action: {}
    scene_43:
      name: Scene 4 - Pressed 3x
      description: Action to run when button is pressed three times.
      default: []
      selector:
        action: {}
    scene_54:
      name: Scene 5 - Pressed 4x
      description: Action to run when button is pressed four times.
      default: []
      selector:
        action: {}
    scene_14:
      name: Scene 1 - Pressed 4x
      description: Action to run when button is pressed four times.
      default: []
      selector:
        action: {}
    scene_24:
      name: Scene 2 - Pressed 4x
      description: Action to run when button is pressed four times.
      default: []
      selector:
        action: {}
    scene_34:
      name: Scene 3 - Pressed 4x
      description: Action to run when button is pressed four times.
      default: []
      selector:
        action: {}
    scene_44:
      name: Scene 4 - Pressed 4x
      description: Action to run when button is pressed four times.
      default: []
      selector:
        action: {}
    scene_55:
      name: Scene 5 - Pressed 5x
      description: Action to run when button is pressed five times.
      default: []
      selector:
        action: {}
    scene_15:
      name: Scene 1 - Pressed 5x
      description: Action to run when button is pressed five times.
      default: []
      selector:
        action: {}
    scene_25:
      name: Scene 2 - Pressed 5x
      description: Action to run when button is pressed five times.
      default: []
      selector:
        action: {}
    scene_35:
      name: Scene 3 - Pressed 5x
      description: Action to run when button is pressed five times.
      default: []
      selector:
        action: {}
    scene_45:
      name: Scene 4 - Pressed 5x
      description: Action to run when button is pressed five times.
      default: []
      selector:
        action: {}
  source_url: https://community.home-assistant.io/t/zen32-scene-controller-z-wave-js/292610
mode: single
max_exceeded: silent
variables:
  device_id: !input 'zooz_switch'
trigger:
- platform: event
  event_type: zwave_js_value_notification
condition: '{{ trigger.event.data.device_id == device_id }}'
action:
- variables:
    property_key_name: '{{ trigger.event.data.property_key_name }}'
    label: '{{ trigger.event.data.label }}'
    command_class_name: '{{ trigger.event.data.command_class_name }}'
    value: '{{ trigger.event.data.value }}'
- service: logbook.log
  data:
    name: 'Z-Wave JS'
    message: 'received event: {{ command_class_name }} - {{ value }} - {{ label }}'
- choose:
  - conditions: '{{ property_key_name == ''001'' and value == ''KeyPressed'' }}'
    sequence: !input 'scene_1'
  - conditions: '{{ property_key_name == ''001'' and value == ''KeyHeldDown'' }}'
    sequence: !input 'scene_1h'
  - conditions: '{{ property_key_name == ''001'' and value == ''KeyReleased'' }}'
    sequence: !input 'scene_1r'
  - conditions: '{{ property_key_name == ''001'' and value == ''KeyPressed2x'' }}'
    sequence: !input 'scene_12'
  - conditions: '{{ property_key_name == ''001'' and value == ''KeyPressed3x'' }}'
    sequence: !input 'scene_13'
  - conditions: '{{ property_key_name == ''001'' and value == ''KeyPressed4x'' }}'
    sequence: !input 'scene_14'
  - conditions: '{{ property_key_name == ''001'' and value == ''KeyPressed5x'' }}'
    sequence: !input 'scene_15'
  - conditions: '{{ property_key_name == ''002'' and value == ''KeyPressed'' }}'
    sequence: !input 'scene_2'
  - conditions: '{{ property_key_name == ''002'' and value == ''KeyHeldDown'' }}'
    sequence: !input 'scene_2h'
  - conditions: '{{ property_key_name == ''002'' and value == ''KeyReleased'' }}'
    sequence: !input 'scene_2r'
  - conditions: '{{ property_key_name == ''002'' and value == ''KeyPressed2x'' }}'
    sequence: !input 'scene_22'
  - conditions: '{{ property_key_name == ''002'' and value == ''KeyPressed3x'' }}'
    sequence: !input 'scene_23'
  - conditions: '{{ property_key_name == ''002'' and value == ''KeyPressed4x'' }}'
    sequence: !input 'scene_24'
  - conditions: '{{ property_key_name == ''002'' and value == ''KeyPressed5x'' }}'
    sequence: !input 'scene_25'
  - conditions: '{{ property_key_name == ''003'' and value == ''KeyPressed'' }}'
    sequence: !input 'scene_3'
  - conditions: '{{ property_key_name == ''003'' and value == ''KeyHeldDown'' }}'
    sequence: !input 'scene_3h'
  - conditions: '{{ property_key_name == ''003'' and value == ''KeyReleased'' }}'
    sequence: !input 'scene_3r'
  - conditions: '{{ property_key_name == ''003'' and value == ''KeyPressed2x'' }}'
    sequence: !input 'scene_32'
  - conditions: '{{ property_key_name == ''003'' and value == ''KeyPressed3x'' }}'
    sequence: !input 'scene_33'
  - conditions: '{{ property_key_name == ''003'' and value == ''KeyPressed4x'' }}'
    sequence: !input 'scene_34'
  - conditions: '{{ property_key_name == ''003'' and value == ''KeyPressed5x'' }}'
    sequence: !input 'scene_35'
  - conditions: '{{ property_key_name == ''004'' and value == ''KeyPressed'' }}'
    sequence: !input 'scene_4'
  - conditions: '{{ property_key_name == ''004'' and value == ''KeyHeldDown'' }}'
    sequence: !input 'scene_4h'
  - conditions: '{{ property_key_name == ''004'' and value == ''KeyReleased'' }}'
    sequence: !input 'scene_4r'
  - conditions: '{{ property_key_name == ''004'' and value == ''KeyPressed2x'' }}'
    sequence: !input 'scene_42'
  - conditions: '{{ property_key_name == ''004'' and value == ''KeyPressed3x'' }}'
    sequence: !input 'scene_43'
  - conditions: '{{ property_key_name == ''004'' and value == ''KeyPressed4x'' }}'
    sequence: !input 'scene_44'
  - conditions: '{{ property_key_name == ''004'' and value == ''KeyPressed5x'' }}'
    sequence: !input 'scene_45'
  - conditions: '{{ property_key_name == ''005'' and value == ''KeyPressed'' }}'
    sequence: !input 'scene_5'
  - conditions: '{{ property_key_name == ''005'' and value == ''KeyHeldDown'' }}'
    sequence: !input 'scene_5h'
  - conditions: '{{ property_key_name == ''005'' and value == ''KeyReleased'' }}'
    sequence: !input 'scene_5r'
  - conditions: '{{ property_key_name == ''005'' and value == ''KeyPressed2x'' }}'
    sequence: !input 'scene_52'
  - conditions: '{{ property_key_name == ''005'' and value == ''KeyPressed3x'' }}'
    sequence: !input 'scene_53'
  - conditions: '{{ property_key_name == ''005'' and value == ''KeyPressed4x'' }}'
    sequence: !input 'scene_54'
  - conditions: '{{ property_key_name == ''005'' and value == ''KeyPressed5x'' }}'
    sequence: !input 'scene_55'