Hue motion sensors + remotes: custom component


#426

The component just relays the info from the hub, so short of hacking the component the best approach is just to ignore the click state


#427

The problem with the “for: seconds: 1” condition is that the automation gets triggered before 1 second passes, so the condition never allows the automation to run.

I ended up using a workaround which consists of 3 parts:

  1. An input_boolean to be used as a trigger for my actions.
  2. An automation that is triggered when a button is clicked on the hue switch, it waits 1 second and then turns on the input boolean.
  3. An automation that is triggered when the input boolean is turned on, checks which button was pressed, and performs the action.

This way I get both click and hold for all buttons.
I might even go further and make a click counter, enabling me to have different actions for second, third, and fourth clicks… but I’m satisfied for now :slight_smile:

Thank you so much for your work!


#428

Good you got it working. Strange the original way wasn’t working, was working when I testet it before I wrote the post. I am not using the function at the moment, so could be that it is not realiable enough. An alternative way could be to just set 1 sec delay under action, and then just check the state under a condition there instead. If you set the update interval to 1,5 or 2 seconds, you don’t need the condition at all, since then it’s not register the click-function before the hold-function. But that would cause slower automation from you press the button, which kind of sucks.

So, if you just set a 1 sec delay first at the action part, you can implement like this post or with a service_template, and just add function for 1_hold, 2_hold and so on.


#429

Thanks for the help, will try that :slight_smile:

EDIT: Come to think of it… a delay in the action is not good enough, because that would mean the automation would be triggered twice for doing the hold action.
The first trigger would be the 1_click event, and the second trigger would be the 1_hold event. The action for both would still be the same of course because of the service_template in the action, but the action for the hold event would still be fired twice.

I believe that my solution with input_boolean eliminates that problem, because even when there are multiple trigger events for one hold event, they would only trigger one action, because input_boolean could only change it’s state to on once.
When the action is done, it resets the state of the input_boolean to off, and then you are ready to process more events if the hue switch is clicked again.


#430

Yes, didn’t think of that. Your solution is definitely a better solution then. Thanks! Use the input boolean as the trigger, and a service template or data template as action would be the best way to go I think :slight_smile:


#431

just thought to let you Hue’rs know the new mdi:light-switch nicely matches the Hue remote switch :wink:

06

Cheers,
Marius


#432

@Mariusthvdb mdi:light-switch does not return an icon for me (0.71), is extra config required?


#433

no not that i am aware of. This is what i have:

lights_panel:
  name: Lights
  view: true
  icon: mdi:light-switch
  entities:
    - sensor.lamps_badge
    - group.lights_tiles

47


#434

@robmarkcole: Just for my understanding, when exactly are the attributes of the sensors updated?

I observed that the light level of a motion sensor does not update instantly (after lights were switched off), but a few minutes later… The sensor state itself does of course update at once (i. e. as soon as motion is detected)

Thanks,
Tim


#435

HI Tim
the data for the sensor is updated every scan_interval. However it may be that the attributes are only updated when there is a state change of the sensor (I’m not sure TBH, but this would be true for every sensor, not just these). One way to check would be to create a rest sensor for the light level and compare with a template sensor on the attribute. Or you could pose the question on the dev chat


#436

@robmarkcole any plans to turn this into an official component? Would be awsome!


#437

Yes, but no promises when.!


#438

How do I convert last motion from UTC to localtime?


#439

Hi @robmarkcole,

It seems that it is a Hue specific behaviour, see here

The sensor data is only updated every 5 minutes or when it changes significantly, i. e. lightlevel changes by 2000 or more, temperature changes by 0.2 degrees or more.

Makes sense in order to save battery of the motion sensor…


#440

Agreed, it’s an approach to conserve battery life. I’ve literally never replaced the batteries in my sensors, and that’s over a year


#441

Hi!
I am using my Hue remote to change different radio channels on my Sonos speaker. I have 4_click to turn it off, But everytime i restart Hassio remote sensor changes to 1_click. Is it possible to fix this so the sensor keeps 4_click when it restarts?

Using Hassio 0.71


#442

Suggest an automation


#443

This is great stuff. If you want to get this mainlined you should probably take a look at aiohue, which is used by the official hue component.


#444

@robmarkcole Just a heads up that I finally got around to finishing up adding Hue sensor support to aiohue, it was merged today. So now it’s your turn to make this component official :slight_smile: .


#445

Thanks! Just need to learn asyncio first :slight_smile: