Smart Switch with 1 Button to control lights


#1

Trying to create my first piston.

Using Xiaomi Smart Button. (1 Button)

Simply looking to use it as a light switch so if the button is pressed and lights are off it switches lights on, else it turns lights off.

Please help as piston never evaluates the first condition and goes straight to the “else” every time


#2

The main problem is you’re using $status instead of switch. ($status I believe just indicates if the hub is talking to the device - i.e., “on line.”) The switch attribute is what you’re looking for.

Below is a slightly different approach, but I think if you change $status to switch, and select the on option (as opposed to the string value ‘on’), then what you have should work.


#3

Even easier… The feature you’re after is built-in.


#5

I thought of Toggle, too, but I don’t think that’s what he wants. It’s possible that only one of the two lights are on when he pushes the button. In that case he wants the one that is on to go off, but doesn’t want the one that is off to go on. At least, that’s how I understood his requirements.


#6

OK… I see what you’re saying. I read the word “lights” and noticed in the piston that he’s using AND to affect both of them.

Regardless…if he’s using the button and his piston to control them then they’ll very soon be in sync.


#7

Appreciate that guys. I went with the toggle approach and seems to do the trick for this application…i will be playing with your solution @pnbruckner for another part of the house where this is needed.

Many thanks to all.
After enabling parallelism I have a very cheap and easy wireless light switch.