Change status of switch component from API?

Hi,

So, I have a somewhat trivial but slightly annoying problem with Homeassistant which I feel should be fixable somehow.

I have a switchbot that operates my hall light, but this light is a 2-way light (3-way in American parlance I think I heard). I.e. it can be operated by separate wall switches from both ends of the hall.

It is fine if I am triggering the switchbot from the Homeassistant web UI.

However, because of the multiple physical switches, Homeassistant does not know what state the light is currently in, on or off.

And I have integrated this with Alexa voice commands, so I sometimes have to say “Alexa, hall light off” to make the light go on. Because if I’ve said “Alexa, hall light on” it just gets ignored, because Homeassistant thinks the light is on.

I’ve thought of maybe an ESPHome or a Pi Pico mounted in the light fitting with an LDR sending back the current actual state of the light to Homeassistant, but I have no experience with the Homeassistant API, so don’t know if it’s even possible to override the state of a switch.

Can anyone help with this?

I can’t believe I’m the first person to encounter this problem, but anything I’ve tried to Google has not returned the exact situation I’m in.

Can you say “Alexa toggle the hall light”?

Your switchbot should expose a switch entity. If you have a light entity, did you create that with a helper?

If the simple solution from Tom isn’t sufficient, then you would want to delete your helper light and create a template light. The state of that template light can be set by whatever information you’ve made available to your HA instance, such as a Zigbee light (lux) sensor, a smart bulb in that fixture and its status of available/unavailable, etc.

Alternatively, just remove your switchbot and the switch it is attached to, and replace it with a smart switch.

I did wonder about this, but Alexa doesn’t seem to know what I mean by ‘toggle’

In any case, it would be better for Homeassistant to know the current state, because I want to have a routine for “TV mode” which switches my living room, dining room and hall lights off IF they are on. Toggle here wouldn’t work

Switchbot was my last resort.

The hall light is dimmable, and when trying a SONOFF MINIR4M in the ceiling rose, I could remotely switch the light on and off, but the dimming function was disabled.

When I put this hall light in, it was far too bright, so I made one of the wall switches a dimmer switch - so I don’t want to be without the dimming capability.