Possible to use a regular light switch with a zigbee relay as a trigger for automations?

I have a regular 1 way light switch near my front door. It is wired through a zigbee no neutral relay to the hallway lights. I can control them via zigbee, or with the physical switch.

Now my idea is to use the same 1 way switch as a trigger for another automation. For example, turning the light on-off or off-on within 1 second, to trigger a "turn all the lights off at home" automation.

possible?

With Hubitat, that is of course possible. Please note the following excerpt from the events log, from one of my zigbee switches:


It's important to use the type (physical), and the exact date/time in rule machine to get at everything that you need to make your automation. It's a complicated trigger, but can be done.

3 Likes

thanks for the answer. Could you please elaborate how to create a trigger with multiple 'events'?

I'm not sure this is the best solution, but one possibility would be a trigger of a single switch flip followed by wait for statement with a relatively short timeout to exit the rule.

edit: changed 'if' to 'wait' as I had a brain fart when typing.

Edit again:
What I’m saying is e.g. this:

Trigger - switch turns on

Actions: wait for [same switch] turns on ->timeout 00:00:02
If ([same switch] is on
Then turn on all lights
Else
Exit rule

This would imply that on-off-on physical swtiching would trigger the rule to execute. You can adapt as you'd like for what you want it to do.

Thanks for clarifying. I still have some trouble getting my head around this.

It makes sense in my head, but I can't understand how I can make it to stop executing the rule with this wait for action. As I understand after the timeout it still continues executing the rule. I would need it to exit the rule on timeout, and continue executing otherwise.

Ah, very good point, yes. You would need to tweak for that for sure... let me think about this.

1 Like

Yeah, I'm struggling to figure it out now that I think about it more. Pretty sure it could be accomplished with a series of waits and ifs, but it is definitely more complex than I originally wrote.

I recall now that I definitely have wished in the past for a toggle in the "wait" functionality to auto exit instead of continuing through the actions after the timeout.

@bravenel - would it be possible to add that as an option to the wait timeout? I'm thinking of just a toggle beside the timeout that chooses the path after the timeout to either continue the actions or exit the rule.

You could try setting a variable for the switch states as they come in. You could just use an integer, and have 0 be clear, 1 will be set when "on physical received" and the variable is equal to 0, then it is set to 2 when "off physical was received" and the variable was set to 1. Then when "on physical is received" again, and the variable is now equal to 2, then do your other actions, and set the variable back to zero.

Flipping the switch to on, off, on is a three step process, so you can just keep track of what step you are on with a variable.

Normal on/off switch flips will start the sequence, so you need some sort of timeout for how long it waits for the next button. One minute would probably be fine. A rule that says one minute after ANY physical switch change, reset the variable to zero. That gives you a full minute to complete the sequence. Could even be like ten seconds to wait before resetting the sequence variable.

Edit: I'm not much of a Rule Machine user, but here is what I am talking about, done in Webcore:


2 Likes

Timeout sets %device% to "timeout" when that is how the Wait ends. So you can put %device% into a variable and test it, exit the rule if it is "timeout".

2 Likes

Hi Bruce, sorry if I'm doing something really obviously wrong here, but I wanted to play around with this and don't see that as a variable that I can actually use in my test rule.

I see it on the Rule page:
image

But then it's not there on the Actions & Conditions page (and therefore not selectable as a condition):
image

You need a String variable to put %device% into, so that you can test the value. See where it says Create New Variable.

2 Likes

Duh. Got it. Thanks.

OK yeah, I think based on Bruce's feedback, something like this would work - the logic is that if there is another 'on' event within 5 seconds I want it to turn on the other light too and if I don't turn it on again, nothing happens:

1 Like

To begin with, wiring regular on/off (mechanical?) switch serially with whatever smart relay is a very bad idea and nothing more than asking for troubles. Power to the smart switch/dimmer/light never should be interrupted by mechanical switch unless this is done for the safety reason but not for using as a secondary controller. Many smart relay modules have a terminals for connecting mechanical switch/button and using these terminals will be a right things to do. Another option will be to convert mechanical switch into smart sensor. Shelly I4 Line Powered module will do the job.
With a right electrical setup/wiring creating a good reliable RM rules will be an (relatively) easy task.

Have you tested this rule? As I see it, for this to work, the driver will have to send two of the same event in succession, i.e. On event followed by a second On event within 5 seconds. Which drivers permit that?

This was in my original proposal to him, in my mind it was implied that this was still the case:

1 Like

it is not wired serially, it is wired as it's supposed to - the switch is connected only to the relay, and relay is what's connected to the light.

1 Like

OK. Looking at you another (I guess, related) posts (double click option) my suggestion will be to change your on/off switch with momentary switch. This way many problems will be solved instantly.

1 Like

no this is not an option. I have tested many of these zigbee switches but none of them are good in my opinion. They have bad tactile feedback, look bad, etc.

But I got it to work!

I will test this solution in a bit but,

Here is a solution from another thread: