I’ve been buying the Thirdreality smart plugs, which are great. But what they don’t seem to have is the ability to distinguish being activated by button press vs. being activated remotely. I’d like the ability to treat those two cases differently: for instance, if a user turns the module on personally, it might override timeouts set up by a motion detection automation.
So first: can anyone recommend a different module, that can do what I want?
But actually, occurs to me that HA should be able to tell the difference, without help from the module. If HA sent a command to the module, and it changed state, then clearly that was a result of remote activation. But if the module changes state and HA wasn’t involved, then it must have been a person. Can HA do this, currently? Am I missing something?
Hello pgf,
Perhaps think about the automation differently.
Sounds like you have an automation that turns on the plug.
Another automation should be looking at when the plug turns on to enable things like motion, not when the button is pushed to turn it on. Then any time the plug turns on it will react to the motion sequence.
Splitting out a manual vs auto turning on of a device, where technically possible, is a more advanced action and likely unnecessary.
I have lights over my workbench that come on, via motion, when I pass through the hallway (where the sensor is, and must remain) to get to the shop. They stay on for an hour, which most of the time is far too much – I enter, get something, and leave. But sometimes I actually work at the workbench, and if I’m still there in an hour, the light goes out. At that point I can either walk back to the hallway, to buy another hour, or reach over and turn the light back on with the button on the module. It will come on, but will soon turn off again because of motion inactivity. I’ve tried using the “module-turned-on” event to make things work, that event also happens when motion turns the light on in the first place, and things quickly got very confusing.
The sensors creates a sensor with 4 states : physical, dashboard_ui, automation, unknown
Physical : someone turned the light on manually
dashboard_ui : someone turned the light on from the dashboard
automation : the light was turned on by an automation (motion sensor)
unknown : should not happen, but you need to have a final if
So in my light turn of on no occupancy, I have this condition
condition:
- condition: state
entity_id: sensor.keuken_licht_on_context
state: 'automation'
So the light does not turn of if someone used the switch manually. (never use the dashboard to switch lights)
If all you need is to have lights on or off with timer based on if motion is detected in a room and you have a door then add in a door sensor and use this blueprint to set your thresholds:
I use this with a motion sensor in my bathroom and the sensor on the door so that whilst there is motion detected the light stays on and after 5min of no motion the light is turned off.
Clever. Unfortunately, no door. I could obviously solve my problem with another motion sensor near the workbench. But since there are still some manually controlled lights, and I almost always turn them on, reaching over and pushing the button on the zigbee module for the workbench light isn’t a big deal. It’s just getting my automations to understand what’s happened that’s the tricky part.
Since I don’t have a door to my bedroom between my lounge room and it, this is the solution I have done to have manual control of the bedroom lamps via the streamdeck when I need it and let the motion sensor toggle them when I am walking through.
I’ve had more time to look at your solution, and I understand it now. Well done. I guess the state: “automation” condition remains the same until the next time the light switch is switched to “on”, and then it’s recomputed?