Files
HAOS/Blueprints/PTM_21xZ_ZE.yaml
2026-07-31 17:54:44 +02:00

321 lines
11 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
blueprint:
homeassistant:
min_version: 2024.10.0
name: EnOcean PTM 21xZ/ZE (MQTT trigger)
description: "Controller automation for executing **press/hold/release** actions
triggered by EnOcean PTM 21xZ/ZE switch.\n\n**PTM216Z**\nMake sure to manually
create a separate **Text Helper** and define its entity in the automation. It
is used to store the last controller event to filter and handle `button hold`
actions.\n\n**SETTINGS**\nIn this tab, there is the possibility to change different
parameters.\n - **Base topic**\n - **Hold delay**\n - **PTM216Z - Specific
settings**\n\nℹ️ Version 2025.12.13\n"
domain: automation
input:
controller:
name: Controller Name
description: The name of the controller as defined in Z2M (e.g. Livingroom_Switch)
default: []
selector:
text:
type: text
multiple: true
multiline: false
settings_section:
name: Settings
icon: mdi:cog-outline
collapsed: true
input:
base_topic:
name: Base topic (MQTT)
description: The base topic as configured in z2m
default: zigbee2mqtt
hold_delay:
name: Hold delay
description: If the button has been held more than the configured Hold delay,
the corresponding held action is triggered.
default: 500
selector:
number:
min: 100.0
max: 1000.0
unit_of_measurement: milliseconds
mode: box
step: 10.0
ptm216z_selector:
name: PTM216Z
description: Turn **On** only if using a PTM216Z
default: false
selector:
boolean: {}
helper_last_controller_event:
name: PTM216Z - Last Controller Event
description: 'Input Text used to store the last event fired by the controller.
You will need to manually create a text input Helper entity for this.
'
default: []
selector:
entity:
domain:
- input_text
multiple: false
reorder: false
ptm21xz_ze_actions:
name: PTM21xZ/ZE - Actions
icon: mdi:gesture-tap
collapsed: true
input:
button_1_pressed:
name: Button 1 Pressed
description: Action to run when button 1 is pressed.
default: []
selector:
action: {}
button_1_held:
name: Button 1 Held
description: Action to run when the button 1 is held.
default: []
selector:
action: {}
button_1_released:
name: Button 1 Released
description: Action to run when the button 1 is released after long press.
default: []
selector:
action: {}
button_2_pressed:
name: Button 2 Pressed
description: Action to run when the button 2 pressed.
default: []
selector:
action: {}
button_2_held:
name: Button 2 Held
description: Action to run when the button 2 is held.
default: []
selector:
action: {}
button_2_released:
name: Button 2 Released
description: Action to run when the button 2 is released after long press.
default: []
selector:
action: {}
button_3_pressed:
name: Button 3 Pressed
description: Action to run when the button 3 is pressed.
default: []
selector:
action: {}
button_3_held:
name: Button 3 Held
description: Action to run when the button 3 is held.
default: []
selector:
action: {}
button_3_released:
name: Button 3 Released
description: Action to run when the button 3 is released after long press.
default: []
selector:
action: {}
button_4_pressed:
name: Button 4 Pressed
description: Action to run when the button 4 is pressed.
default: []
selector:
action: {}
button_4_held:
name: Button 4 Held
description: Action to run when the button 4 is held.
default: []
selector:
action: {}
button_4_released:
name: Button 4 Released
description: Action to run when the button 4 is released after long press.
default: []
selector:
action: {}
button_1_and_3_pressed:
name: Buttons 1 and 3 Pressed
description: Action to run when buttons 1 and 3 are pressed.
default: []
selector:
action: {}
button_1_and_3_held:
name: Buttons 1 and 3 Held
description: Action to run when buttons 1 and 3 are held.
default: []
selector:
action: {}
button_1_and_3_released:
name: Buttons 1 and 3 Released
description: Action to run when buttons 1 and 3 are released after long
press.
default: []
selector:
action: {}
button_2_and_4_pressed:
name: Buttons 2 and 4 Pressed
description: Action to run when buttons 2 and 4 are pressed.
default: []
selector:
action: {}
button_2_and_4_held:
name: Buttons 2 and 4 Held
description: Action to run when buttons 2 and 4 are held.
default: []
selector:
action: {}
button_2_and_4_released:
name: Buttons 2 and 4 Released
description: Action to run when buttons 2 and 4 are released after long
press.
default: []
selector:
action: {}
ptm21xz_ze_two_fingers_actions:
name: PTM215ZE / PTM216Z - Two fingers actions
icon: mdi:gesture-two-tap
collapsed: true
input:
button_1_and_4_pressed:
name: Buttons 1 and 4 Pressed
description: Action to run when buttons 1 and 4 are pressed.
default: []
selector:
action: {}
button_1_and_4_held:
name: Buttons 1 and 4 Held
description: Action to run when buttons 1 and 4 are held.
default: []
selector:
action: {}
button_1_and_4_released:
name: Button 1 and 4 Released
description: Action to run when buttons 1 and 4 are released after long
press.
default: []
selector:
action: {}
button_2_and_3_pressed:
name: Buttons 2 and 3 Pressed
description: Action to run when buttons 2 and 3 are pressed.
default: []
selector:
action: {}
button_2_and_3_held:
name: Buttons 2 and 3 Held
description: Action to run when buttons 2 and 3 are held.
default: []
selector:
action: {}
button_2_and_3_released:
name: Buttons 2 and 3 Released
description: Action to run when buttons 2 and 3 are released after long
press.
default: []
selector:
action: {}
source_url: https://github.com/chris-1243/HA---Blueprint/blob/main/PTM_21xZ_ZE.yaml
mode: single
max_exceeded: silent
trigger_variables:
base_topic: !input base_topic
triggers:
- trigger: mqtt
topic: '{{ base_topic ~ "/+" ~ "/action" }}'
variables:
command: '{{ trigger.payload }}'
controller: !input controller
mqtt_topic: '{{ trigger.topic }}'
conditions:
and:
- '{{ mqtt_topic.split("/")[1] in controller }}'
- '{{ command.split("_", 1)[0] in ("press", "release") }}'
actions:
- variables:
helper_last_controller_event: !input helper_last_controller_event
ptm216z: !input ptm216z_selector
prev_command: '{% if ptm216z %} {{ states(helper_last_controller_event) }} {%
else %} none {% endif %}'
- sequence:
- if: '{{ ptm216z }}'
then:
- action: input_text.set_value
data:
entity_id: '{{ helper_last_controller_event }}'
value: '{{ command }}'
- choose:
- conditions: '{{ "release" in command }}'
sequence:
- choose:
- conditions: '{{ command == "release_1" or prev_command == "press_1" }}'
sequence: !input button_1_released
- conditions: '{{ command == "release_2" or prev_command == "press_2" }}'
sequence: !input button_2_released
- conditions: '{{ command == "release_3" or prev_command == "press_3" }}'
sequence: !input button_3_released
- conditions: '{{ command == "release_4" or prev_command == "press_4" }}'
sequence: !input button_4_released
- conditions: '{{ command == "release_1_and_3" or prev_command == "press_1_and_3"
}}'
sequence: !input button_1_and_3_released
- conditions: '{{ command == "release_2_and_4" or prev_command == "press_2_and_4"
}}'
sequence: !input button_2_and_4_released
- conditions: '{{ command == "release_1_and_4" or prev_command == "press_1_and_4"
}}'
sequence: !input button_1_and_4_released
- conditions: '{{ command == "release_2_and_3" or prev_command == "press_2_and_3"
}}'
sequence: !input button_2_and_3_released
- conditions: '{{ "press" in command }}'
sequence:
- wait_for_trigger:
- trigger: mqtt
topic: '{{ mqtt_topic }}'
payload: release
value_template: '{{ value.split("_", 1)[0] }}'
timeout:
milliseconds: !input hold_delay
- if: '{{ wait.trigger != None }}'
then:
- choose:
- conditions: '{{ command == "press_1" }}'
sequence: !input button_1_pressed
- conditions: '{{ command == "press_2" }}'
sequence: !input button_2_pressed
- conditions: '{{ command == "press_3" }}'
sequence: !input button_3_pressed
- conditions: '{{ command == "press_4" }}'
sequence: !input button_4_pressed
- conditions: '{{ command == "press_1_and_3" }}'
sequence: !input button_1_and_3_pressed
- conditions: '{{ command == "press_2_and_4" }}'
sequence: !input button_2_and_4_pressed
- conditions: '{{ command == "press_1_and_4" }}'
sequence: !input button_1_and_4_pressed
- conditions: '{{ command == "press_2_and_3" }}'
sequence: !input button_2_and_3_pressed
else:
- choose:
- conditions: '{{ command == "press_1" }}'
sequence: !input button_1_held
- conditions: '{{ command == "press_2" }}'
sequence: !input button_2_held
- conditions: '{{ command == "press_3" }}'
sequence: !input button_3_held
- conditions: '{{ command == "press_4" }}'
sequence: !input button_4_held
- conditions: '{{ command == "press_1_and_3" }}'
sequence: !input button_1_and_3_held
- conditions: '{{ command == "press_2_and_4" }}'
sequence: !input button_2_and_4_held
- conditions: '{{ command == "press_1_and_4" }}'
sequence: !input button_1_and_4_held
- conditions: '{{ command == "press_2_and_3" }}'
sequence: !input button_2_and_3_held