Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(IKEA E1524/E1810) Improve Blueprint adding Z2M 2.0 MQTT Device Trigger support #662

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 81 additions & 10 deletions blueprints/controllers/ikea_e1524_e1810/ikea_e1524_e1810.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ blueprint:
# Controller - IKEA E1524/E1810 TRÅDFRI Wireless 5-Button Remote

Controller automation for executing any kind of action triggered by the provided IKEA E1524/E1810 TRÅDFRI Wireless 5-Button Remote. Allows to optionally loop an action on a button long press.
Supports deCONZ, ZHA, Zigbee2MQTT.
Supports deCONZ, ZHA, Zigbee2MQTT and Zigbee2MQTT in Home Assistant legacy mode.

Automations created with this blueprint can be connected with one or more [Hooks](https://epmatt.github.io/awesome-ha-blueprints/docs/blueprints/hooks) supported by this controller.
Hooks allow to easily create controller-based automations for interacting with media players, lights, covers and more.
Expand All @@ -15,7 +15,7 @@ blueprint:

🚀 This blueprint is part of the **[Awesome HA Blueprints](https://epmatt.github.io/awesome-ha-blueprints) project**.

ℹ️ Version 2025.01.03
ℹ️ Version 2025.01.05
source_url: https://github.com/EPMatt/awesome-ha-blueprints/blob/main/blueprints/controllers/ikea_e1524_e1810/ikea_e1524_e1810.yaml
domain: automation
homeassistant:
Expand All @@ -30,15 +30,16 @@ blueprint:
- deCONZ
- ZHA
- Zigbee2MQTT
- LegacyZigbee2MQTT
controller_device:
name: (deCONZ, ZHA) Controller Device
description: The controller device to use for the automation. Choose a value only if the remote is integrated with deCONZ, ZHA.
name: (deCONZ, ZHA, Zigbee2MQTT) Controller Device
description: The controller device to use for the automation. Choose a value only if the remote is integrated with deCONZ, ZHA or Zigbee2MQTT.
default: ''
selector:
device:
controller_entity:
name: (Zigbee2MQTT) Controller Entity
description: The action sensor of the controller to use for the automation. Choose a value only if the remote is integrated with Zigbee2MQTT.
name: (Legacy Zigbee2MQTT) Controller Entity
description: The action sensor of the controller to use for the automation. Choose a value only if the remote is integrated with legacy Zigbee2MQTT.
default: ''
selector:
entity:
Expand Down Expand Up @@ -387,15 +388,81 @@ variables:
# build data to send within a controller event
controller_entity: !input controller_entity
controller_device: !input controller_device
controller_id: '{% if integration_id=="zigbee2mqtt" %}{{controller_entity}}{% else %}{{controller_device}}{% endif %}'
controller_id: '{% if integration_id=="legacyzigbee2mqtt" %}{{controller_entity}}{% else %}{{controller_device}}{% endif %}'
mode: restart
max_exceeded: silent
trigger:
# trigger for zigbee2mqtt
# trigger for legacyzigbee2mqtt
- platform: event
event_type: state_changed
event_data:
entity_id: !input controller_entity
# triggers for zigbee2mqtt mqtt device action
- platform: device
domain: mqtt
device_id: !input controller_device
type: action
subtype: 'toggle'
- platform: device
domain: mqtt
device_id: !input controller_device
type: action
subtype: arrow_left_click
- platform: device
domain: mqtt
device_id: !input controller_device
type: action
subtype: arrow_left_hold
- platform: device
domain: mqtt
device_id: !input controller_device
type: action
subtype: arrow_left_release
- platform: device
domain: mqtt
device_id: !input controller_device
type: action
subtype: arrow_right_click
- platform: device
domain: mqtt
device_id: !input controller_device
type: action
subtype: arrow_right_hold
- platform: device
domain: mqtt
device_id: !input controller_device
type: action
subtype: arrow_right_release
- platform: device
domain: mqtt
device_id: !input controller_device
type: action
subtype: 'brightness_down_click'
- platform: device
domain: mqtt
device_id: !input controller_device
type: action
subtype: brightness_down_hold
- platform: device
domain: mqtt
device_id: !input controller_device
type: action
subtype: brightness_down_release
- platform: device
domain: mqtt
device_id: !input controller_device
type: action
subtype: brightness_up_click
- platform: device
domain: mqtt
device_id: !input controller_device
type: action
subtype: brightness_up_hold
- platform: device
domain: mqtt
device_id: !input controller_device
type: action
subtype: brightness_up_release
# trigger for other integrations
- platform: event
event_type:
Expand All @@ -410,6 +477,8 @@ condition:
- >-
{%- set trigger_action -%}
{%- if integration_id == "zigbee2mqtt" -%}
{{ trigger.payload }}
{%- elif integration_id == "legacyzigbee2mqtt" -%}
{{ trigger.event.data.new_state.state }}
{%- elif integration_id == "deconz" -%}
{{ trigger.event.data.event }}
Expand All @@ -418,9 +487,9 @@ condition:
{%- endif -%}
{%- endset -%}
{{ trigger_action not in ["","None"] }}
# only for zigbee2mqtt, check if the event is relative to a real state change, and not only some minor changes in the sensor attributes
# only for legacyzigbee2mqtt, check if the event is relative to a real state change, and not only some minor changes in the sensor attributes
# this is required since multiple state_changed events are fired for a single button press, with the result of the automation being triggered multiple times
- '{{ integration_id != "zigbee2mqtt" or trigger.event.data.new_state.state != trigger.event.data.old_state.state }}'
- '{{ integration_id != "legacyzigbee2mqtt" or trigger.event.data.new_state.state != trigger.event.data.old_state.state }}'
action:
# debouncing - when automation is triggered multiple times, the last automation run is the one which completes execution, due to mode restart
# therefore previous runs must wait for the debounce delay before executing any other action
Expand All @@ -432,6 +501,8 @@ action:
- variables:
trigger_action: >-
{%- if integration_id == "zigbee2mqtt" -%}
{{ trigger.payload }}
{%- elif integration_id == "legacyzigbee2mqtt" -%}
{{ trigger.event.data.new_state.state }}
{%- elif integration_id == "deconz" -%}
{{ trigger.event.data.event }}
Expand Down
Loading