This is a blueprint for the IKEA Tradfri Shortcut Button E1812.
The states of the action are internal send as on/off/brightness_move_up/brightness_stop.
I transformed them into single press, double press, long_press and released.
For each of them you can select actions that will be performed.
Because I am quite new to home assistant I am happy for useful feedback for improving the code.
Blueprint Code
Click the badge to import this Blueprint: (needs Home Assistant Core that supports zigbee2mqtt)
Or import this Blueprint by using the forum topic URL:
blueprint:
name: 'Z2M IKEA Shortcut Button E1812'
description: "Blueprint for Ikea Tradfri Shortcut Button E1812. You can put several actions to each single press, double press and long press."
domain: automation
source_url: https://community.home-assistant.io/t/z2m-ikea-tradfri-shortcut-button-e1812-universal-actions/522409
input:
button:
name: Remote
description: IKEA Shortcut Button to use (e.g sensor.kitchen_remote_action)
selector:
entity:
integration: mqtt
domain: sensor
multiple: false
single:
name: Action when On sended
description: Action to run when SHORT press
default: []
selector:
action: {}
double:
name: Action when Off sended
description: Action to run when DOUBLE SHORT press
default: []
selector:
action: {}
long:
name: Action when Brightness_move_up sended
description: Action to run when LONG press
default: []
selector:
action: {}
released:
name: Action when Brightness_stop sended
description: Action to run when LONG press RELEASED
default: []
selector:
action: {}
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id:
- !input button
to: "off"
id: "off"
- platform: state
entity_id:
- !input button
to: "on"
id: "on"
- platform: state
entity_id:
- !input button
to: "brightness_move_up"
id: "long_down"
- platform: state
entity_id:
- !input button
to: "brightness_stop"
id: "stop"
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: "off"
sequence: !input double
- conditions:
- condition: trigger
id: "on"
sequence: !input single
- conditions:
- condition: trigger
id: "long_down"
sequence: !input long
- conditions:
- condition: trigger
id: "stop"
sequence: !input released
i cant get it in my Blueprint list .
When i try i get this massage: No valid blueprint found in the topic. Blueprint syntax blocks need to be marked as YAML or no syntax.
Here is the yaml code only for 3 actions.
The reason is, that when you hold the button, it sends brightness_move_up and as soon you release it sends a brightness_stop. If that is a trigger, than the automation restarts and actions might not be fully executed.
Blueprint Code
Click the badge to import this Blueprint: (needs Home Assistant Core that supports zigbee2mqtt)
Or import this Blueprint by using the forum topic URL:
blueprint:
name: 'Z2M IKEA Shortcut Button E1812 3 Universal Actions'
description: "Blueprint for Ikea Tradfri Shortcut Button E1812. You can put several actions to each single press, double press and long press."
domain: automation
source_url: https://community.home-assistant.io/t/z2m-ikea-tradfri-shortcut-button-e1812-universal-actions/522409/3
input:
button:
name: Remote
description: IKEA Shortcut Button to use (e.g sensor.kitchen_remote_action)
selector:
entity:
integration: mqtt
domain: sensor
multiple: false
single:
name: Action when On sended
description: Action to run when SHORT press
default: []
selector:
action: {}
double:
name: Action when Off sended
description: Action to run when DOUBLE SHORT press
default: []
selector:
action: {}
long:
name: Action when Brightness_move_up sended
description: Action to run when LONG press
default: []
selector:
action: {}
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id:
- !input button
to: "off"
id: "off"
- platform: state
entity_id:
- !input button
to: "on"
id: "on"
- platform: state
entity_id:
- !input button
to: "brightness_move_up"
id: "long_down"
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: "off"
sequence: !input double
- conditions:
- condition: trigger
id: "on"
sequence: !input single
- conditions:
- condition: trigger
id: "long_down"
sequence: !input long
Thanks for the template!.
The short button press works like a charm, i’m just having some difficulties with the double press. Do you have any idea why this doesn’t work?.
Maybe I missed something, but with the migration to Z2M 2.0, *_action are not available anymore on HA, so this blueprint doesn’t work anymore.
Any idea how to fix it ? (for the time being I added this to Z2M conf : legacy_action_sensor: true, but keeping “legacy” setting is not the correct way to do it
Can confirm this doesn’t work if you set legacy_triggers to false. I just setup my automation from scratch using the mqtt trigger. Just set the “topic” to <your_device_topic>/action with on as the payload which will capture the button press. If you want to register the double-click, use off as the payload. Here’s my new automation:
This worked for me, thank you so much!
Your script is for a single click. Can I integrate double and long click into the same script (and how to then?) or do I have to make separate automations for them?
Instead of importing this as a new template, I just copied your edits and pasted them over the existing template I have in my HA. I needed to reselect the E1812 device in the automation but that’s about it, all is good now.