While doesn't get to the do despite conditions being met


#1

1) Give a description of the problem
The DO portion of the while statement never does. It works if I set it to test.
I also do not understand why it kicks out and then schedules the next execution at 7pm.
I’m new to this, so I’m sure this is a layer 8 problem.

2) What is the expected behavior?
Between 6am and 7pm play some mp3s randomly throughout the day

3) What is happening/not happening?
Does not enter the do portion of the while statement, even though the conditions are met

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)


#2

Update. It enters the do if I toggle the heronAuto switch from on to off then back to on.


#3

Try updating the piston so the trigger is the switch being on or the status of the sonos is the top trigger and use time as a condition.

Triggers are the ones indicated by the orange lightning bolt.


#4

Thank you for the suggestion. I did that with the same result. The logs show the conditions are evaluated to true, but then stops at the do statement. If I then flip the button to off and then on, it works as expected. I used the smart lighting app to turn the switch on at sunrise and off at sunset. It’s not the prettiest solution, but I think that will get the job done.


#5

Your lines 29, 32, and 34 are all vague conditions… and since you have no triggers in this piston, then all of your conditions become triggers. (the lightning bolts in the left margin)

The way I usually try to code is to decide on a precise trigger to execute the piston, and then place vague conditions beneath that to decide what path to take afterwards.

IE:

If HeronAuto's switch changes to on   <-- Trigger
Then
    IF Time is between X & Y          <-- Condition
    Then Set level & Play track
    END IF
END IF

If HeronAuto's switch changes to off  <-- Trigger
Then
    Stop music
END IF