#light.toggle stops working for Area target if any light in Area is unavailable

1 messages · Page 1 of 1 (latest)

feral badger
#

I have created a basic automation with one action:

action: light.toggle
metadata: {}
target:
area_id: bedroom
data: {}

When I run this action, the lights will turn on successfully. However, when I run it again (attempting to turn all the lights OFF), none of the lights turn off if there are any devices are are disconnected or unavailable. I had temporarily unplugged a lamp and was confused why my light remote was no longer working.

I can make my own toggle and run light.turn_off and light.turn_on, but I couldn't figure out a way to straightforwardly check the light on/off state for an Area. I could do it by picking some or all of the lights and checking them manually, but that won't dynamically update when I add lights to the room.

Is there a trick here? How can I robustly toggle my dang lights without making it a custom mess?

vapid finch
#

Tbh I would use on/off anyway because an area toggle can get confused if some lights are on and others are off, which you might have for many reasons
You can do this dynamically with a template. Use area entities and filter out everything that isn't a light and available - then check if any of them are on, if so - turn them off, otherwise turn everything on. (or vice versa)
You probably want to also add a trigger for when a light becomes available it checks what state it should be in.
You could also just use a light group, but it's a little less dynamic requires like 3 extra clicks when you add a new bulb

feral badger
#

I've always preferred the toggle and then a long-press to turn force all the lights off to fix them. I've got some crappy cheap wifi bulbs that sometimes need an extra push to turn off anyways.

I'm not familiar with area entities. Are you talking about making a custom entity group for all my lights in that room? Or is there something else I can use?

#

Honestly if you could explain what you mean by this, I would appreciate it.

"You can do this dynamically with a template. Use area entities and filter out everything that isn't a light and available"

vapid finch
feral badger
#

oh shit

#

this will probably fix all my problems lol

#

Had no idea this existed

vapid finch
#

I'm not at home so can't easily show you what it would look like, but if you've done some template stuff it should be a good start 🙂

feral badger
#

I think I can figure it out

vapid finch
#

If you get stuck ask, I'll be home in a couple of hours