EPMatt / awesome-ha-blueprints

A curated collection of automation blueprints for Home Assistant.
https://epmatt.github.io/awesome-ha-blueprints
GNU General Public License v3.0
862 stars 254 forks source link

Bug - Philips Hue Dimmer V2 - Double Press not recognized #576

Open TTvanWillegen opened 1 year ago

TTvanWillegen commented 1 year ago

Blueprint name

EPMatt/awesome-ha-blueprints/blob/main/blueprints/controllers/philips_929002398602/philips_929002398602.yaml#L389

Home Assistant Core Version

2023.11.2

Home Assistant Installation Type

Home Assistant Operating System

Description

Hi there,

I have just re-paired all my zigbee devices via Z2M using a sonoff controller as they failed recently. However, now that it almost all works, the double press doesn't.

I've been able to trace this back to a mismatch in the regex used in the calculation of the trigger_delta and the value stored in the last_action helper fields.

The regex currently is as follows: Line 389

^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$ while the helper field doesn' t contain whitespace: {"a":"off_press_release","t":1699726460.746302}

A matching regex (for me) is as follows: ^\{((\"a\": \".*\"|\"t\":\d+\.\d+)(,)?){2}\}$ This regex removes the whitespace after the semicolon in the t part as well as after the separating comma in the center.

Automation YAML config

For use in Home Assistant's Developer tools:

{%set helper_last_controller_event = 'input_text.last_hue_dimmer_switch_action' %}

{{states(helper_last_controller_event) | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")}}
{{states(helper_last_controller_event) | regex_match("^\{((\"a\":\".*\"|\"t\":\d+\.\d+)(,)?){2}\}$")}}

To Reproduce

For use in Home Assistant's Developer tools:

{%set helper_last_controller_event = 'input_text.last_hue_dimmer_switch_action' %} <- change the input to match yours.

{{states(helper_last_controller_event) | regex_match("^\{((\"a\": \".*\"|\"t\": \d+\.\d+)(, )?){2}\}$")}} <- old regex
{{states(helper_last_controller_event) | regex_match("^\{((\"a\":\".*\"|\"t\":\d+\.\d+)(,)?){2}\}$")}} <- new regex

Expected behavior

The hue switch to emulate a double press event.

Actual Behaviour

Not triggering the double press path due to a mismatching Regex.

Additional Details

Screenshots

No response

Additional context

No response

hjone72 commented 12 months ago

Life saver! Had just been trying to solve this issue. I isolated it down to the delta variable and then found your open issue here.

acid115 commented 11 months ago

If you use deconz, then you have no double quoted value for the "a"-key. a":2002,"t":1702413771.806498

So the right one is: regex_match("^\{((\"a\":[\"]?.*[\"]?|\"t\":\d+\.\d+)(,)?){2}\}$")

Or better: regex_match("^\{((\"a\":(\".*\"|\d+)|\"t\":\d+\.\d+)(,)?){2}\}$")

RassK commented 9 months ago

Seems exactly the same issue with IKEA E2001.