🎮 ZHA, deCONZ, Zigbee2MQTT - Ikea E1743 On/Off Switch & Dimmer Universal blueprint - all actions + double click events - control lights, media players and more with Hooks

Hi,
Blueprint works great for the 5 button remote but double press stopped working with HA core 5.0 update. Last version it’s working is with 4.6 which I now reverted to. Any ideas how to keep this working with newer versions of HA?
Running HA supervisor on docker.
Thanks

EDIT: Nevermind I dug into the github discussions and already found that there are several pull requests for other tradfri models which changed 2 regex entries. These changes should be applied to the blueprint to make double taps work on HA 5.x. I made a pull requests for my model yaml can be downloaded here: changed regex to make double tap work again on HA 5.x by comk22 ¡ Pull Request #550 ¡ EPMatt/awesome-ha-blueprints ¡ GitHub

1 Like

Ah… that explains whats happened to my switches.

Looking at the blueprint code I think you’re talking about lines 299-305:

    trigger_delta: '{{ (as_timestamp(now()) - ((states(helper_last_controller_event)
      | from_json).t if helper_last_controller_event is not none and (states(helper_last_controller_event)
      | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")) else as_timestamp("1970-01-01
      00:00:00"))) * 1000 }}'
    last_controller_event: '{{ (states(helper_last_controller_event) | from_json).a
      if helper_last_controller_event is not none and (states(helper_last_controller_event)
      | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")) else "" }}'

Pretty sure thats a trivial fix. I’ll have a go at it later when I am home.

2 Likes

Ok, I changed my blueprint file for the E1743 and double presses are working again, by simply changing the block of code between lines 309-315 to this:

    trigger_delta: '{{ (as_timestamp(now()) - ((states(helper_last_controller_event)
      | from_json).t if helper_last_controller_event is not none and (states(helper_last_controller_event)
      | regex_match("^\{((\"a\":\".*\"|\"t\":\d+\.\d+)(,)?){2}\}$")) else as_timestamp("1970-01-01
      00:00:00"))) * 1000 }}'
    last_controller_event: '{{ (states(helper_last_controller_event) | from_json).a
      if helper_last_controller_event is not none and (states(helper_last_controller_event)
      | regex_match("^\{((\"a\":\".*\"|\"t\":\d+\.\d+)(,)?){2}\}$")) else "" }}'

One last thing was still broken. For some reason, long press down no longer works.
When listening to the ZHA events for this, this is what I get:

event_type: zha_event
data:
  device_ieee: 70:ac:08:ff:fe:b0:ef:e3
  unique_id: 70:ac:08:ff:fe:b0:ef:e3:1:0x0008
  device_id: d0c386d7bd249ec226ae57987d9b701a
  endpoint_id: 1
  cluster_id: 8
  command: move
  args:
    - 1
    - 83
    - 0
    - 0
  params:
    move_mode: 1
    rate: 83
    options_mask: 0
    options_override: 0
origin: LOCAL
time_fired: "2023-06-22T20:06:58.294432+00:00"
context:
  id: 01H3JBF6ZP4610GGRQ3WWE6BFH
  parent_id: null
  user_id: null

Which according to the existing blueprint, should be interpreted as this:-

      button_down_long:
      - move_MoveMode.Down_83_bitmap8.0_bitmap8.0

(See lines 236-237).

I’ve had to change this to:

      button_down_long:
      - move_MoveMode.Down_83_0_0

And long button down presses are now working again.

4 Likes

Can you update blueprint please? My double button wont work

Hi,

I’m using ZHA and is not working any button



id: ‘1690478735259’
alias: Controller - IKEA E1743 TRÅDFRI On/Off Switch & Dimmer
description: ‘’
use_blueprint:
path: EPMatt/ikea_e1743.yaml
input:
integration: ZHA
controller_device: 0636ea5d6cce1e93af9a14e56cab5b5e
action_button_up_short:
- type: turn_on
device_id: 0f73127aaba38182b2069c668b81f374
entity_id: 3cbfdbeedbd90a2a7f70eff657915668
domain: light
action_button_up_long:
- type: turn_on
device_id: 0f73127aaba38182b2069c668b81f374
entity_id: 3cbfdbeedbd90a2a7f70eff657915668
domain: light
action_button_up_release:
- type: turn_on
device_id: e0e897dbe4fa39dcc56335b14c144f09
entity_id: 211d965dd7a08ed77265ff7bb8da5a95
domain: light
action_button_up_double:
- type: turn_on
device_id: 0f73127aaba38182b2069c668b81f374
entity_id: 3cbfdbeedbd90a2a7f70eff657915668
domain: light

please some support here…

Nick

Hi, format your code properly please

{
“trace”: {
“last_step”: “action/1”,
“run_id”: “a04993142eb9da4c8ba9b9268ef4a24f”,
“state”: “stopped”,
“script_execution”: “error”,
“timestamp”: {
“start”: “2023-08-02T15:46:39.864527+00:00”,
“finish”: “2023-08-02T15:46:39.915265+00:00”
},
“domain”: “automation”,
“item_id”: “1690991159540”,
“error”: “UndefinedError: ‘dict object’ has no attribute ‘event’”,
“trigger”: null,
“trace”: {
“trigger”: [
{
“path”: “trigger”,
“timestamp”: “2023-08-02T15:46:39.868233+00:00”,
“changed_variables”: {
“this”: {
“entity_id”: “automation.new_automation_7”,
“state”: “on”,
“attributes”: {
“id”: “1690991159540”,
“last_triggered”: “2023-08-02T15:46:28.112870+00:00”,
“mode”: “restart”,
“current”: 0,
“friendly_name”: “New Automation”
},
“last_changed”: “2023-08-02T15:46:00.839473+00:00”,
“last_updated”: “2023-08-02T15:46:28.117414+00:00”,
“context”: {
“id”: “01H6VEVP4ENZ67D35YAKQQX1WH”,
“parent_id”: “01H6VEVP4CZ8WH3AECGXF46HHM”,
“user_id”: null
}
},
“trigger”: {
“platform”: null
},
“integration”: “ZHA”,
“button_up_long_loop”: false,
“button_up_long_max_loop_repeats”: 500,
“button_up_double_press”: false,
“button_down_long_loop”: false,
“button_down_long_max_loop_repeats”: 500,
“button_down_double_press”: false,
“helper_last_controller_event”: “”,
“helper_double_press_delay”: 500,
“helper_debounce_delay”: 0,
“integration_id”: “zha”,
“adjusted_double_press_delay”: 500,
“actions_mapping”: {
“deconz”: {
“button_up_short”: [
“1002”
],
“button_up_long”: [
“1001”
],
“button_up_release”: [
“1003”
],
“button_down_short”: [
“2002”
],
“button_down_long”: [
“2001”
],
“button_down_release”: [
“2003”
]
},
“zha”: {
“button_up_short”: [
“on”
],
“button_up_long”: [
“move_with_on_off_0_83”
],
“button_up_release”: [
“stop”
],
“button_down_short”: [
“off”
],
“button_down_long”: [
“move_1_83”
],
“button_down_release”: [
“stop”
]
},
“zigbee2mqtt”: {
“button_up_short”: [
“on”
],
“button_up_long”: [
“brightness_move_up”
],
“button_up_release”: [
“brightness_stop”
],
“button_down_short”: [
“off”
],
“button_down_long”: [
“brightness_move_down”
],
“button_down_release”: [
“brightness_stop”
]
}
},
“button_up_short”: [
“on”
],
“button_up_long”: [
“move_with_on_off_0_83”
],
“button_up_release”: [
“stop”
],
“button_down_short”: [
“off”
],
“button_down_long”: [
“move_1_83”
],
“button_down_release”: [
“stop”
],
“integrations_with_prev_event_storage”: [
“zha”,
“zigbee2mqtt”
],
“controller_entity”: “”,
“controller_device”: “0636ea5d6cce1e93af9a14e56cab5b5e”,
“controller_id”: “0636ea5d6cce1e93af9a14e56cab5b5e”
}
}
],
“action/0”: [
{
“path”: “action/0”,
“timestamp”: “2023-08-02T15:46:39.888386+00:00”,
“changed_variables”: {
“context”: {
“id”: “01H6VEW1KRYPEBEXCGH1WT1K4A”,
“parent_id”: “01H6VEW1KPG9E7DYVDHNW11TJS”,
“user_id”: null
}
},
“result”: {
“delay”: 0,
“done”: true
}
}
],
“action/1”: [
{
“path”: “action/1”,
“timestamp”: “2023-08-02T15:46:39.890085+00:00”,
“error”: “UndefinedError: ‘dict object’ has no attribute ‘event’”
}
]
},
“config”: {
“variables”: {
“integration”: “ZHA”,
“button_up_long_loop”: false,
“button_up_long_max_loop_repeats”: 500,
“button_up_double_press”: false,
“button_down_long_loop”: false,
“button_down_long_max_loop_repeats”: 500,
“button_down_double_press”: false,
“helper_last_controller_event”: “”,
“helper_double_press_delay”: 500,
“helper_debounce_delay”: 0,
“integration_id”: “{{ integration | lower }}”,
“adjusted_double_press_delay”: “{{ [helper_double_press_delay - helper_debounce_delay, 100] | max }}”,
“actions_mapping”: {
“deconz”: {
“button_up_short”: [
“1002”
],
“button_up_long”: [
“1001”
],
“button_up_release”: [
“1003”
],
“button_down_short”: [
“2002”
],
“button_down_long”: [
“2001”
],
“button_down_release”: [
“2003”
]
},
“zha”: {
“button_up_short”: [
“on”
],
“button_up_long”: [
“move_with_on_off_0_83”
],
“button_up_release”: [
“stop”
],
“button_down_short”: [
“off”
],
“button_down_long”: [
“move_1_83”
],
“button_down_release”: [
“stop”
]
},
“zigbee2mqtt”: {
“button_up_short”: [
“on”
],
“button_up_long”: [
“brightness_move_up”
],
“button_up_release”: [
“brightness_stop”
],
“button_down_short”: [
“off”
],
“button_down_long”: [
“brightness_move_down”
],
“button_down_release”: [
“brightness_stop”
]
}
},
“button_up_short”: “{{ actions_mapping[integration_id][“button_up_short”] }}”,
“button_up_long”: “{{ actions_mapping[integration_id][“button_up_long”] }}”,
“button_up_release”: “{{ actions_mapping[integration_id][“button_up_release”] }}”,
“button_down_short”: “{{ actions_mapping[integration_id][“button_down_short”] }}”,
“button_down_long”: “{{ actions_mapping[integration_id][“button_down_long”] }}”,
“button_down_release”: “{{ actions_mapping[integration_id][“button_down_release”] }}”,
“integrations_with_prev_event_storage”: [
“zha”,
“zigbee2mqtt”
],
“controller_entity”: “”,
“controller_device”: “0636ea5d6cce1e93af9a14e56cab5b5e”,
“controller_id”: “{% if integration_id==“zigbee2mqtt” %}{{controller_entity}}{% else %}{{controller_device}}{% endif %}”
},
“mode”: “restart”,
“max_exceeded”: “silent”,
“trigger”: [
{
“platform”: “event”,
“event_type”: “state_changed”,
“event_data”: {
“entity_id”: “”
}
},
{
“platform”: “event”,
“event_type”: [
“deconz_event”,
“zha_event”
],
“event_data”: {
“device_id”: “0636ea5d6cce1e93af9a14e56cab5b5e”
}
}
],
“condition”: [
{
“condition”: “and”,
“conditions”: [
“{%- set trigger_action -%} {%- if integration_id == “zigbee2mqtt” -%} {{ trigger.event.data.new_state.state }} {%- elif integration_id == “deconz” -%} {{ trigger.event.data.event }} {%- elif integration_id == “zha” -%} {{ trigger.event.data.command }}{{”" if trigger.event.data.args|length > 0}}{{ trigger.event.data.args|join("") }} {%- endif -%} {%- endset -%} {{ trigger_action not in ["",“None”] }}",
“{{ integration_id != “zigbee2mqtt” or trigger.event.data.new_state.state != trigger.event.data.old_state.state }}”
]
}
],
“action”: [
{
“delay”: {
“milliseconds”: 0
}
},
{
“variables”: {
“trigger_action”: “{%- if integration_id == “zigbee2mqtt” -%} {{ trigger.event.data.new_state.state }} {%- elif integration_id == “deconz” -%} {{ trigger.event.data.event }} {%- elif integration_id == “zha” -%} {{ trigger.event.data.command }}{{”" if trigger.event.data.args|length > 0}}{{ trigger.event.data.args|join("") }} {%- endif -%}",
“trigger_delta”: “{{ (as_timestamp(now()) - ((states(helper_last_controller_event) | from_json).t if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match(”^\{((\“a\”: \".\"|\“t\”: \d+\.\d+)(, )?){2}\}$")) else as_timestamp(“1970-01-01 00:00:00”))) * 1000 }}",
“last_controller_event”: “{{ (states(helper_last_controller_event) | from_json).a if helper_last_controller_event is not none and (states(helper_last_controller_event) | regex_match(”^\{((\“a\”: \".
\"|\“t\”: \d+\.\d+)(, )?){2}\}$")) else “” }}"
}
},
{
“service”: “input_text.set_value”,
“data”: {
“entity_id”: “”,
“value”: “{{ {“a”:trigger_action,“t”:as_timestamp(now())} | to_json }}”
}
},
{
“choose”: [
{
“conditions”: “{{ trigger_action | string in button_up_short }}”,
“sequence”: [
{
“choose”: [
{
“conditions”: “{{ button_up_double_press }}”,
“sequence”: [
{
“choose”: [
{
“conditions”: “{{ trigger_action | string in states(helper_last_controller_event) and trigger_delta | int <= helper_double_press_delay | int }}”,
“sequence”: [
{
“service”: “input_text.set_value”,
“data”: {
“entity_id”: “”,
“value”: “{{ {“a”:“double_press”,“t”:as_timestamp(now())} | to_json }}”
}
},
{
“event”: “ahb_controller_event”,
“event_data”: {
“controller”: “{{ controller_id }}”,
“action”: “button_up_double”
}
},
{
“choose”: [
{
“conditions”: [],
“sequence”: []
}
]
}
]
}
],
“default”: [
{
“delay”: {
“milliseconds”: “{{ adjusted_double_press_delay }}”
}
},
{
“event”: “ahb_controller_event”,
“event_data”: {
“controller”: “{{ controller_id }}”,
“action”: “button_up_short”
}
},
{
“choose”: [
{
“conditions”: [],
“sequence”: [
{
“type”: “toggle”,
“device_id”: “0f73127aaba38182b2069c668b81f374”,
“entity_id”: “3cbfdbeedbd90a2a7f70eff657915668”,
“domain”: “light”
}
]
}
]
}
]
}
]
}
],
“default”: [
{
“event”: “ahb_controller_event”,
“event_data”: {
“controller”: “{{ controller_id }}”,
“action”: “button_up_short”
}
},
{
“choose”: [
{
“conditions”: [],
“sequence”: [
{
“type”: “toggle”,
“device_id”: “0f73127aaba38182b2069c668b81f374”,
“entity_id”: “3cbfdbeedbd90a2a7f70eff657915668”,
“domain”: “light”
}
]
}
]
}
]
}
]
},
{
“conditions”: “{{ trigger_action | string in button_up_long }}”,
“sequence”: [
{
“event”: “ahb_controller_event”,
“event_data”: {
“controller”: “{{ controller_id }}”,
“action”: “button_up_long”
}
},
{
“choose”: [
{
“conditions”: “{{ button_up_long_loop }}”,
“sequence”: [
{
“repeat”: {
“while”: “{{ repeat.index < button_up_long_max_loop_repeats | int }}”,
“sequence”: []
}
}
]
}
],
“default”: []
}
]
},
{
“conditions”: [
“{{ trigger_action | string in button_up_release }}”,
“{{ not integration_id in integrations_with_prev_event_storage or last_controller_event | string in button_up_long }}”
],
“sequence”: [
{
“event”: “ahb_controller_event”,
“event_data”: {
“controller”: “{{ controller_id }}”,
“action”: “button_up_release”
}
},
{
“choose”: [
{
“conditions”: [],
“sequence”: []
}
]
}
]
},
{
“conditions”: “{{ trigger_action | string in button_down_short }}”,
“sequence”: [
{
“choose”: [
{
“conditions”: “{{ button_down_double_press }}”,
“sequence”: [
{
“choose”: [
{
“conditions”: “{{ trigger_action | string in states(helper_last_controller_event) and trigger_delta | int <= helper_double_press_delay | int }}”,
“sequence”: [
{
“service”: “input_text.set_value”,
“data”: {
“entity_id”: “”,
“value”: “{{ {“a”:“double_press”,“t”:as_timestamp(now())} | to_json }}”
}
},
{
“event”: “ahb_controller_event”,
“event_data”: {
“controller”: “{{ controller_id }}”,
“action”: “button_down_double”
}
},
{
“choose”: [
{
“conditions”: [],
“sequence”: []
}
]
}
]
}
],
“default”: [
{
“delay”: {
“milliseconds”: “{{ adjusted_double_press_delay }}”
}
},
{
“event”: “ahb_controller_event”,
“event_data”: {
“controller”: “{{ controller_id }}”,
“action”: “button_down_short”
}
},
{
“choose”: [
{
“conditions”: [],
“sequence”: []
}
]
}
]
}
]
}
],
“default”: [
{
“event”: “ahb_controller_event”,
“event_data”: {
“controller”: “{{ controller_id }}”,
“action”: “button_down_short”
}
},
{
“choose”: [
{
“conditions”: [],
“sequence”: []
}
]
}
]
}
]
},
{
“conditions”: “{{ trigger_action | string in button_down_long }}”,
“sequence”: [
{
“event”: “ahb_controller_event”,
“event_data”: {
“controller”: “{{ controller_id }}”,
“action”: “button_down_long”
}
},
{
“choose”: [
{
“conditions”: “{{ button_down_long_loop }}”,
“sequence”: [
{
“repeat”: {
“while”: “{{ repeat.index < button_down_long_max_loop_repeats | int }}”,
“sequence”: []
}
}
]
}
],
“default”: []
}
]
},
{
“conditions”: [
“{{ trigger_action | string in button_down_release }}”,
“{{ not integration_id in integrations_with_prev_event_storage or last_controller_event | string in button_down_long }}”
],
“sequence”: [
{
“event”: “ahb_controller_event”,
“event_data”: {
“controller”: “{{ controller_id }}”,
“action”: “button_down_release”
}
},
{
“choose”: [
{
“conditions”: [],
“sequence”: []
}
]
}
]
}
]
}
],
“id”: “1690991159540”,
“alias”: “New Automation”,
“description”: “”
},
“blueprint_inputs”: {
“id”: “1690991159540”,
“alias”: “New Automation”,
“description”: “”,
“use_blueprint”: {
“path”: “EPMatt/ikea_e1743.yaml”,
“input”: {
“integration”: “ZHA”,
“controller_device”: “0636ea5d6cce1e93af9a14e56cab5b5e”,
“action_button_up_short”: [
{
“type”: “toggle”,
“device_id”: “0f73127aaba38182b2069c668b81f374”,
“entity_id”: “3cbfdbeedbd90a2a7f70eff657915668”,
“domain”: “light”
}
]
}
}
},
“context”: {
“id”: “01H6VEW1KRYPEBEXCGH1WT1K4A”,
“parent_id”: “01H6VEW1KPG9E7DYVDHNW11TJS”,
“user_id”: null
}
},
“logbookEntries”: [
{
“name”: “New Automation”,
“message”: “triggered”,
“source”: null,
“entity_id”: “automation.new_automation_7”,
“context_id”: “01H6VEW1KRYPEBEXCGH1WT1K4A”,
“when”: 1690991199.868478,
“domain”: “automation”
}
]
}

Do you realize that you have just posted some gibberish without any way for us to know what the purpose is?

I didn’t manage to upload/fix the code to be in code format, I will read more and when I will know, I will come back with the error again.

nick

Hey, this blueprint is not working anymore because of the problem with regex. @lsismeiro @LewisSpring I think I saw somewhere that you tried to keep the blueprints repo up-to-date ? I created a pull request here to fix that problem for E1743, could you accept it ? Thx !

Edit: Forgot to say it but I tested locally and it works fine after the fix.

Hi, thanks for the pull request. I haven’t got write access to the repository, but @lsismeiro will see it in due course

Hello,
this looks great. Usinf deCONZ and unfortunately I cannot make the double press working. I tried several times, all the rest works, I activated the double press options and also added the helper as required.
I tried to extend the delay between double press and also added a debouncer, but nothing changes.
no matter how fast or slow I do the double tap, this gets not detected.
Any ideas please?

Is there any progress here?
As of today, the long press and hold still doesn’t work. :frowning:

Setting:
Blueprint: Version 2022.08.08
Ikea E1743 with FW 24.4.6
HA Core: 2023.11.3
ZHA + Skyconnect

Hi @Vanessa
Have you tried this version of the blueprint?
awesome-ha-blueprints/blueprints/controllers/ikea_e1743/ikea_e1743.yaml at main ¡ lsismeiro/awesome-ha-blueprints (github.com)

We do have an issue open ( E1743 long press still doesn’t work with latest pull · Issue #4 · lsismeiro/awesome-ha-blueprints (github.com)) Re Long press but I am unable to verify it as I don’t have the device.

Yes, i tried the fork. Unfortunately still unsuccessful.

It turns out I have an E1743 :laughing:

I will test this and get back to you!!

1 Like

Seeing the same issue, Please check the issue I linked above and will continue there.

1 Like

Hey everyone!

Thanks to SandaleZ and Rofo.

I finally read this topic to the end and with your help I managed to get this blueprint to work with ZHA with IKEA E1743 button.

  1. The code needs to be edited:

config/blueprints/automation/EPMatt/ikea_e1743.yaml

By file editor

Afterwords create a new text helper by UI and extent the maximum letters to 255

At the end, refresh your automation.

For me it was lines between 216 - 228

    zha:
      button_up_short:
      - 'on'
      button_up_long:
      - move_with_on_off_MoveMode.Up_83
      button_up_release:
      - stop_with_on_off
      button_down_short:
      - 'off'
      button_down_long:
      - move_MoveMode.Down_83_0_0
      button_down_release:
      - stop_with_on_off
  1. I also had to edit the code below in the same file as recommended by Rofo
    For me it was lines between 287-293
    trigger_delta: '{{ (as_timestamp(now()) - ((states(helper_last_controller_event)
      | from_json).t if helper_last_controller_event is not none and (states(helper_last_controller_event)
      | regex_match("^\{((\"a\":\".*\"|\"t\":\d+\.\d+)(,)?){2}\}$")) else as_timestamp("1970-01-01
      00:00:00"))) * 1000 }}'
    last_controller_event: '{{ (states(helper_last_controller_event) | from_json).a
      if helper_last_controller_event is not none and (states(helper_last_controller_event)
      | regex_match("^\{((\"a\":\".*\"|\"t\":\d+\.\d+)(,)?){2}\}$")) else "" }}'

Hey @Hari_Hari

These work, thank you!
Will contribute these to GitHub - lsismeiro/awesome-ha-blueprints: A curated collection of automation blueprints for Home Assistant. with credit to you

Update ikea_e1743.yaml - change actions by LewisSpring ¡ Pull Request #5 ¡ lsismeiro/awesome-ha-blueprints (github.com)

cc @Vanessa

Please test if possible by importing and switching your automations: raw.githubusercontent.com/lsismeiro/awesome-ha-blueprints/69707d91de11a3317d9276216e3c28c4f2e95f41/blueprints/controllers/ikea_e1743/ikea_e1743.yaml

1 Like

Hey @LewisSpring

I downloaded your blueprint and ran my automation on it. Everything works great. Single, double and long presses work perfectly.