this post was submitted on 17 Dec 2025
15 points (100.0% liked)

homeassistant

17154 readers
27 users here now

Home Assistant is open source home automation that puts local control and privacy first.
Powered by a worldwide community of tinkerers and DIY enthusiasts.

Home Assistant can be self-installed on ProxMox, Raspberry Pi, or even purchased pre-installed: Home Assistant: Installation

Discussion of Home-Assistant adjacent topics is absolutely fine, within reason.
If you're not sure, DM @GreatAlbatross@feddit.uk

founded 2 years ago
MODERATORS
 

I have a button that triggers a script for bedtime to turn off all lights, and, if pressed again, checks to see if all lights are off and if so, turns a few (like the bathroom light) on.

My problem is one or two of the lights (connected via Zigbee2Mqtt) are often powered off at the switch on the lamp, meaning HA still sees them as "on" until the power is restored and they can be turned "off" via the app. The lights cannot be turned "off" (in HA) manually.

Is there any good solution for detecting when a light goes missing and turning it "off" in HA?

top 14 comments
sorted by: hot top controversial new old
[–] passenger@sopuli.xyz 6 points 19 hours ago* (last edited 19 hours ago) (1 children)

The right answer: enable the online/offline detection in zigbee2mqtt. I forget the name of the setting though (edit: it's called availability). This might increase power consumption on some battery devices. You can then check if devices are available in your scripts and ignore their state if not.

It has a delay until offline state is detected, the delay can be tweaked as far as I know, but is a tradeoff with battery powered devices consumption.

[–] Kirk@startrek.website 1 points 50 minutes ago (1 children)

Helpful! Thank you I will look into it.

[–] passenger@sopuli.xyz 1 points 10 minutes ago* (last edited 9 minutes ago)

To add, I found some old Philips switches might have reacted badly to this, because they drained battery super fast afterwards. Like a month or two. I switched them all to cheap Ikea switches which work as usual and drain very slowly. All working nicely and I can make toggle buttons work like you described even if some lights are cut off from power.

But yeah there might be problems with certain devices and drain.

[–] just_another_person@lemmy.world 6 points 20 hours ago (1 children)

You don't. If they don't have power, they drop from the network or mesh.

This is why they make "Smart" Switches, which is probably more why you want instead of individual bulbs maybe.

[–] Kirk@startrek.website 4 points 20 hours ago* (last edited 20 hours ago) (1 children)

If they don’t have power, they drop from the network or mesh.

That's the problem, they don't drop, the entity remains in a zombie state. Is there really no way to test if a device is still connected or not?

EDIT: Or just manually set an entity to "off"?

[–] just_another_person@lemmy.world 5 points 19 hours ago

You can decrease the timeout of the devices to maybe get them to show as offline faster. Thread about it here.

[–] CompactFlax@discuss.tchncs.de 3 points 20 hours ago* (last edited 20 hours ago)

If they’re powered off they should be listed as unavailable/unknown.

[–] thehatfox@lemmy.world 1 points 19 hours ago (2 children)

Disable or remove the lamp switches. Add more smart buttons if there is a need for a physical control near the lamp.

As it happens I’m actually looking for a smart lamp switch if anyone knows of any options.

[–] solidgrue@lemmy.world 2 points 17 hours ago* (last edited 17 hours ago) (1 children)

As it happens I’m actually looking for a smart lamp switch if anyone knows of any options

I was doing the same myself earlier this year. I'd found a European product that was an inline smart switch, like one of those rocker switches they put on the wire for those decorative canister uplights. The switches were out of stock on all the sites that listed it, and the manufacturer website didn't seem to indicate they'd be producing more any time soon.

Eventually I just settled on using an inexpensive smart button (Tuya TS0041/TZ300 over ZHA) to control a smart bulb or a smart plug on the "dumb" fixtures. It wasn't exactly what I wanted, but nobody seems to make a smart inline switch anymore. As a bonus, the switch supports double-tap and long press gestures so I was able to program the bedside button with a few functions to toggle the bedside lamp on a short press, and turn off all the lights in the house on a double tap.

It uses a coin battery that lasts a few months. I think I've changed it maybe once since I got it.

[–] thehatfox@lemmy.world 2 points 15 hours ago

So far the only inline option I’ve found is this dimmable switch from Samotech. I haven’t tried one yet myself, and there’s mixed reviews online. For the lamps I have I only want an on-off switch though, not a dimmer.

Making due with plugging them into smart plugs for now, but an inline option would be much neater.

[–] passenger@sopuli.xyz 2 points 19 hours ago* (last edited 19 hours ago) (1 children)

They should just enable offline/online detection (edit: the z2m setting is called availability)

[–] thehatfox@lemmy.world 1 points 18 hours ago (1 children)

I’d say it’s always best to avoid Zigbee devices going offline, its neither convenient for automation or good for the mesh for devices to keep dropping.

[–] passenger@sopuli.xyz 2 points 18 hours ago

This might be true for the majority of cases, but it really depends on your mesh network, what devices drop and your needs. It works perfectly in my case.

[–] Lyra_Lycan@lemmy.blahaj.zone 1 points 20 hours ago* (last edited 20 hours ago)

I would instead remove the lights from the button script's condition. If it checks for the "All Lights" group, you can remove those lamps from the group.