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
9 Likes

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

Hi!
I’m really enjoying the blueprint - thanks!
Are you able to add the possibility to double press the buttons?
Thanks in advance!

Hi, thanks for the blueprint!

Would it theoretically be feasible to include the loops in the blueprint?

I have several of these switches that I want to migrate from Hue to z2m, and editing the automations manually seems a bit cumbersome and error-prone… By just looking at the blueprint it’s not immediately obvious to me how the templating mechanism works… :-/

Stefan

I don’t want to add double click because this would mean that single clicks always have some kind of lag.

1 Like

In this thread you can find an example with loops :slight_smile:

Yes I do understand how to add loops manually. It’s just that I have several switches where I want to control lights in a consistent way (always on/dim/off). Having a “higher level” abstraction for this (probably common) case would be very convenient. For me, it’s kind of moot now because I have copied the loops everywhere manually. From looking at the blueprints, it wasn’t obvious for me how the template mechanism works / if this would be possible at all in a blueprint (opposed to the instances).

I would say that in most situations loops is not the right solution.

The best way to get a smooth dimming is usually to use some kind build in fading, like “Brightness_move” in zigbee2mqtt:
https://www.zigbee2mqtt.io/devices/LED1623G12.html#moving-stepping

or " Dimmer < > and !" in Tasmota:

I am hoping someone can point me in the right direction. I have some PTM 216Z switches which should be similar to the 215Z.

When I press the button, action changes to “press_1” then “” then “release” (note no _1) and then “” again I am getting the feeling that the two stages where the thae action is Blank “” is what is causing my issue?

When I press a button I can see the automation being triggered but all the cases fail for some reason.

If I write a simple automation I can get the light to toggle

alias: New Automation
description: ""
trigger:
  - platform: mqtt
    topic: zigbee2mqtt/Interrupteur -  Bureau Grenier
    payload: press_1
    value_template: "{{ value_json.action }}"
condition: []
action:
  - type: toggle
    device_id: 32127eef940d19603e011d7f2fd1a077
    entity_id: switch.eclairage_petit_escalier_l2
    domain: switch
mode: single

would you have any suggestion on how I could troubleshoot and see why the blueprint is failing on my end?

thanks a lot!