Make ST Switch check light on or off before executing comand


#1

1) Give a description of the problem
ST Switch does not turn off light, if it has already been turned on by Voice assistant or IFTTT schedule.

The problem I’d like to solve is that when my Lifx Lights have been triggered by anything other than the ST buttons I have I have to press the button twice to turn off the light. Might sound like not much of an issue but when you have a tech-adverse fiance living with you “if it doesn’t do it the way it’s supposed to the first time it must be broken”, catch my drift :rofl:

2) What is the expected behaviour?
Switch is pressed, switch checks current light condition e.g is light on or off.
If light off turn on, if light on turn off

I’m relatively new to WebCore and would love if someone could help me by pointing out how I would set up these conditions. Or if its even possible to do so.

Thank you WebCore family :slight_smile:


#2

Just to clarify, it sounds like you have two devices…

A Smart Switch… and a Smart bulb…

Is this right?


I have one more question… Is the switch hard wired into your wall?

In other words, if the switch stays off, is it possible to still turn on the bulb?


#3

Hi WCmore,

Thanks for responding. I have a Samsung smart button as the smart switch yes. And my Smart light is a Lifx Bulb.

The switch is not hardwired in its one of these
My problem is if I turn on my lifx light with by any means other than the smartthings button (say google assistant) when I press the smartthings button wanting to turn off the light it doesn’t actually turn off the light.

It will turn off if I press the button a second time, and I think this may be becasue the button thinks the light is actually turned off (as that is the last known state the button would have put the light into).

I’m guessing that the reason it works on the second press is because it assumes that the first press of the button turned the device on, and therefore the new press is sending the off command.

I hope that makes sense. I feel like I said ‘press’ and ‘button’ and on and off WAY to many times in that paragraph.

Thank you


#4

If you already have a piston created, you can simply disable “Command Optimizations”. This will cause webCoRE to send the right command regardless of the current status. This setting affects all commands in this piston.

You can disable “Command Optimizations” by:

  • Editing the piston
  • Click on the “name” on line 2
  • Click the pic
  • Disable “Command Optimizations”
  • Save the popup
  • Save the piston
  • Test :grin:


#5

If you do not have a piston created yet, this should do the trick:

pic

No need to fiddle with settings on this one.


Note:

If the bulb is not reporting properly to the SmartThings hub, then this piston will fail…


#6

Thank you so much WCmore,

I just looked at my piston and my problem was that I was using ‘else if’ instead of ‘else’ which I think may have been my problem. I’ll try out your piston setup and let you know.

Thank you so much. I couldn’t be more gracious of your time.


#7

Let us know how it works, and come back to solution the post that helped the most.


#8

Welcome to the club…
We have weekly meetings and start like this…
Me - Hi my name is Ike (use your name) and I have a smarthome that my partner hates.
Group - Hi Ike…

:joy::joy::joy::rofl::rofl::rofl:


#9

OMG how god damn true!

As for the code I’m still not getting something right but I think you’ve steered me on to the right path I just need to figure out my devices.

Cheers guys


#10

Did you try importing my piston above and testing that?


If you are working with a different piston, you can click on the green camera pic and then post that image here for review.


#11

Yes I imported the above and have actually got it working thank you so much for that.

The only issue I’m running into now is that it works for a split second before turning off again.
The only way I could get it to begin working with your piston was to turn the code optimisation off, but I’m now having this other issue :frowning:

Not sure if I need to ad a end with execution to the end of the string to stop it from replaying the piston or something. Would love any insight you might have.

Cheers


#12

Please turn Logging Level to Full and post an error here (along with a green snapshot and Trace turned on)… It sounds like the button may be sending a “push” twice.


#13

12/8/2019, 8:35:35 AM +939ms
+1ms ╔Received event [212 Montague].test = 1575754535939 with a delay of 0ms
+97ms ║RunTime Analysis CS > 25ms > PS > 53ms > PE > 18ms > CE
+99ms ║Runtime (37330 bytes) successfully initialized in 53ms (v0.3.110.20191009) (97ms)
+101ms ║╔Execution stage started
+113ms ║║Cancelling condition #2’s schedules…
+114ms ║║Condition #2 evaluated false (8ms)
+116ms ║║Cancelling condition #1’s schedules…
+117ms ║║Condition group #1 evaluated false (state changed) (11ms)
+122ms ║╚Execution stage complete. (21ms)
+123ms ╚Event processed successfully (123ms)


#14

Please turn on Trace and post a fresh green snapshot…

Also, the Test button does nothing in this piston. We need to see a log from a real error.
(IE: push the ST button)


#15

12/8/2019, 8:35:35 AM +939ms
+1ms ╔Received event [212 Montague].test = 1575754535939 with a delay of 0ms
+97ms ║RunTime Analysis CS > 25ms > PS > 53ms > PE > 18ms > CE
+99ms ║Runtime (37330 bytes) successfully initialized in 53ms (v0.3.110.20191009) (97ms)
+101ms ║╔Execution stage started
+113ms ║║Cancelling condition #2’s schedules…
+114ms ║║Condition #2 evaluated false (8ms)
+116ms ║║Cancelling condition #1’s schedules…
+117ms ║║Condition group #1 evaluated false (state changed) (11ms)
+122ms ║╚Execution stage complete. (21ms)
+123ms ╚Event processed successfully (123ms)


#16

Thank you for the Trace. Now we just need to see a log after you press the ST button…


#17

Oh Sorry I thought that was the log


#18

12/8/2019, 9:44:28 AM +955ms
+1ms ╔Received event [Grayden Lamp].button = pushed with a delay of 153ms
+43ms ║RunTime Analysis CS > 11ms > PS > 23ms > PE > 9ms > CE
+45ms ║Runtime (37326 bytes) successfully initialized in 23ms (v0.3.110.20191009) (43ms)
+46ms ║╔Execution stage started
+52ms ║║Comparison (enum) pushed gets (string) pushed = true (1ms)
+53ms ║║Condition #2 evaluated true (4ms)
+54ms ║║Condition group #1 evaluated true (state did not change) (5ms)
+64ms ║║Comparison (enum) on is (string) on = true (1ms)
+65ms ║║Condition #4 evaluated true (9ms)
+66ms ║║Condition group #3 evaluated true (state did not change) (11ms)
+68ms ║║Cancelling statement #7’s schedules…
+77ms ║║Executed physical command [Bedside Lamp 1].off() (6ms)
+78ms ║║Executed [Bedside Lamp 1].off (8ms)
+80ms ║╚Execution stage complete. (34ms)
+81ms ╚Event processed successfully (81ms)
12/8/2019, 9:44:13 AM +240ms
+2ms ╔Received event [Grayden Lamp].button = pushed with a delay of 158ms
+86ms ║RunTime Analysis CS > 21ms > PS > 52ms > PE > 13ms > CE
+88ms ║Runtime (37327 bytes) successfully initialized in 52ms (v0.3.110.20191009) (86ms)
+89ms ║╔Execution stage started
+94ms ║║Comparison (enum) pushed gets (string) pushed = true (0ms)
+95ms ║║Condition #2 evaluated true (3ms)
+96ms ║║Condition group #1 evaluated true (state did not change) (4ms)
+111ms ║║Comparison (enum) on is (string) on = true (1ms)
+112ms ║║Condition #4 evaluated true (14ms)
+112ms ║║Condition group #3 evaluated true (state did not change) (15ms)
+114ms ║║Cancelling statement #7’s schedules…
+161ms ║║Executed physical command [Bedside Lamp 1].off() (43ms)
+162ms ║║Executed [Bedside Lamp 1].off (44ms)
+164ms ║╚Execution stage complete. (75ms)
+165ms ╚Event processed successfully (165ms)
12/8/2019, 9:19:15 AM +732ms
+1ms ╔Received event [Grayden Lamp].button = pushed with a delay of 167ms
+87ms ║RunTime Analysis CS > 21ms > PS > 53ms > PE > 12ms > CE
+89ms ║Runtime (37332 bytes) successfully initialized in 53ms (v0.3.110.20191009) (86ms)
+89ms ║╔Execution stage started
+95ms ║║Comparison (enum) pushed gets (string) pushed = true (0ms)
+96ms ║║Cancelling condition #2’s schedules…
+96ms ║║Condition #2 evaluated true (4ms)
+97ms ║║Cancelling condition #1’s schedules…
+98ms ║║Condition group #1 evaluated true (state changed) (6ms)
+112ms ║║Comparison (enum) on is (string) on = true (1ms)
+113ms ║║Condition #4 evaluated true (14ms)
+114ms ║║Condition group #3 evaluated true (state did not change) (15ms)
+116ms ║║Cancelling statement #7’s schedules…
+133ms ║║Executed physical command [Bedside Lamp 1].off() (12ms)
+133ms ║║Executed [Bedside Lamp 1].off (14ms)
+135ms ║╚Execution stage complete. (46ms)
+136ms ╚Event processed successfully (136ms)
12/8/2019, 8:35:35 AM +939ms
+1ms ╔Received event [212 Montague].test = 1575754535939 with a delay of 0ms
+97ms ║RunTime Analysis CS > 25ms > PS > 53ms > PE > 18ms > CE
+99ms ║Runtime (37330 bytes) successfully initialized in 53ms (v0.3.110.20191009) (97ms)
+101ms ║╔Execution stage started
+113ms ║║Cancelling condition #2’s schedules…
+114ms ║║Condition #2 evaluated false (8ms)
+116ms ║║Cancelling condition #1’s schedules…
+117ms ║║Condition group #1 evaluated false (state changed) (11ms)
+122ms ║╚Execution stage complete. (21ms)
+123ms ╚Event processed successfully (123ms)

Clear

Full


#19

Thanks for the logs…

It seems like, at all three times, White Bulb 2 was seen as “ON”, so webCoRE sent the “OFF” command…

9:19:15 AM:
║║Condition #4 evaluated true (14ms)
║║Executed physical command [Bedside Lamp 1].off()

9:44:13 AM:
║║Condition #4 evaluated true (14ms)
║║Executed physical command [Bedside Lamp 1].off()

9:44:28 AM:
║║Condition #4 evaluated true (14ms)
║║Executed physical command [Bedside Lamp 1].off()

Was there any issues with those three times?


I do not see this happening in your log…


#20

Oh sorry,

The reason it shows that is it has the same behaviour when its already turned on. So I ran it with the light on. So for instance I can turn it on with the lifx app then hit the ST button and it goes off for a split second then comes back on.

When it’s off it does it in reverse of course. But I’ll run it again with the light off so you can see the log. Thanks again for all your continued help WCmore :slight_smile: