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 - E2002: wrong regex in Code #612

Open
1 task
martin3000 opened this issue Aug 29, 2024 · 1 comment
Open
1 task

Bug - E2002: wrong regex in Code #612

martin3000 opened this issue Aug 29, 2024 · 1 comment
Labels
blueprint An issue related to a blueprint bug Something isn't working

Comments

@martin3000
Copy link

martin3000 commented Aug 29, 2024

Blueprint name

Controller - IKEA E2001/E2002 STYRBAR Remote control

Home Assistant Core Version

2024.8.1

Home Assistant Installation Type

Home Assistant Core

Description

The variable last_controller_event is only filled if the helper_last_controller_event matches the regex "^{(("a": ".*"|"t": \d+.\d+)(,)?){2}}$". This requires that the "a" and "t" keys are separated by a comma AND a blank.
But the input_text is built as {"a":trigger_action,"t":as_timestamp(now())} with only a separating comma and no blank. Also after the colon a blank is expected which is not there. This means that the variable last_controller_event is never filled.
The correct code line should be:
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 "" }}'

So (, ) is changed to (,) and the blank after the colon is removed.

Automation YAML config

none

To Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Trigger the automation '....'
  4. See error

Expected behavior

none

Actual Behaviour

none

Additional Details

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

Screenshots

No response

Additional context

No response

@martin3000 martin3000 added blueprint An issue related to a blueprint bug Something isn't working labels Aug 29, 2024
@tavarez992
Copy link

I can confirm this bug.
Need to replace
regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")
to
regex_match("^\{((\"a\":\".*\"|\"t\":\d+\.\d+)(,)?){2}\}$")

I tested it on ikea_e1524_e1810.yaml

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

No branches or pull requests

2 participants