Zigbee2MQTT enOcean PTM 215Z (Friends of Hue) switch

Hi Guys,

I’ve created a Zigbee2MQTT blueprint for Friends Of Hue switches based on the enOcean PTM 215Z switches (Like Senic Gira, NIKO, Bush Jeager, EcoDim and others alike) This blueprint is based on the great work of Nick but based on MQTT instead of the legacy sensor created by z2m. Also using mode restart instead of single for easier dimming.
Make sure you enable Elapsed in the z2m advanced settings. This is used to prevent a release after a short press to restart the automation prematurely.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.
Direct link to gist

Below an example on how to use the blueprint in yaml:

alias: Woonkamer SW2
description: ''
use_blueprint:
  path: vandalon/z2m EnOcean PTM 215Z (Friends of Hue) switch.yaml
  input:
    button_1_pressed:
      - service: light.turn_on
        target:
          entity_id: light.woonkamer
        data: {}
      - service: switch.turn_on
        target:
          entity_id: switch.adaptive_lighting_woonkamer
        data: {}
      - service: adaptive_lighting.set_manual_control
        data:
          entity_id: switch.adaptive_lighting_woonkamer
          manual_control: false
    button_2_pressed:
      - service: scene.turn_on
        target:
          entity_id: scene.woonkamer_gedimd
        data:
          transition: 2
    button_3_pressed:
      - service: scene.turn_on
        data:
          transition: 2
        target:
          entity_id: scene.woonkamer_relax
    button_4_pressed:
      - service: scene.turn_on
        target:
          entity_id: scene.woonkamer_tv
        data:
          transition: 2
    button_3_and_4_pressed:
      - service: light.turn_off
        target:
          entity_id:
            - light.eetkamertafel
            - light.boekenkast_plafondlamp
            - light.keuken
        data:
          transition: 2
    button_1_and_2_pressed:
      - service: light.toggle
        target:
          entity_id: light.woonkamer_rechts
        data:
          transition: 1
    button_1_held:
      - repeat:
          count: 25
          sequence:
            - service: light.turn_on
              data:
                brightness_step: 25
              target:
                entity_id: light.woonkamer
            - delay:
                milliseconds: 500
    button_2_held:
      - repeat:
          count: 25
          sequence:
            - service: light.turn_on
              data:
                transition: 1
                brightness_step: -25
              target:
                entity_id: light.woonkamer
            - delay:
                milliseconds: 500
    button_1_and_2_held:
      - scene: scene.gordijnen_open
    button_3_and_4_held:
      - scene: scene.gordijnen_dicht
    controller: Woonkamer SW2

Updated the gist with a couple of bug fixes.

Updated the blueprint. Removed a bug where sometimes a false long press was detected. Also simplified the code.

Could I ask you a different question, related to adding the Niko FOH switch to Z2M? I see you have the options ‘button_1_held’. I’m currently adding mine to Z2M and only see “press_1” and “release_1”. Nothing like held / long press. Do you have any chance why this is?

Kind regards!

Hi Leon,

This is because the switch (via z2m at least) does not send a held button command. Because of that i use a timer that times how long the “press_1” active before receiving the “release_1” that is then considered a “held_1”

Hey @vandalon
ich have bought three “Friends of Hue” (PTM 215Z) but I have some challanges to configurate them.

Light turn on and off works perfekt. But the hold/held don´t work. If I press the Button (1 or 2) for long time the brightnes change once for 10% up or down . But it will not be repeated. I have to push 10 times the button for a long time…

Elapsed is aktivated
I have try to add the mode „resart“ into yaml, becaus I cant take the option into your blueprint. Is that correct?

Where is (my) mistake?
Thanks in advance.

Edith says: Maybe held_1 is not available?

Hi Ferro,

Because the PTM 215Z devices do not support “held” in itself , this is emulated by the blueprint.
The switch only send button press and release. The held is emulated by counting the time when the press command is received without being followed by the release command.

The held commands do not repeat automatically, you will have to do that your self with a loop. See the example in the top post. When creating a loop, the loop will automatically be interrupted when a new commands is received (the release command).

Cheers,
Joris

Okay, I understand.
I don’t like the follow sentence, but: In Hue (app) and iConnectHue (app) with Philips Hue Bridge it works. Therefore I am almost certain, there is somewhere a solution.

What’s are your opinion to the following? If you get the signal “press_1” and you do not get the information “release_1” under certain conditions (like less than 500ms) the operator wants to fade the light. (The light will be dimed). If you get the information “release_1” you stop the dim process.

For switch light on/off: If you get the command “press_1” and the command “release_1” under certain conditions (within 500ms) the lights switch on or off.

Is that an option to simulate the dim?

“Glück auf” (what does it mean),
Christian

I don’t know if the hue bridge emulates the same behavior or if z2m missing the held signal. I’m guessing the FoH switches don’t send repeating signals or even a held signal because of the extra power needed for that. It makes more sense to me that the hue bridge works in the same way as the script above.

If you want dimming to work you can just use my example.

The hold delay is set in the blueprint. (default 500ms).
Meaning that if you hold the button for less then 500ms it’s considered a single press, anything longer is seen as a long press.

button_1_pressed:
      - service: light.turn_on
        target:
          entity_id: light.woonkamer
button_2_pressed:
      - service: scene.turn_off
        target:
          entity_id: light.woonkamer
button_1_held:
      - repeat:
          count: 11 #stop loop after 11 times because 11*24 > 255, 255 beging the max brightness
          sequence:
            - service: light.turn_on
              data:
                transition: 0.6
                brightness_step: 24
              target:
                entity_id: light.woonkamer
            - delay:
                milliseconds: 300 #this delay is just to keep the loop from dimming to fast
    button_2_held:
      - repeat:
          count: 11 #stop loop after 11 times because 11*24 > 255, 255 beging the max brightness and thus 255-(11*24) will always be 0.
          sequence:
            - service: light.turn_on
              data:
                transition: 0.6
                brightness_step: -24
              target:
                entity_id: light.woonkamer
            - delay:
                milliseconds: 300 #this delay is just to keep the loop from dimming to fast

The above is what I use at home for dimming lights.

p.s. I’m not german, I’m Dutch :slight_smile:

I have try, but it do not work :frowning:

alias: TEST kl. Flur Lichtschalter 3
description: ''
use_blueprint:
  path: vandalon/z2m EnOcean PTM 215Z (Friends of Hue) switch.yaml
  input:
    controller: kl. Flur Lichtschalter
    button_1_pressed:
      - type: turn_on
        target:
        entity_id: light.hue_lightstrip_arbeitszimmer
    button_2_pressed:
      - service: light.turn_off
        target:
        entity_id: light.hue_lightstrip_arbeitszimmer
    button_1_held:
      - repeat:
        count: 11 #stop loop after 11 times because 11*24 > 255, 255 beging the max brightness
        sequence:
      - service: light.turn_on
        data:
          transition: 0.6
          brightness_step: 24
        target:
          entity_id: light.hue_lightstrip_arbeitszimmer
      - delay:
          milliseconds: 300 #this delay is just to keep the loop from dimming to fast
    button_2_held:
      - repeat:
        count: 11 #stop loop after 11 times because 11*24 > 255, 255 beging the max brightness and thus 255-(11*24) will always be 0.
        sequence:
      - service: light.turn_on
        data:
          transition: 0.6
          brightness_step: -24
        target:
          entity_id: light.hue_lightstrip_arbeitszimmer
      - delay:
          milliseconds: 300 #this delay is just to keep the loop from dimming to fast

what does the automation debug tool tell you?
Also, did you make sure you have the latest version of the blueprint installed?

Hey, there is no option to debug the autoation.
I create as follow: 2022-08-01-20-55-28.mp4 - Google Drive

But the automation are not been saved, because there is anywhere a mistake into my yaml code.

Please create a new automation from the blueprint , make sure it exists and then apply parts of the example code you need to it