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

Hey,
this is my first post so forgive me if its the wrong part of the forum.

Im trying to set up E1766 for my blinds and E1743 for my lights. I have filled in all the required fields but when I try to save it always return a “Response error: 500”.

So when I check the logs it says:
Error handling request
13:08:42 – (ERROR) components/config/automation.py

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/__init__.py", line 145, in post
    self._write_value(hass, current, config_key, data)
  File "/usr/src/homeassistant/homeassistant/components/config/automation.py", line 70, in _write_value
    cur_value[CONF_ID] = uuid.uuid4().hex
**TypeError: 'str' object does not support item assignment**

Any suggestions on what Im doing wrong here?

Hi, welcome to the forum!

The automation seems to be right, things you could try:

  • use an entity instead of a device and/or another device for the action to see if the that works
  • delete & recreate the automation

Just an idea or wait for someone else who makes more out of that error.

Figured out the fix for my long press issue.

It’s in this Pull Request for the blueprint: remove spaces to match new helper format in 2023.5 by LordSushiPhoenix · Pull Request #545 · EPMatt/awesome-ha-blueprints · GitHub

The short story is that in HA 2023.4.6 and older, the helper text messages would be something like this:

{"a": "off", "t": 1684956194.70524}

After updating to 2023.5.x, they look like this:

{"a":"off","t":1684956194.70524}

The key difference is that there is no longer a space after each colon or comma. The blueprint has regex that is hard-coded to look for that, which causes it to “miss” these events.

@tuffno: Though I don’t use Z2M (ZigBee2MQTT), there are some folks in that pull request link and in this issue link that have implemented similar fixes. Though they’re talking about a double-tap issue, it’s caused by the same bug in the end.

1 Like

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