Hue motion sensors + remotes: custom component

Sorry about post in wrong thread, reposted here: Hue lights show 'On' when in fact unreachable

Wrong thread

I didn’t plan to compare it, I started my home setup with Apple Homekit.
in one room, I had a simple setup that opens the light when motion is detected (Hue sensor).
This automation never had delay opening the light when motion was detected.

Then I discovered HA :slight_smile:
I started configuring it and bit by bit using HA to replace what HK was doing.
When I saw your component, I finally was able to do the automation using HA but I got this bigger delay so I was wondering if it was normal…

My lights turn on immediately using this custom component. I’m using nodered for the automations, though

1 Like

I think hue pushes updates to Home Kit, HA needs to poll the bridge so it isn’t as responsive.

Hi, does this works only with hue sensors, or does it also works with other sensors? Do you need to have the custom ui for this to work?

I’m sorry, what does that mean?

Here is my automations for it (takes 3-5 sec to trigger the light)
I’m far from an expert here… it triggers the light when Hue motion sensor is ON, sends notification and closes the light after 5m the motion sensor is off…
If there is a better way, please share, thanks…

> - action:
>   - data:
>       message: Mouvement dans établi!!!
>       title: Home Assistant
>     service: notify.pushover
>   - data:
>       message: Mouvement dans établi!!!
>       title: Home Assistant
>     service: notify.email_sylvain
>   - data:
>       entity_id: switch.switch_etabli
>     service: homeassistant.turn_on
>   alias: Mouvement établi
>   condition: []
>   id: '1523883421908'
>   trigger:
>   - entity_id: sensor.capteur_motion_etabli
>     from: 'off'
>     platform: state
>     to: 'on'
>     
> - alias: Lumières établi OFF après 5 minutes sans mouvement
>   trigger:
>     platform: state
>     entity_id: sensor.capteur_motion_etabli
>     to: 'off'
>     for:
>       minutes: 5
>   action:
>     service: homeassistant.turn_off
>     entity_id: switch.switch_etabli

ok, I feel stupid, I answered my own question by posting the automation… it sends the pushover notification and email before it triggers the light…
I removed the first two actions and it’s much better now…

Haha! I’m definitely using that icon_template code in my setup. Love it!

:grinning::+1:t3:

Is it normal the last_updated attribute on the Hue remote doesn’t change?
It detects the click changes but the last updated doesn’t change.

Based on suggestions here, my automations use it as trigger…

@sfnetwork you are the first to report that, please follow the debugging instructions.
Cheers

ok, I think I got it to work (I updated to latest version of the component and include the API key in sensor instead of in the “hue.py”)

Now the last updated attribute changes but it seems to be showing UTC instead of EST for the time. (HA is set to EST)
Not a big deal, just curious. It doesn’t affect anything since I just need this to change when I click on the dimmer remote…

1 Like

Hello,

I have detected some WARNINGS like these since I installed your custom component on hassio:

WARNING (MainThread) [homeassistant.components.sensor] Updating hue sensor took longer than the scheduled update interval 0:00:00.100000

I have also detected the device tracker component marks the hue bridge as “away” very often. (is the component overloading the hue bridge)

How can I get rid of these warnings? Is there a recommended scan_interval to modify?

Thanks!

Hi this has come up before, changing scan_interval is the solution

Ok, changed scan_interval in hue.py to 0.5 seconds. Is this a good value?

Should be fine

Hey guys @robmarkcole @Zepixir, I have a really weird behavior with my hue switches, could you help?

I have 2 hue switches.
When you hold a button on the first hue switch, '1_hold' state is updated directly.
But when you hold a button on the second hue switch, '1_click' is updated and then '1_hold' is updated.

I literally read the entire 417 comments thread, and I can’t get it to work :slight_smile:
The '1_hold' automation works great, but the short click doesn’t work as expected.

I added a 1 second delay to the automation as @Zepixir suggested, but now it works only on the second short click. The first short click gets completely ignored.
It is almost like the trigger is triggered, but the automation fails on the 1 second condition.

Here is my code:

Automation:

- alias: Bedroom Sync Hue Remote to Switch On
  initial_state: True
  trigger:
    - platform: state
      entity_id: sensor.bedroom_hue_remote_trigger
  condition:
    condition: state
    entity_id: sensor.bedroom_hue_remote
    state: '1_click'
    for:
      seconds: 1
  action:
    - service: homeassistant.turn_on
      entity_id: group.wall_lights

Last updated template sensor:

- platform: template
  sensors:
    bedroom_hue_remote_trigger:
      value_template: '{% if states.sensor.bedroom_hue_remote %}
        {{ states.sensor.bedroom_hue_remote.last_updated }}
      {% else %}
        n/a
      {% endif %}'

Do you have any ideas?

EDIT: Changing the SCAN_INTERVAL value to 1 second doesn’t work.

What default scan interval are you using? The component polls the hub periodically, so it’s possible that your scan interval isn’t fast enough.

Otherwise all remotes should function the same - have you check the remote functions as expected with the Hue app?

I’m using the default 0.1 scan interval.

At some point the remote started working as expected all of the sudden (did not show click events before hold), so I checked the other remote again (which was previously working correctly) and all of the sudden it showed 1_click before the 1_hold.

Now both remotes show a “click” state before the “hold” event. I suspect that it depends on the time the custom component “syncs” with the API.
Is there any way to avoid the click event from the python script?

The workaround of “for: seconds: 1” should work, but for some reason it doesn’t for me… :confused: