Zigbee2MQTT enOcean PTM 215Z (Friends of Hue) switch

3 new versions

  • Advanced with all functions
  • Dimming version, with smooth dimming
  • Simple version for setting scenes etc.

Dimming version

blueprint:
  name: Z2M - EnOcean PTM215Z (Friends of Hue) switch, Dimming, v2
  description: |
    This blueprint is focusing on easy setting scenes and easy dimming of lights

    The button on the left will dim+/dim- on one light (or a Z2M light group) when hold
  domain: automation
  input:
    controller:
      name: (Zigbee2MQTT) Device Name
      description: The name of the device as defined in z2m (e.g. Livingroom lamp). Important, If more lights are to be controlled, make a group in Z2M
      default: ''
    base_topic:
      name: (Zigbee2MQTT) Base mqtt topic
      description: The base topic as configured in z2m. The standard is zigbee2mqtt
      default: zigbee2mqtt
    switch:
      name: HA device name, action entity
      description: The entity from HA
      selector:
        entity:
          integration: mqtt
          domain: sensor
    dim_speed:
      name: Dimming Speed
      description: The speed of the dimming effect. 
      default: 50
      selector:
        number:
          min: 1
          max: 500
          step: 1

    button_1_short_release:
      name: Button 1 short release (upper left)
      description: Action to run, when the button 1 is released after short pres.
      default: []
      selector:
        action: {}
    button_2_short_release:
      name: Button 2 short release (lower left)
      description: Action to run, when the button 2 is released after short press.
      default: []
      selector:
        action: {}

    button_3_short_release:
      name: Button 3 short release (upper right)
      description: Action to run, when the button 3 is released after short press.
      default: []
      selector:
        action: {}
    button_3_long_release:
      name: Button 3 long release (upper right)
      description: Action to run, when the button 3 is released after long press.
      default: []
      selector:
        action: {}

    button_4_short_release:
      name: Button 4 short release (lower right)
      description: Action to run, when the button 4 is released after short press.
      default: []
      selector:
        action: {}
    button_4_long_release:
      name: Button 4 long release (lower right)
      description: Action to run, when the button 4 is released after long press.
      default: []
      selector:
        action: {}

    button_13_short_release:
      name: Button 1 and 3 short release (both upper)
      description: Action to run, when the button 1 and 3 is released after short press.
      default: []
      selector:
        action: {}
    button_13_long_release:
      name: Button 1 and 3 long release (both upper)
      description: Action to run, when the button 1 and 3 is released after long press.
      default: []
      selector:
        action: {}

    button_24_short_release:
      name: Button 2 and 4 short release (both lower)
      description: Action to run, when the button 1 and 3 is released after short press.
      default: []
      selector:
        action: {}
    button_24_long_release:
      name: Button 2 and 4 long release (both lower)
      description: Action to run, when the button 1 and 3 is released after long press.
      default: []
      selector:
        action: {}

mode: restart
max_exceeded: silent

trigger:
  - platform: state
    entity_id: !input 'switch'
    to:
      - release_1
      - release_2
      - release_3
      - release_4
      - release_1_and_3
      - release_2_and_4
      - press_1
      - press_2
      - press_3
      - press_4
      - press_1_and_3
      - press_2_and_4

action:
  - variables:
      base_topic: !input base_topic
      controller: !input controller
      dimspeed_p: !input 'dim_speed'
      keypress: '{{ trigger.to_state.state }}'
      timediff: >-
        {{ (trigger.to_state.last_changed -
        trigger.from_state.last_changed).total_seconds() }}
  - variables:
      dimspeed_n: '{{ dimspeed_p | int * -1 }}'
  - choose:
    - conditions: '{{ keypress == ''press_1'' }}'
      sequence: 
      - delay:
          seconds: 1
      - action: mqtt.publish
        data:
          topic: '{{ base_topic ~ ''/'' ~ controller ~ ''/set''}}'
          payload: "{\"brightness_move_onoff\": {{ dimspeed_p }} }"

    - conditions: '{{ keypress == ''press_2'' }}'
      sequence: 
      - delay:
          seconds: 1
      - action: mqtt.publish
        data:
          topic: '{{ base_topic ~ ''/'' ~ controller ~ ''/set''}}'
          payload: "{\"brightness_move_onoff\": {{ dimspeed_n }} }"


    - conditions: '{{ keypress == ''release_1'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > 1 }}'
          sequence:
            - action: mqtt.publish
              data:
                topic: '{{ base_topic ~ ''/'' ~ controller ~ ''/set''}}'
                payload: "{\"brightness_move\": \"stop\"}"
        default:
        - choose:
          - conditions: '{{ true }}'
            sequence: !input button_1_short_release

    - conditions: '{{ keypress == ''release_2'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > 1  }}'
          sequence:
            - action: mqtt.publish
              data:
                topic: '{{ base_topic ~ ''/'' ~ controller ~ ''/set''}}'
                payload: "{\"brightness_move\": \"stop\"}"
        default:
        - choose:
          - conditions: '{{ true }}'
            sequence: !input button_2_short_release

    - conditions: '{{ keypress == ''release_3'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > 1 }}'
          sequence: !input button_3_long_release
        default:
        - choose:
          - conditions: '{{ true }}'
            sequence: !input button_3_short_release

    - conditions: '{{ keypress == ''release_4'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > 1 }}'
          sequence: !input button_4_long_release
        default:
        - choose:
          - conditions: '{{ true }}'
            sequence: !input button_4_short_release

    - conditions: '{{ keypress == ''release_1_and_3'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > 1 }}'
          sequence: !input button_13_long_release
        default:
        - sequence: !input button_13_short_release

    - conditions: '{{ keypress == ''release_2_and_4'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > 1 }}'
          sequence: !input button_24_long_release
        default:
        - sequence: !input button_24_short_release


Advanced version:

blueprint:
  name: Z2M - EnOcean PTM215Z (Friends of Hue) switch, Advanced, v2
  description: Includes all button functions, Advanced use
  domain: automation
  input:
    switch:
      name: HA device name, action entity
      description: If more switches share same functionality, you can choose 2 or more
      selector:
        entity:
          integration: mqtt
          domain: sensor
          multiple: true  
    hold_delay:
      name: Hold delay
      description: If the button has been held more than the configured Hold delay,
        the corresponding repeat action will be triggered
      default: 1000
      selector:
        number:
          min: 300
          max: 3000
          unit_of_measurement: milliseconds
          step: 100

    button_1_press:
      name: Button 1 Pressed (upper left)
      description: Action to run, when button 1 is pressed.
      default: []
      selector:
        action: {}
    button_1_repeat:
      name: Button 1 Repeted action (upper left)
      description: Action to repeat, when the button 1 is held.
      default: []
      selector:
        action: {}
    button_1_short_release:
      name: Button 1 short released (upper left)
      description: Action to run, when the button 1 is released after short pres.
      default: []
      selector:
        action: {}
    button_1_long_release:
      name: Button 1 long released (upper left)
      description: Action to run, when the button 1 is released after long press.
      default: []
      selector:
        action: {}

    button_2_press:
      name: Button 2 Pressed (lower left)
      description: Action to run, when button 2 is pressed.
      default: []
      selector:
        action: {}
    button_2_repeat:
      name: Button 2 Repeted action (lower left)
      description: Action to repeat, when the button 2 is held.
      default: []
      selector:
        action: {}
    button_2_short_release:
      name: Button 2 short released (lower left)
      description: Action to run, when the button 2 is released after short press.
      default: []
      selector:
        action: {}
    button_2_long_release:
      name: Button 2 long released (lower left)
      description: Action to run, when the button 2 is released after long press.
      default: []
      selector:
        action: {}

    button_3_press:
      name: Button 3 Pressed (upper right)
      description: Action to run, when button 3 is pressed.
      default: []
      selector:
        action: {}
    button_3_repeat:
      name: Button 3 Repeted action (upper right)
      description: Action to repeat, when the button 3 is held.
      default: []
      selector:
        action: {}
    button_3_short_release:
      name: Button 3 short released (upper right)
      description: Action to run, when the button 3 is released after short press.
      default: []
      selector:
        action: {}
    button_3_long_release:
      name: Button 3 long released (upper right)
      description: Action to run, when the button 3 is released after long press.
      default: []
      selector:
        action: {}

    button_4_press:
      name: Button 4 Pressed (lower right)
      description: Action to run, when button 4 is pressed.
      default: []
      selector:
        action: {}
    button_4_repeat:
      name: Button 4 Repeted action (lower right)
      description: Action to repeat, when the button 4 is held.
      default: []
      selector:
        action: {}
    button_4_short_release:
      name: Button 4 short released (lower right)
      description: Action to run, when the button 4 is released after short press.
      default: []
      selector:
        action: {}
    button_4_long_release:
      name: Button 4 long released (lower right)
      description: Action to run, when the button 4 is released after long press.
      default: []
      selector:
        action: {}

    button_13_press:
      name: Button 1+3 Pressed (upper)
      description: Action to run, when upper buttons are pressed.
      default: []
      selector:
        action: {}
    button_13_repeat:
      name: Button 1+3 Repeated action (upper)
      description: Action to repeat, when the upper buttons are held.
      default: []
      selector:
        action: {}
    button_13_short_release:
      name: Button 1+3 are short released (upper)
      description: Action to run, when the upper buttons are released after short press.
      default: []
      selector:
        action: {}
    button_13_long_release:
      name: Button 1+3 long released (upper)
      description: Action to run, when the upper buttons are released after long press.
      default: []
      selector:
        action: {}

    button_24_press:
      name: Button 1+3 Pressed (lower)
      description: Action to run, when lower buttons are pressed.
      default: []
      selector:
        action: {}
    button_24_repeat:
      name: Button 1+3 Repeated action (lower)
      description: Action to repeat, when the lower buttons are held.
      default: []
      selector:
        action: {}
    button_24_short_release:
      name: Button 1+3 are short released (lower)
      description: Action to run, when the lower buttons are released after short press.
      default: []
      selector:
        action: {}
    button_24_long_release:
      name: Button 1+3 long released (lower)
      description: Action to run, when the lower buttons are released after long press.
      default: []
      selector:
        action: {}

mode: restart
max_exceeded: silent

trigger:
  - platform: state
    entity_id: !input 'switch'
    to:
      - release_1
      - release_2
      - release_3
      - release_4
      - release_1_and_3
      - release_2_and_4
      - press_1
      - press_2
      - press_3
      - press_4
      - press_1_and_3
      - press_2_and_4

action:
  - variables:
      keypress: '{{ trigger.to_state.state }}'
      holddelay: !input 'hold_delay'
      timediff: >-
        {{ (trigger.to_state.last_changed -
        trigger.from_state.last_changed).total_seconds() }}

  - choose:
    - conditions: '{{ keypress == ''press_1'' }}'
      sequence: 
      - sequence: !input button_1_press
      - delay:
          milliseconds: !input hold_delay
      - sequence: !input button_1_repeat

    - conditions: '{{ keypress == ''press_2'' }}'
      sequence: 
      - sequence: !input button_2_press
      - delay:
          milliseconds: !input hold_delay
      - sequence: !input button_2_repeat

    - conditions: '{{ keypress == ''press_3'' }}'
      sequence: 
      - sequence: !input button_3_press
      - delay:
          milliseconds: !input hold_delay
      - sequence: !input button_3_repeat

    - conditions: '{{ keypress == ''press_4'' }}'
      sequence: 
      - sequence: !input button_4_press
      - delay:
          milliseconds: !input hold_delay
      - sequence: !input button_4_repeat

    - conditions: '{{ keypress == ''press_1_3'' }}'
      sequence: 
      - sequence: !input button_13_press
      - delay:
          milliseconds: !input hold_delay
      - sequence: !input button_13_repeat

    - conditions: '{{ keypress == ''press_2_4'' }}'
      sequence: 
      - sequence: !input button_24_press
      - delay:
          milliseconds: !input hold_delay
      - sequence: !input button_24_repeat


    - conditions: '{{ keypress == ''release_1'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > (holddelay/1000) }}'
          sequence: !input button_1_long_release
        default:
        - sequence: !input button_1_short_release

    - conditions: '{{ keypress == ''release_2'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > (holddelay/1000) }}'
          sequence: !input button_2_long_release
        default:
        - sequence: !input button_2_short_release

    - conditions: '{{ keypress == ''release_3'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > (holddelay/1000) }}'
          sequence: !input button_3_long_release
        default:
        - sequence: !input button_3_short_release

    - conditions: '{{ keypress == ''release_4'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > (holddelay/1000) }}'
          sequence: !input button_4_long_release
        default:
        - sequence: !input button_4_short_release

    - conditions: '{{ keypress == ''release_1_3'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > (holddelay/1000) }}'
          sequence: !input button_13_long_release
        default:
        - sequence: !input button_13_short_release

    - conditions: '{{ keypress == ''release_2_4'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > (holddelay/1000) }}'
          sequence: !input button_24_long_release
        default:
        - sequence: !input button_24_short_release




Here is the simple version

blueprint:
  name: Z2M - EnOcean PTM215Z (Friends of Hue) switch, Simpel, v2
  description: |
    This blueprint is focusing on easy setting scenes

    Only includes short_release and long_release
  domain: automation
  input:
    switch:
      name: HA device name, action entity
      description: The entity from HA
      selector:
        entity:
          integration: mqtt
          domain: sensor
          multiple: true 
    button_1_short_release:
      name: Button 1 short release (upper left)
      description: Action to run, when the button 1 is released after short pres.
      default: []
      selector:
        action: {}
    button_1_long_release:
      name: Button 1 long release (upper left)
      description: Action to run, when the button 1 is released after long press.
      default: []
      selector:
        action: {}

    button_2_short_release:
      name: Button 2 short release (lower left)
      description: Action to run, when the button 2 is released after short press.
      default: []
      selector:
        action: {}
    button_2_long_release:
      name: Button 2 long release (lower left)
      description: Action to run, when the button 2 is released after long press.
      default: []
      selector:
        action: {}

    button_3_short_release:
      name: Button 3 short release (upper right)
      description: Action to run, when the button 3 is released after short press.
      default: []
      selector:
        action: {}
    button_3_long_release:
      name: Button 3 long release (upper right)
      description: Action to run, when the button 3 is released after long press.
      default: []
      selector:
        action: {}

    button_4_short_release:
      name: Button 4 short release (lower right)
      description: Action to run, when the button 4 is released after short press.
      default: []
      selector:
        action: {}
    button_4_long_release:
      name: Button 4 long release (lower right)
      description: Action to run, when the button 4 is released after long press.
      default: []
      selector:
        action: {}

    button_13_short_release:
      name: Button 1 and 3 short release (both upper)
      description: Action to run, when the button 1 and 3 is released after short press.
      default: []
      selector:
        action: {}
    button_13_long_release:
      name: Button 1 and 3 long release (both upper)
      description: Action to run, when the button 1 and 3 is released after long press.
      default: []
      selector:
        action: {}

    button_24_short_release:
      name: Button 2 and 4 short release (both lower)
      description: Action to run, when the button 1 and 3 is released after short press.
      default: []
      selector:
        action: {}
    button_24_long_release:
      name: Button 2 and 4 long release (both lower)
      description: Action to run, when the button 1 and 3 is released after long press.
      default: []
      selector:
        action: {}

mode: restart
max_exceeded: silent

trigger:
  - platform: state
    entity_id: !input 'switch'
    to:
      - release_1
      - release_2
      - release_3
      - release_4
      - release_1_and_3
      - release_2_and_4
      - press_1
      - press_2
      - press_3
      - press_4
      - press_1_and_3
      - press_2_and_4

action:
  - variables:
      keypress: '{{ trigger.to_state.state }}'
      timediff: >-
        {{ (trigger.to_state.last_changed -
        trigger.from_state.last_changed).total_seconds() }}
  - choose:

    - conditions: '{{ keypress == ''release_1'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > 1 }}'
          sequence: !input button_1_long_release
        default:
        - sequence: !input button_1_short_release

    - conditions: '{{ keypress == ''release_2'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > 1 }}'
          sequence: !input button_2_long_release
        default:
        - sequence: !input button_2_short_release


    - conditions: '{{ keypress == ''release_3'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > 1 }}'
          sequence: !input button_3_long_release
        default:
        - sequence: !input button_3_short_release

    - conditions: '{{ keypress == ''release_4'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > 1 }}'
          sequence: !input button_4_long_release
        default:
        - sequence: !input button_4_short_release

    - conditions: '{{ keypress == ''release_1_and_3'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > 1 }}'
          sequence: !input button_13_long_release
        default:
        - sequence: !input button_13_short_release

    - conditions: '{{ keypress == ''release_2_and_4'' }}'
      sequence:
      - choose:
        - conditions: '{{ timediff > 1 }}'
          sequence: !input button_24_long_release
        default:
        - sequence: !input button_24_short_release


5 Likes

Great work, really appreciate it.

One quick question, could you post a working example?

I cannot get the +/- dimming part to work, only when I release the buttons and press again the dimming action repeats itself.

Remember, the dimming is only build into the version called dimming.

It uses MQTT to do the dimming, hence it might not work on all zigbee bulbs. You can test if your bulbs work with the MQTT dimming, please look in post #76. If you can not get the bulbs dimming manually, then the blueprint will not work. It uses the same MQTT call

Here is my version for our kitchen. My zigbee2mqtt topic is “zigbee2mqtt”, the standard for Z2M. If you have changed this, it needs to be defined.

alias: Køkken Kontakt
description: ""
use_blueprint:
  path: Zigbee2mqtt-Enocean-Dimming-v2.yaml
  input:
    controller: Køkken Light Dimming
    switch: sensor.kokkenkontakt_action
    button_1_short_release:
      - action: scene.turn_on
        metadata: {}
        target:
          entity_id: scene.kokken_high
    button_2_short_release:
      - action: scene.turn_on
        metadata: {}
        target:
          entity_id: scene.kokken_low
    button_3_short_release:
      - action: scene.turn_on
        metadata: {}
        target:
          entity_id: scene.kokken_medium
    button_4_short_release:
      - action: light.turn_off
        metadata: {}
        data: {}
        target:
          area_id: kokken

Thanks for quick reply.

I’m using the version with dimming, and my Z2M topic is right, and the light supports dimming through MQTT.

Everything works if I just want to turn on/off the lights.
It’s just the dimming part I’m missing.

I tried using your Yaml, and changed to my entities, but it gives me an error:

Message malformed: Unable to determine action @ data[‘action’][2][‘choose’][0][‘sequence’][1]

Here is my Yaml:

alias: Bar Switch
description: ""
use_blueprint:
  path: switches/khvej8/Zigbee2mqtt-Enocean-Dimming-v2.yaml
  input:
    controller: bar_foh_switch
    switch: sensor.bar_foh_switch_action
    button_1_short_release:
      - service: scene.turn_on
        metadata: {}
        target:
          entity_id: scene.zdralic_low
    button_3_short_release: 
      - service: scene.turn_on
      metadata: {}
      target:
        entity_id: scene.zdralic_high

The “controller” is the zigbee name of the bulb to be dimmed. It is the name in Z2M interface including spaces, and not the home assistant name of the bulb.

If you would like to control more than one bulb, then create a Z2M group. This is done in the Z2M interface.

I will update the blueprint description, to avoid misunderstandings.

1 Like

Hi there, this blueprint is new to me and i can’t seem to get it to work.
I have set te BP as shown:

the automation yaml is:

Blockquote - id: ‘1730367547227’
alias: Niko switch 1
description: ‘’
use_blueprint:
path: vandalon/z2m EnOcean PTM 215Z (Friends of Hue) switch.yaml
input:
controller: Niko_Switch_1
button_1_pressed:
- action: light.toggle
metadata: {}
data: {}
target:
entity_id:
- light.0x0017880110265491
- light.0x00178801104a7741
base_topic: zigbee2mqtt

switch is in log:
image

but not available in Z2M devices:
image

What could i be doing wrong?