Piston Opening curtain with Sunrise (not meant to happen)


#1

1) Give a description of the problem
I have a piston that is ment to close a curtain anytime a media device changed status to play between Sunrise and Sunset. But it seems to be running with sunrise and I have no idea why?

2) What is the expected behaviour?
Curtain should only open if I play media between sunrise and sunset.

3) What is happening/not happening?
Curtain is opening every sunrise

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
25/12/2020, 05:42:59 +76ms +0ms ╔Received event [Home].time = 1608835380000 with a delay of -924ms +50ms ║RunTime Analysis CS > 24ms > PS > 6ms > PE > 20ms > CE +52ms ║Runtime (38101 bytes) successfully initialized in 6ms (v0.3.110.20191009) (51ms) +53ms ║╔Execution stage started +87ms ║║Comparison (time) 20579134 is_between (datetime) 1608835380000 .. (datetime) 1608887280000 = true (5ms) +88ms ║║Time restriction check passed +89ms ║║Cancelling condition #2's schedules... +90ms ║║Condition #2 evaluated true (32ms) +91ms ║║Cancelling statement #2's schedules... +97ms ║║Requesting time schedule wake up at Fri, Dec 25 2020 @ 8:08:00 PM AEDT +112ms ║║Comparison (string) is (string) playing = false (1ms) +114ms ║║Comparison (string) stopped is (string) playing = false (1ms) +115ms ║║Condition #3 evaluated false (16ms) +116ms ║║Condition group #1 evaluated false (state did not change) (59ms) +128ms ║║Comparison (string) is (string) stopped = false (1ms) +130ms ║║Comparison (string) stopped is (string) stopped = true (1ms) +132ms ║║Condition #5 evaluated true (13ms) +133ms ║║Condition group #4 evaluated true (state did not change) (14ms) +135ms ║║Cancelling statement #6's schedules... +161ms ║║Executed physical command [Bedroom Curtain].open() (22ms) +162ms ║║Executed [Bedroom Curtain].open (23ms) +165ms ║╚Execution stage complete. (112ms) +166ms ║Setting up scheduled job for Fri, Dec 25 2020 @ 8:08:00 PM AEDT (in 51900.758s) +173ms ╚Event processed successfully (173ms)


#2

Two things.

  1. Just use sunrise and sunset (or $sunrise and $sunset). The piston knows what you mean.

  2. You haven’t defined any explicit triggers, only implied by your choice of conditions that the period between sunrise and sunset and the Music Player status are of interest. So the piston runs at sunrise, sunset and when the status changes to pick up all the changes to those conditions.

If you use ‘changes to’ rather than ‘is’ for the status comparisons they will be considered as triggers and the piston, by default, will only run on those status changes. I think that is what you want but I may be wrong.

When you use ‘changes’ triggers it is important they get evaluated when the event they are interested in occurs. So you would restructure the piston as:

If ... status changes ..
   And time is between sunrise and sunset
Then
    ...
Endif
If ... status changes ...
Then
    ...
Endif

#3

Thanks mate,

Really appreciate that!

I’ve made the changes and ill see if it opens in the morning :slight_smile:


#4

Just going through old posts and forgot to reply to this,

This worked, thanks so much for that :slight_smile: