No longer works with Hue remotes since 2012.12.0b0
ianfretwell opened this issue · 6 comments
Apparently there are changes to the events/devices due to the move to the Hue API v2 that are introduced with the 2021.12 builds.
As per :- https://github.com/home-assistant/core/pull/58996
Currently this renders event-sensor unusable as it no longer seems to see the devices.
Are there any plans to support this going forward please?
This does not directly answer your question about the future of this component, but I was able to eliminate my use of it by changing my remote button automations to use event triggers. To find out the details of the event, I went to Developer Tools -> Events and entered "hue_event" and clicked "Start Listening". Then I pushed the button on my hue remote and see:
The important properties are highlighted.
I changed my automation from:
- alias: Remote - Living room dimmer
trigger:
- platform: state
entity_id:
- sensor.hue_livingroom_remote
action:
- service: scene.turn_on
data_template:
entity_id: >
{% set theSwitch = trigger.entity_id %}
{% if is_state(theSwitch, "1_click_up") %}
scene.living_room_high
{% elif is_state(theSwitch, "2_click_up") %}
scene.living_room_medium
{% elif is_state(theSwitch, "3_click_up") %}
scene.living_room_low
{% elif is_state(theSwitch, "4_click_up") %}
scene.living_room_no_light
{% endif %}
To:
- alias: Remote - Living room dimmer
mode: restart
trigger:
- platform: event
event_type: "hue_event"
event_data:
id: hue_livingroom_remote_button
type: initial_press
- platform: event
event_type: "hue_event"
event_data:
id: hue_livingroom_remote_button
type: short_release
action:
- service: scene.turn_on
data:
entity_id: >
{% set theButton = trigger.event.data.subtype %}
{% if theButton == 1 %}
scene.living_room_high
{% elif theButton == 2 %}
scene.living_room_medium
{% elif theButton == 3 %}
scene.living_room_low
{% else %}
scene.living_room_no_light
{% endif %}
Note, during my testing I found that if I clicked different buttons very quickly, sometimes it did not send a "initial_press" event, only a "short_release", so I just added an additional trigger for that.
@azogue any word on this? Isn’t working with the latest version of HA
For a core alternative see https://community.home-assistant.io/t/trigger-template-based-on-hue-switches-needs-event-time-fired/364084/3?u=mariusthvdb
How would the automations look for this?
depending on your wishes you can trigger own the state change of any of those trigger based template sensors, seems as straightforward as can be
I fixed it by enabling sensor state compositions from multiple event data keys, using comma-separated syntax to define multiple keys. So, for the typical Hue Dimmer Switch, which with v2 produces events like this:
{
"event_type": "hue_event",
"data": {
"id": "interruptor_dormitorio_button",
"device_id": "e2759d6e89fb4ff08a02aaaaaaaaaaaa",
"unique_id": "5d280803-eeec-4f71-b80b-aaaaaaaaaaaa",
"type": "initial_press",
"subtype": 4
},
"origin": "LOCAL",
"time_fired": "2021-12-19T09:59:46.138968+00:00",
"context": {
"id": "04e971ec1a6b534a062dc4c596035788",
"parent_id": null,
"user_id": null
}
}
Using type,subtype
as the 'event field' will compose a sensor state initial_press-4
, which can be mapped again to the old predefined states (or to any custom ones).
For the dimmer switch, the new state mapping would be initial_press-1: 1_click, initial_press-2: 2_click, initial_press-3: 3_click, initial_press-4: 4_click, repeat-1: 1_hold, repeat-2: 2_hold, repeat-3: 3_hold, repeat-4: 4_hold, short_release-1: 1_click_up, short_release-2: 2_click_up, short_release-3: 3_click_up, short_release-4: 4_click_up, long_release-1: 1_hold_up, long_release-2: 2_hold_up, long_release-3: 3_hold_up, long_release-4: 4_hold_up
.
Sadly 😢, as the event sensor is a generic integration, not a Hue-specific one, and Hue bridges with v1 API are currently supported and working in HA Core, there is no easy solution for the current sensors defined for the old v1 Hue API, so they would have to be edited or removed and created again 😤
Take into account that the "id" property has changed too, adding the "_button" suffix (not sure if device_id
and unique_id
have changed too)
For new sensors, the wizard now has new presets:
- "Hue Dimmer Switch (Hue v2)"
- "Hue Smart Button (Hue v2)"
I don't have any more kinds of devices connected to the Hue bridge (I'm using deCONZ for most of my ZigBee network), so I don't know how other remotes work now with the new API, so if anyone could provide that kind of info 🥺🙏