This is driving me mad. If I walk into the room this sensor is "detecting", nothing happens. The (new to me) green 'yeah, that's right' lights come up in the automation on my phone, but nothing happens.
The only thing that triggers this automation is the state of binary_sensor.hobeian_zg_204zm_occupancy... are you sure that is working correctly? There are a number of older threads about this device not working properly.
Second, you have 2 very similar entity ID's your automation binary_sensor.hobeian_zg_204zm_occupancy and binary_sensor.hobeian_zg_204zm are those both valid and are they being used in the right places?
Yep, well done. The missing _occupancy was definitely what I wasn't able to see and looks like it was causing the issue, so thanks for seeing that.
I think I might need to find a better trigger to turn the light back off though. If you leave the room and the occupancy clears (which it does see, the state definitely changes in HA) it doesn't turn the light off again in time, and is (I think) waiting for a trigger that won't occur.
I do something similar for presence in certain rooms of the house but base it off of “wasp-in-the-box” logic. I use a timer helper. Anything that should indicate presence in the room, including presence and/or motion sensors or a device like a fan or media_player states, etc. are used as triggers and each trigger gets an ID. Then, I use choose action, I use triggered by ID conditions with actions that turn on the timer and the lights.
The key is to loop back and reset the timer, so there’s choose blocks with conditions that evaluate the current states of my sensors and devices which will reset the timer. The timer is set relatively short, between 3 to 5 seconds typically, except for my bathrooms which I set to 15 minutes.
When the timer does run out and no conditions are met, the lights go off.
Appreciate the insight, that might be above my skill level tbh.
Ultimately, this is just to turn on a light in a very dark tv room - perhaps I should just get it to turn on for a period of time. Once you sit down turn on the amp, it'll turn the light off anyway as part of that device's automation - the thinking is that by then you're not tripping over stuff.
Check the automation's debug traces for a time that happened and see which condition of the Choose isn't passing. Once we know that, we can figure out the changes that are needed.