1) Give a description of the problem
I’ve searched the forums on “subscriptions” but I’m not quite clear on something. I’m sure this has been discussed elsewhere (I did see the Conditions and Triggers topic) so please forgive me, but just looking for a simple explanation of what the intent is here.
2) What is the expected behaviour?
I expect the “if” statement to evaluate an expression that returns a boolean result, and branch accordingly. In this particular case, I expect that
if Backyard East Light's switch is off
compiles to something like
if ( getStatusOfDevice("Backyard East Light", "switch") == "off"
) { … }
else { … }
3) What is happening/not happening?
WC creates a subscription for the Backyard East Light switch (switch 2 in the snapshot). While it doesn’t hurt anything, it seems completely pointless and illogical. The piston is only interested in the state of the switch at the instant the if statement’s condition is evaluated. If I wanted to do something based on an event from the light switch, I would have added it in the on events from section.
I’m coming at this from the perspective of a C++/C# programmer, which is probably part of the problem. I realize I can override the auto behavior and turn off that subscription, but why is it created in the first place?
**4) Post a Green Snapshot of the piston![image|45x37]
5) Attach logs after turning logging level to Full
1/9/2020, 12:43:49 PM +194ms
+12ms ╔Subscribing to devices…
+15ms ║Using Attribute subscription
+72ms ║Device missing from piston. Loading all from parent (56ms)
+77ms ║Subscribing to Backyard Lights Button.pushed…
+85ms ║Subscribing to Backyard East Light.switch…
+92ms ║Piston controls Back Yard Camera…
+107ms ╚Finished subscribing (98ms)
+121ms ║Comparison (enum) off is (string) off = true (1ms)
+123ms ║Cancelling condition #4’s schedules…
+124ms ║Cancelling condition #3’s schedules…
+133ms ╔Starting piston… (v0.3.110.20201015_HE)
+134ms ╚Piston successfully started (127ms)