I am using Hue lights with HA that I discovered and setup today. After tinkering with the automation aspect of HA I came across an immediate problem.
So my first automation is to turn a light off, if it is turned on during the day. This works when I turn the light on from HA, but if the light comes on from ANY other source, the automation does not work at all. Furthermore, when the task runs and I can see the light turn off in front of me, the light switch in HA stays ON and doesn’t update to OFF state. For testing purposes, it’s set to after dark, as it’s after dark here right now!
# Turn off lights when everybody leaves the house
- alias: 'Rule 2 - Away Mode'
trigger:
platform: state
entity_id: light.entrance
to: 'on'
condition:
condition: state
entity_id: sun.sun
state: 'below_horizon'
action:
service: light.turn_off
entity_id: light.entrance
“If you overwrite a state via the states dev tool or the API, it will not impact the actual device. If the device state is being polled, it will overwrite the state in the state machine the next polling.”
This is how my hue light is turned on at sunset:
First I created a group with my lights I want to control outside.
Edit: I just reread the original post. Ok… Under trigger, have you added the
from: ‘off’
Also, make sure that your rooms and lights in philips hue are different. (I add the word area to all my rooms). this will avoid which toggle I’m looking at in Home Assistant.
My home assistant updates the hue light status regardless of how it is turned on. Sorry if I couldn’t help after all.
Scott
Thanks for replying to my post, I appreciate it. Have you tried adding an offset to your sunset trigger or do you find the weather service you use is quite accurate?
I did try adding the “from: off” like you suggested to no avail and I don’t quite understand what you mean by making sure that rooms and lights are different than phillips hue.
Mine will still not update correctly. I wonder if there’s a way to change the polling time.
Edit: Wow, so I did a cleanup of my hue bridge which I found as a solution to a similar problem by googling around and while that didn’t make things amazing, I can definitely see a light toggled on or off by another device… after about a minute. There’s a lot of UI lag in between. Is this common? How do I address this?
Edit2: scan_interval: 10 seemed to help, is there any downside to this? is there a way to update it automatically, faster?
I just started with the philips hue two weeks ago. I use the philips hue phone app to add my lights and name them. In the app you can name the rooms and name the lights. I kept getting confused because HA adds both the rooms and the lights. So I had to add “area” to the room names. I also found it easier to put
light:
platform: hue
host: 192.168.***.***
in my config rather than relying on the auto-discovery. Probably my imagination, but I haven’t experienced that much lag.
Oh, as for sunset/sunrise… I had to add elevation to make it more accurate. Seems to be perfect for my outside lights. I think I found my elevation in google maps?..
sun:
elevation: 177
For my inside lights, I found a hour and a half offset before sundown works the best for me.
In your automation, you turn off the light, I was curious if you could also set the state to off as an action… I have yet to see an example of this yet.
Scott
State of the “Switch” in HA you mean? I haven’t seen that done either.
I found some nifty things… so apparently you can poll Hue every 2 seconds and the bridge doesn’t mess up, atleast that’s what I’ve read from other people experiencing issues with the same thing.