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

Bug - Ikea Shortcut Button Double Click does not work #593

Open
1 task
hackintoshlover opened this issue Jan 18, 2024 · 8 comments · May be fixed by #600
Open
1 task

Bug - Ikea Shortcut Button Double Click does not work #593

hackintoshlover opened this issue Jan 18, 2024 · 8 comments · May be fixed by #600
Labels
blueprint An issue related to a blueprint bug Something isn't working

Comments

@hackintoshlover
Copy link

Blueprint name

Controller - IKEA E1812 TRÅDFRI Shortcut button

Home Assistant Core Version

2023.11.3

Home Assistant Installation Type

Home Assistant Operating System

Description

I imported the Ikea shortcut button blueprint and set it up everything works as expected, except double click.
Attached screenshots of setup with error.
I having configured the device using zigbee 2 mqtt setup.

Automation YAML config

Attachedalias: Controller - IKEA E1812 TRÅDFRI Shortcut button
description: ""
use_blueprint:
  path: EPMatt/ikea_e1812.yaml
  input:
    integration: Zigbee2MQTT
    controller_entity: sensor.0x94deb8fffee14abe_action
    action_button_double:
      - service: switch.toggle
        data: {}
        target:
          device_id: 9d9d853ecd3efa803f10702640113de1
    helper_double_press_delay: 1000
    button_double_press: true
    helper_last_controller_event: input_text.helper_last_controller_event

To Reproduce

Import blueprint.
Setup as image below.
Run.

Expected behavior

Double click should toggle switch.

Actual Behaviour

Nothing.

Additional Details

  • I'd like to help developing a fix for this issue.

Screenshots

Screenshot (364)
Screenshot (363)
Screenshot (362)
Screenshot (361)
Screenshot (360)
Screenshot (359)
Screenshot (358)
Screenshot (357)
Screenshot (356)

Additional context

No response

@hackintoshlover hackintoshlover added blueprint An issue related to a blueprint bug Something isn't working labels Jan 18, 2024
@t08
Copy link

t08 commented Jan 30, 2024

same here. Also a note is that the (Optional) Helper - Double Press delay is working-isch, it takes the delay, after that it just fires the single press action

@ZtormTheCat
Copy link

I also have this problem and did a little digging in the traces. It seems like the time since the last command doesn't get set correctly. I'm currently working on finding out where the problem exactly lies and will try to fix it.

@ZtormTheCat
Copy link

I found the problem. It has to do with RegEx.
The problem occurs both when trying to set trigger_delta and last_controller_event.
It seems that for some time now the regex to determine if the Helper contains the correct string doesn't match, even though it is correct.

I am in no way a home assistant or scripting expert but to me it seems like some way down the line the way home assistant handles whitespaces in RegEx changed.

This is the current way the automation checks for the correctness:

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 }}

If you change this to:

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 }}

It gets matched correctly. All I did was remove all whitespaces in the RegEx.

@hackintoshlover
Copy link
Author

I found the problem. It has to do with RegEx. The problem occurs both when trying to set trigger_delta and last_controller_event. It seems that for some time now the regex to determine if the Helper contains the correct string doesn't match, even though it is correct.

I am in no way a home assistant or scripting expert but to me it seems like some way down the line the way home assistant handles whitespaces in RegEx changed.

This is the current way the automation checks for the correctness:

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 }}

If you change this to:

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 }}

It gets matched correctly. All I did was remove all whitespaces in the RegEx.

Hi glad it worked for you.
just two quick questions:

  1. Where do i make these changes?
  2. The only change i see is regex_match changed to a new line. That fixes it?

@ZtormTheCat
Copy link

  1. I will try to create a Pull request today so you can just import the blueprint again. But I'll also look into how to change it locally so you don't have to wait for the PR.

  2. I also removed the spaces before the first \d and before )?

@hackintoshlover
Copy link
Author

Thanks Mate.
I hope the update happens soon.

@ZtormTheCat
Copy link

Ok, so here's how you can change it locally:
First you should install the file explorer add-on in the Add-On stored if you didn't already.
Then follow this tutorial to edit your blueprint locally.

In the blueprint navigate to line 482 and 486 (Might vary for you) and change all the regex strings to not contain ANY whitespaces aka Spaces and newlines. Then save the .yaml file and restart Home Assistant(Honestly don't know if thats necessary).

If you still need help doing it, feel free to ask.

@ZtormTheCat ZtormTheCat linked a pull request Feb 8, 2024 that will close this issue
3 tasks
@p4sI
Copy link

p4sI commented Feb 9, 2024

Thanks for this fix in the regex @ZtormTheCat. Worked like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blueprint An issue related to a blueprint bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants