@Uzi71 na klar, teile ich gerne. Ohne die Community wäre ich ja auch nie so weit gekommen.
Hier der Blueprint, für zigbee2mqtt und wichtig dabei, dass in zigbee2mqtt > Einstellungen > Erweitert „Elapsed“ aktiviert ist:
blueprint:
name: Z2M - Hue Dimmer switch v2 (929002398602)
description:
"Define actions your Philips Hue Dimmer switch v2 using Zigbee2MQTT.
Use the controller name as defined in Z2M e.g. (Livingroom Switch).
Make sure that 'Elapsed' is enabled in the z2m advanced settings."
# Based on the fixed Blueprint Hue Tap dial switch by vandalon
# and Philips Hue Dimmer switch v2 by CrazyCoder. See sources.
domain: automation
input:
controller:
name: (Zigbee2MQTT) Controller Name
description: The name of the controller as defined in z2m (e.g. Livingroom Switch)
default: ""
base_topic:
name: (Zigbee2MQTT) Base mqtt topic
description: The base topic as configured in z2m
default: zigbee2mqtt
remote_button_on_press:
name: Button On Press
description: Action to run on button 1 single press
default: []
selector:
action: {}
remote_button_on_press_release:
name: Button On Press Release
description: Action to run on button 1 press release
default: []
selector:
action: {}
remote_button_on_hold:
name: Button On Hold
description: Action to run on button 1 hold
default: []
selector:
action: {}
remote_button_on_hold_release:
name: Button On Hold Release
description: Action to run on button 1 hold release
default: []
selector:
action: {}
remote_button_up_press:
name: Button Up Press
description: Action to run on button 2 single press
default: []
selector:
action: {}
remote_button_up_press_release:
name: Button Up Press Release
description: Action to run on button 2 press release
default: []
selector:
action: {}
remote_button_up_hold:
name: Button Up Hold
description: Action to run on button 2 hold
default: []
selector:
action: {}
remote_button_up_hold_release:
name: Button Up Hold Release
description: Action to run on button 2 hold release
default: []
selector:
action: {}
remote_button_down_press:
name: Button Down Press
description: Action to run on button 3 single press
default: []
selector:
action: {}
remote_button_down_press_release:
name: Button Down Press Release
description: Action to run on button 3 press release
default: []
selector:
action: {}
remote_button_down_hold:
name: Button Down Hold
description: Action to run on button 3 hold
default: []
selector:
action: {}
remote_button_down_hold_release:
name: Button Down Hold Release
description: Action to run on button 3 hold release
default: []
selector:
action: {}
remote_button_off_press:
name: Button Off Press
description: Action to run on button 4 single press
default: []
selector:
action: {}
remote_button_off_press_release:
name: Button Off Press Release
description: Action to run on button 4 press release
default: []
selector:
action: {}
remote_button_off_hold:
name: Button Off Hold
description: Action to run on button 4 hold
default: []
selector:
action: {}
remote_button_off_hold_release:
name: Button Off Hold Release
description: Action to run on button 4 hold release
default: []
selector:
action: {}
#source_url: https://gist.github.com/vandalon/20649ce1fbe5d91902d9c17f27751254
#similar fix https://community.home-assistant.io/t/warning-after-reboot-typeerror-argument-of-type-nonetype-is-not-iterable/681902/26
#and https://gist.github.com/CrazyCoder/28d660d9e2e8464458e591ad79b3698e
mode: restart
max_exceeded: silent
trigger_variables:
base_topic: !input "base_topic"
controller: !input "controller"
trigger:
- platform: mqtt
topic: "{{ base_topic ~ '/' ~ controller }}"
condition:
- condition: template
value_template: >-
{{ as_timestamp(now()) - as_timestamp(states.binary_sensor.zigbee2mqtt_bridge_connection_state.last_changed) | int > 30 }}
- condition: template
value_template: >
{{ trigger.payload_json.action is defined and trigger.payload_json.elapsed is defined}}
action:
- variables:
action: '{{ trigger.payload_json.action }}'
- choose:
- conditions: '{{ action == ''on_press'' }}'
sequence: !input remote_button_on_press
- conditions: '{{ action == ''on_press_release'' }}'
sequence: !input remote_button_on_press_release
- conditions: '{{ action == ''on_hold'' }}'
sequence: !input remote_button_on_hold
- conditions: '{{ action == ''on_hold_release'' }}'
sequence: !input remote_button_on_hold_release
- conditions: '{{ action == ''up_press'' }}'
sequence: !input remote_button_up_press
- conditions: '{{ action == ''up_press_release'' }}'
sequence: !input remote_button_up_press_release
- conditions: '{{ action == ''up_hold'' }}'
sequence: !input remote_button_up_hold
- conditions: '{{ action == ''up_hold_release'' }}'
sequence: !input remote_button_up_hold_release
- conditions: '{{ action == ''down_press'' }}'
sequence: !input remote_button_down_press
- conditions: '{{ action == ''down_press_release'' }}'
sequence: !input remote_button_down_press_release
- conditions: '{{ action == ''down_hold'' }}'
sequence: !input remote_button_down_hold
- conditions: '{{ action == ''down_hold_release'' }}'
sequence: !input remote_button_down_hold_release
- conditions: '{{ action == ''off_press'' }}'
sequence: !input remote_button_off_press
- conditions: '{{ action == ''off_press_release'' }}'
sequence: !input remote_button_off_press_release
- conditions: '{{ action == ''off_hold'' }}'
sequence: !input remote_button_off_hold
- conditions: '{{ action == ''off_hold_release'' }}'
sequence: !input remote_button_off_hold_release
Die auf diesem Blueprint aufbauende Automation könnte so aussehen (nur als Beispiel, nicht einfach kopieren):
alias: DEIN NAME FÜR DIE AUTOMATION
description: ""
use_blueprint:
path: DER PFAD ZUM BLUEPRINT
input:
controller: NAME DEINES HUE DIMMERS
remote_button_on_press: []
remote_button_up_hold:
- service: light.turn_on
data:
brightness_step: 25
transition: 1
target:
device_id: DEINE LEUCHTE
enabled: true
remote_button_down_hold:
- service: light.turn_on
data:
brightness_step: -25
transition: 1
target:
device_id: DEINE LEUCHTE
enabled: true
remote_button_down_hold_release: []
remote_button_up_hold_release: []
remote_button_up_press_release:
- service: mqtt.publish
metadata: {}
data:
qos: "0"
retain: false
topic: zigbee2mqtt/NAME DER LEUCHTE IN ZIGBEE2MQTT/set
payload: "{\"brightness_step\": 51, \"transition\": 1}"
remote_button_down_press_release:
- service: mqtt.publish
metadata: {}
data:
qos: "0"
retain: false
topic: zigbee2mqtt/NAME DER LEUCHTE IN ZIGBEE2MQTT/set
payload: "{\"brightness_step\": -51, \"transition\": 1}"
remote_button_on_press_release:
- choose:
- conditions:
- condition: device
type: is_off
device_id: DEINER LEUCHTE
entity_id: DEINER LEUCHTE
domain: light
sequence:
- type: turn_on
device_id: DEINER LEUCHTE
entity_id: DEINER LEUCHTE
domain: light
- conditions:
- condition: device
type: is_on
device_id: DEINER LEUCHTE
entity_id: DEINER LEUCHTE
domain: light
sequence:
- type: turn_off
device_id: DEINER LEUCHTE
entity_id: DEINER LEUCHTE
domain: light
remote_button_off_press_release:
- choose:
- conditions:
- condition: device
type: is_off
device_id: DEINER LEUCHTE
entity_id: DEINER LEUCHTE
domain: light
sequence:
- service: light.toggle
metadata: {}
data: {}
target:
entity_id: light.DEINE LEUCHTE
- conditions:
- condition: device
type: is_on
device_id: DEINER LEUCHTE
entity_id: DEINER LEUCHTE
domain: light
sequence:
- service: input_select.select_next
target:
entity_id: input_select.NAME DES HELFERS_szenenwahl
data:
cycle: true
- service: scene.turn_on
target:
entity_id: >-
scene.{{
states.input_select.NAME DEINES HELFES_szenenwahl.state }}
default: []
Den Helfer „Szenenwahl“ für die Automation zum durchwechseln der Szenen, habe ich hier schon mal erklärt: