athua
(Gus)
June 15, 2023, 4:40am
104
Double clicks have been having issues since HA 2023.5 was released.
See the following issues discussion which contains work-around to get it working:
opened 12:36PM - 05 May 23 UTC
bug
blueprint
### Blueprint name
Controller - IKEA E1743 TRÅDFRI On/Off Switch & Dimmer
… ### Home Assistant Core Version
2023.5.1
### Home Assistant Installation Type
Home Assistant Operating System
### Description
The Blueprint 'Controller - IKEA E1743 On/Off Switch & Dimmer' stopped working after recent Home Assistant update
Upon further inspection it’s simply the double tap feature of that controller/blueprint that’s not working. The single press and long press functionality is working but the double press functionality is dead and appears to be throwing errors in the error log. Here is just one example of what I see simply after a home assistant reboot:
Logger: homeassistant.components.automation
Source: components/automation/config.py:207
Integration: Automation (documentation, issues)
First occurred: 6:58:51 AM (1 occurrences)
Last logged: 6:58:51 AM
Blueprint 'Controller - IKEA E1743 On/Off Switch & Dimmer' generated invalid automation with inputs {'integration': 'deCONZ', 'controller_device': 'd798e7a289381fe620c8ca2f6f1c7c9e', 'helper_last_controller_event': 'input_text.text1', 'action_button_up_double': [{'service': 'light.turn_on', 'data': {}, 'target': {'entity_id': 'light.living_room_fan_lights'}}], 'action_button_down_double': [{'service': ''}], 'button_up_double_press': True, 'button_down_double_press': True, 'helper_double_press_delay': 1000, 'action_button_up_short': [{'type': 'turn_on', 'device_id': 'bc0d7e01c84ff0e016a4c6bd1a6c480b', 'entity_id': 'light.texas_instruments_cc1352_cc2652_z_stack_3_30_build_20220219_living_room_downlights_zha_group_zha_group_0x0002', 'domain': 'light', 'brightness_pct': 100}], 'action_button_down_short': [{'type': 'turn_off', 'device_id': 'bc0d7e01c84ff0e016a4c6bd1a6c480b', 'entity_id': 'light.texas_instruments_cc1352_cc2652_z_stack_3_30_build_20220219_living_room_downlights_zha_group_zha_group_0x0002', 'domain': 'light'}], 'action_button_up_long': [{'device_id': 'bc0d7e01c84ff0e016a4c6bd1a6c480b', 'domain': 'light', 'entity_id': 'light.texas_instruments_cc1352_cc2652_z_stack_3_30_build_20220219_living_room_downlights_zha_group_zha_group_0x0002', 'type': 'brightness_increase'}], 'action_button_down_long': [{'device_id': 'bc0d7e01c84ff0e016a4c6bd1a6c480b', 'domain': 'light', 'entity_id': 'light.texas_instruments_cc1352_cc2652_z_stack_3_30_build_20220219_living_room_downlights_zha_group_zha_group_0x0002', 'type': 'brightness_decrease'}], 'button_up_long_loop': True, 'button_down_long_loop': True, 'button_up_long_max_loop_repeats': 2500, 'button_down_long_max_loop_repeats': 2500}: Service does not match format <domain>.<name> for dictionary value @ data['action'][3]['choose'][3]['sequence'][0]['choose'][0]['sequence'][0]['choose'][0]['sequence'][2]['choose'][0]['sequence'][0]['service']. Got ''
### Automation YAML config
```yaml
alias: Bathroom - Doubletap - Fan
description: ""
use_blueprint:
path: EPMatt/ikea_e1743.yaml
input:
integration: deCONZ
controller_device: 1291a6dbd2844a87b99006cff6b0a308
helper_last_controller_event: input_text.text1
button_up_double_press: true
button_down_double_press: true
action_button_up_double:
- type: turn_on
device_id: 4b3c7d62506e2024325e9ac0a60eeed0
entity_id: switch.bathroom_fan
domain: switch
action_button_down_double:
- type: turn_off
device_id: 4b3c7d62506e2024325e9ac0a60eeed0
entity_id: switch.bathroom_fan
domain: switch
helper_double_press_delay: 1000
```
### To Reproduce
1. Go to '...'
2. Click on '....'
3. Trigger the automation '....'
4. See error
Logger: homeassistant.helpers.template
Source: helpers/template.py:237
First occurred: 8:35:01 AM (1 occurrences)
Last logged: 8:35:01 AM
Template variable error: 'dict object' has no attribute 'event' when rendering '{%- 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 -%}'
Logger: homeassistant.components.automation.bathroom_doubletap_fan
Source: helpers/script.py:410
Integration: Automation ([documentation](https://www.home-assistant.io/integrations/automation), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+automation%22))
First occurred: 8:35:01 AM (1 occurrences)
Last logged: 8:35:01 AM
Bathroom - Doubletap - Fan: Error executing script. Error rendering template for variables at pos 2: UndefinedError: 'dict object' has no attribute 'event'
Logger: homeassistant.components.automation.bathroom_doubletap_fan
Source: components/automation/__init__.py:254
Integration: Automation ([documentation](https://www.home-assistant.io/integrations/automation), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+automation%22))
First occurred: 8:35:01 AM (1 occurrences)
Last logged: 8:35:01 AM
Error while executing automation automation.bathroom_doubletap_fan: UndefinedError: 'dict object' has no attribute 'event'
### Expected behavior
I would expect the device_id of 4b3c7d62506e2024325e9ac0a60eeed0 to turn on/off.
### Actual Behaviour
Nothing -- error is thrown, and device never receives command.
### Additional Details
- [ ] I'd like to help developing a fix for this issue.
### Screenshots
_No response_
### Additional context
_No response_
I applied the fix and its working for me using Zigbee2MQTT:
Search for the regex_match code and replace it with the following (some spaces have been removed):
regex_match("^{((“a”:".*"|“t”:\d+.\d+)(,)?){2}}$"))
1 Like
Nick4
(Nick)
June 15, 2023, 7:43am
105
THANK YOU, you have put me in the right direction!
At first I didn’t have a clue where to find this and then it didn’t work since the code you gave seems to be for another zigbee integration.
Nick4
(Nick)
June 15, 2023, 7:52am
106
For anyone having this double click issue.
You have to open the blueprint file (so not the blueprint in your HA UI but in your filesystem ) for the automation you used for this button. (maybe make a copy)
Find regex_match and replace the string following to it.
This string is different for the type of zigbee integration you use.
For Zigbee2MQTT it’s:
regex_match("^\{((\"a\":\".*\"|\"t\":\d+\.\d+)(,)?){2}\}$"))
For deCONZ:
regex_match("^{(("a":.*|"t":\d+.\d+)(,)?){2}}$"))
For ZHA: can’t find the code but you have to remove the spaces between the brackets.
Save the file and reload your automations.
5 Likes
I have tried this with no luck - surely the official blueprint can be updated?
Nick4
(Nick)
July 25, 2023, 11:19am
108
Hi Damien, what did you do?
It’s not that hard, for me this was unknown terrain too.
Which integration do you use?
1 Like
Using Zigbee2MQTT.
Just managed to fix it though. I copied the latest blueprint yaml files from the awesome-ha-blueprints repo and removed 6 spaces total, 3 from each of the regex lines.
1 Like
This worked for ZHA. 6 total spaces in 2 different regex lines.
Sorry, but which spaces between which brackets?
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 "" }}'
I thought we needed spaces between {{ and the (
tego1
(Tego1)
August 10, 2023, 11:39am
112
Hi, this blueprint looks great but the UP and DN buttons are not working for me.
The UP button sends this: {“a”:“step_with_on_off_StepMode.Up_43_5”,“t”:1691605619.133851}
and DN this: {“a”:“step_StepMode.Down_43_5_0_0”,“t”:1691605611.559078}
Any ideas?
Thank you
Nick4
(Nick)
August 10, 2023, 8:22pm
113
Hi Dave, I just did a recap from what I found when I had this issue as well.
I just used the that example for z2m which solved my problem.
As you can see, there are no spaces between the {{ and (
So what is in the Git repo is already correct? What I posted just above is exactly how it currently is in the repo
athua
(Gus)
August 11, 2023, 4:56am
115
sparkydave:
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 "" }}'
You need to change it to:
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 "" }}'
ie. remove the space between the : and \ and also between the , and )
1 Like
does this fix work in 2023.7?
I’m trying to apply it in mine, and it keeps generating this error each time i chuck the new deconz regex in and reload my automations:
invalid template (TemplateSyntaxError: expected token ',', got 'a') for dictionary value @ data['action'][1]['variables']['last_controller_event']. Got '{{ (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 "" }}' invalid template (TemplateSyntaxError: expected token ',', got 'a') for dictionary value @ data['action'][1]['variables']['trigger_delta']. Got '{{ (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 }}'
Nick4
(Nick)
August 27, 2023, 5:36pm
117
Hi, welcome to the forum!
You seem to have used the wrong string.
Have a look a little higher in this topic for my post with the correct one for deCONZ.
1 Like
i’d have sworn up and down i was using the deconz one
i suppose that’s what happens when you try this stuff before bed haha
for my own sanity, this:
regex_match("^{(("a":.*|"t":\d+.\d+)(,)?){2}}$"))
is the correct string, isn’t it?
I’ve replaced the regex that appears on lines 439 and 440 of the blueprint, but it’s still not working for me - I’ll be honest, I suck at regex, and I’m not even sure where I should start to begin troubleshooting. If someone could point me in the correct direction, I’d be eternally grateful.
i don’t suppose anyone has any ideas as to the above?
i’ve tried mucking round a bit over the last couple weeks, and i just can’t seem to get it working as it should with the double presses
the single press works fine, but no matter what i do, the double press just doesn’t seem to work
Nick4
(Nick)
September 13, 2023, 9:48am
120
If you have solved the issue of the spaces correctly it will be something else.
near as i can tell it’s gotta be something else - the traces on the automation seem to be fine, the controller is firing 5002 and 4002 events on the right and left buttons, and the time looks to be correct as well - the automation just isn’t picking up the double presses, and i’m legitimately bamboozled as to why
i got it working!
the deconz regex above isn’t quite right, or at least it wasn’t for me. this is what got me up and running in the end:
regex_match("^\{((\"a\":.*|\"t\":\d+\.\d+)(,)?){2}\}$"))
the regex for deconz above in the thread wasn’t parsing the quotes around the “a” properly, and needed to be escaped for a literal match, as with the “t”
I learnt quite a bit about regex tonight! thanks for the help @Nick4
it was absolutely something else, and i’m glad i wasn’t going nuts
1 Like
djgizmo
September 22, 2023, 1:31am
123
I’ve installed this and added the latest regex mod… but I can’t seem to get the up, left, right, or down buttons to work. Only the center button (but both for click and double click.)
Trace shows:
Triggered by the event 'zha_event' at September 21, 2023 at 9:29:36 PM
Test Test if 2 conditions matches
Delay for 50 milliseconds
Define variables trigger_action, trigger_delta, and last_controller_event
Call a service 'Input text: Set' on
(input_text.julieremotelastcontrolledevent) turned {"a":"step_with_on_off_StepMode.Up_43_5","t":1695346176.657274}
Choose: No action taken
Finished at September 21, 2023 at 9:29:36 PM (runtime: 0.06 seconds)
Any suggestions?