Morning wake up Fade and mode setting

conditions
timer

#1

1) Give a description of the problem
it doesn’t always evaluate correctly and won’t trigger, I move the conditions around and sometimes they then work for that one but then not the others.

2) What is the expected behavior?
if the weekend or we are on holiday use the holiday time to trigger but if not on holiday and its a weekday use the work time. Then trigger a fade piston (best to do this as had issues with long fades all in the same piston as the rest), wate for this piston to complete and restore the music then set the mode to home.

3) What is happening/not happening?
its not triggering sometimes even when it should.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
will update this when i have some again, but last time I checked all the logs were correct but evaluating wrong
|+1ms|╔Received event [Home].time = 1514720881287 with a delay of -1052ms| |---|---| |+134ms|║RunTime Analysis CS > 20ms > PS > 65ms > PE > 48ms > CE| |+137ms|║Runtime (57224 bytes) successfully initialized in 65ms (v0.2.101.20171227) (134ms)| |+137ms|║╔Execution stage started| |+265ms|║║Comparison (boolean) true is (boolean) true = true (2ms)| |+266ms|║║Condition #54 evaluated true (115ms)| |+277ms|║║Comparison (boolean) true is (boolean) true = true (1ms)| |+279ms|║║Condition #90 evaluated true (11ms)| |+280ms|║║Condition group #28 evaluated true (state did not change) (128ms)| |+819ms|║║Executed physical command [Master Bedroom SONOS].playTextAndResume([Get up lazy bones and do some work!, 40]) (529ms)| |+820ms|║║Executed [Master Bedroom SONOS].playTextAndResume (530ms)| |+823ms|║╚Execution stage complete. (686ms)| |+825ms|║Setting up scheduled job for Mon, Jan 1 2018 @ 7:30:00 AM GMT (in 70918.94s), with 4 more jobs pending| |+1011ms|╚Event processed successfully (1011ms)|

this time after i got it to run the it didn’t run the routine


#2

I’ve been in your shoes before… What I found was that trying to evaluate changing restrictions on a Timer produced inconsistent results. To me it seemed like the Timer would execute every time if the restriction WAS true when it was evaluated (say like 24 hours ago), instead of evaluating it to see if it IS true.

That makes a big difference…because you might turn on your Holiday switch in the middle of the day, but the restriction was already evaluated…so it just goes ahead and runs that day disregarding the switch.

So…what I did to get around all of that was to create a Trigger Piston which only had the Timers and the Conditions in it… Then I evaluate everything in that trigger piston and execute the Wakeup piston if everything was true (when the timer went off).

So something like this:

Every day at (some time you set)
If Holiday is off and Presence is Home
then
Execute Wake up piston

Doing it that way got it working for me.


#3

Oh, and you can build a separate Timer for just the weekends a bit easier this way too. Just duplicate the Weekday one and set it to only run on Sat and Sun… The routine you call stays the same…but the timer changes.

I never had any issue with the “only on” certain days of the week part of a timer.


#4

Lastly… Fades work like Waits…

So if you tell a light to Fade up over X minutes, it’s going to essentially hold the piston at that command for the duration of the fade. So you can either account for this in your piston (know that it will wait there for X minutes) or you can run that command as an Async. Personally I chose to build in the delay of the fade into the script. But YMMV on that one…so test and deploy accordingly.


#5

Yeah that’s what I had before and the fade held up the piston correctly but when I started to also include the speakers conditions that’s when it became to much for it. So I now have the fade in a seperate piston of 30 mins then have to pause the main piston as the fade only works like a wait in its own piston. Although you can select the option to wait until the other piston completes that only counts for its task’s. So as soon as it’s triggers are done it moves on even though it’s still fading, hence why I had to put in the wait to the main piston.

I’ll give your ideas ago, I think your right with

Think I found the same.

Think I understand what you were saying so I will have to create 2 more pistons one for

If time is X (work day) (Monday to Friday)

Then only when presence is true and holiday is off trigger piston.

Then another ( or another asynk if should work?)
If time is Y (weekend) Saturday, Sunday

Then only when presence is true trigger piston.

Then another

If time is Y (Monday to Friday)

Then only when presence is true and holiday is on trigger piston.

Essentially braking down the groups to basic IF’s?

@webCoRE_Minions is this a bug then, or were we doing it wrong?

Edit: async didn’t work i had to but the timers in there own piston, still trying with 2 in one at the moment with hopefully using else but dont think it will work.


#6

@Mike1616 may have worked out a way to do it in one


#7

this is correct. once the timer is setup for execution it does not get reevaluated till that timer run happens.

to work around this add an empty on event block at the top of the piston:

on events from
   @Holiday
do
end on

#8

so this?

to do this

and this is the fade

I’m still having issues with the piston not fully firing when it does though it seems to be the same issue with a 30 min wait.


#9

I don’t think you need to put in the Event block for the Holiday switch as we’re circumventing the issue with the Timer the way we’re setting this up. You would need that Event block if we weren’t splitting things up though.

I’m not sure what you mean by “not fully firing”. Do you mean that the piston does not start when the Timer event happens? Or do you mean that you main routine is not completing?

What’s the issue with the 30 minute wait? Is it not happening?

Here’s my suggestion on the Trigger piston. This is essentially what you’re doing…but a little more streamlined. I’m just curious about the 30 minute wait time though. As long as there’s no issue there then this should do the trick. Also this is what I meant by duplicating things for the weekend. You can have more than one timer in the same piston. It will just execute the commands when that particular section becomes true.


#10

So if the trigger piston evaluates true it fires the main piston (ideally I wanted them all in the same piston but if it works as it is that’s a start). This then runs and fires the fade pistion, but I want the fade to complete before it moves on its 30mins. As it doesn’t wait for waits in other pistons, I then have to put a wait in the main so input in 30mins. Now this works as well as the stuff above it. But when the piston resumes it only fires the speaker message then stops. So the routine doesn’t fire (previously I had change mode to home then change security to disamed, but thought triggering a routine with that in would reduce the pressure on WebCoRE and it would work but it didn’t) and then the last bit doesn’t eather. But it says it has completed as if it did.


#11

I can understand why you had to put the Fades into their own piston for the lights that you’re changing. Because you’re fading two different things (level and temperature) you have to run them as Async in order for them to happen at the same time…otherwise I"m sure the level would change for 30 minutes and then the temperature would change for another 30 minutes. Not exactly the effect you’re going for. So…Async for that makes perfect sense…but Async also means that it would not work in the main piston as it would never wait for the fade to finish, and would just start doing the next commands.

However, why are you using Async for the speaker parts? Do you really want all of them evaluating at the same time, only one will ever be true…

Also, if the main piston is starting but it is not completing then you’re likely going to need to turn on full logging and investigate where it’s stopping. Personally I also like to put in Debug commands into the Log just so I know if a particular section I’m evaluating is working.

I still think the trigger piston needs to be changed a bit in order to clean up the main piston a bit more…I’ll see if I can work on that and post an example a bit later.

One more thing… What is “Switch 2” in your piston?


#12

When I had it in the main piston only the 1st was async which ment that it waited for the 2nd to finish before it moves on. The reason there both async now is because I tried to put a wait in after to see if it would hold up the main piston, but just haven’t changed it back.

No they don’t need to be, again it was a attempt by me to try and get the bottom bit to run. But doesn’t seem to make any difference.

I have done full logging and what I said above is what happens. It acts as if it’s running completely but just skips the last bit, but not tried the debugging in the position? How do you do that?

Switch 2 is my master routine switch if it’s off it stops evething from running.


#13

here’s this mornings logs showing it just not doing it.

02/01/2018, 07:59:59 +105ms
+0ms ╔Received event [Home].time = 1514880000369 with a delay of -1265ms
+268ms ║RunTime Analysis CS > 25ms > PS > 206ms > PE > 37ms > CE
+270ms ║Runtime (53273 bytes) successfully initialized in 206ms (v0.2.101.20171227) (269ms)
+271ms ║╔Execution stage started
+398ms ║║Comparison (boolean) true is (boolean) true = true (2ms)
+399ms ║║Condition #54 evaluated true (118ms)
+410ms ║║Comparison (boolean) true is (boolean) true = true (1ms)
+411ms ║║Condition #90 evaluated true (11ms)
+412ms ║║Condition group #28 evaluated true (state did not change) (132ms)
+413ms ║║Cancelling statement #28’s schedules…
+901ms ║║Executed physical command [Master Bedroom SONOS].playTextAndRestore([Get up lazy bones and do some work!, 50]) (474ms)
+901ms ║║Executed [Master Bedroom SONOS].playTextAndRestore (475ms)
+903ms ║╚Execution stage complete. (632ms)
+1036ms ╚Event processed successfully (1036ms)
02/01/2018, 07:29:59 +269ms
+0ms ╔Received event [Home].execute = :08429ca7a6790229fded5cff1a1c4551: with a delay of 0ms
+115ms ║RunTime Analysis CS > 20ms > PS > 54ms > PE > 40ms > CE
+118ms ║Runtime (53291 bytes) successfully initialized in 54ms (v0.2.101.20171227) (116ms)
+118ms ║╔Execution stage started
+128ms ║║Comparison (enum) on is (string) on = true (2ms)
+129ms ║║Condition #12 evaluated true (7ms)
+130ms ║║Condition group #null evaluated true (state did not change) (8ms)
+136ms ║║Comparison (string) :964d0cd483c8df461f20eef29b039dab: is_not (string) :7d38143ce28f077111de1773d2583cdb: = true (2ms)
+137ms ║║Condition #92 evaluated true (5ms)
+138ms ║║Condition group #48 evaluated true (state did not change) (6ms)
+139ms ║║Cancelling statement #48’s schedules…
+1038ms ║║Executed virtual command executePiston (894ms)
+1061ms ║║Executed virtual command setVariable (5ms)
+1094ms ║║Executed virtual command setVariable (7ms)
+1098ms ║║Executed virtual command wait (1ms)
+1100ms ║║Requesting a wake up for Tue, Jan 2 2018 @ 8:00:00 AM GMT (in 1800.0s)
+1124ms ║╚Execution stage complete. (1006ms)
+1127ms ║Setting up scheduled job for Tue, Jan 2 2018 @ 8:00:00 AM GMT (in 1799.974s)
+1145ms ╚Event processed successfully (1144ms)

and here is the traced piston


#14

I’m just talking about writing your own lines of text into the Log. I find it helpful to see where the piston is for trying to troubleshoot problems. So I’ve just added several lines like below (they are in the “Location” section.

image

So when I’m writing a piston I just have it tack in stuff like that so I can see where it got to and what the values of the variables might be as it’s going along. There’s also a way to trace a piston, but i’m not as familiar with that in webCoRE.


#15

I’ve been using the trace (its at the bottom of the piston next to copy to clipboard) but the button only appears once it has ran. It’s great to see what’s happening and what evaluated correctly. that’s how I worked out what was happening but cant work out why :frowning: . If you look at the piston above it has the trace on and the blue line going down the side, shows it ran fully (but it didn’t).

image

I’ll give this a go see if it helps :smile:


#16

I tweaked it a bit on your recommendations and just ran a test and it worked :slight_smile: just got to see if it runs tomorrow now :slight_smile: . Then on to the next problem with the speaker not restoring to the previous state.

02/01/2018, 16:55:48 +300ms
+0ms ╔Received event [Home].time = 1514912149585 with a delay of -1285ms
+119ms ║RunTime Analysis CS > 21ms > PS > 57ms > PE > 41ms > CE
+122ms ║Runtime (52388 bytes) successfully initialized in 57ms (v0.2.101.20171227) (121ms)
+123ms ║╔Execution stage started
+149ms ║║Cancelling statement #70’s schedules…
+188ms ║║Executed physical command [Master Bedroom SONOS].setLevel([25]) (33ms)
+189ms ║║Executed [Master Bedroom SONOS].setLevel (34ms)
+213ms ║║Executed physical command [Master Bedroom SONOS].setTrack({“station”:“Best of Coldplay”,“name”:null,“artist”:null,“album”:null,“trackNumber”:“4”,“status”:“playing”,“level”:"",“uri”:“x-rincon-cpcontainer:0006206ccatalog%2fplaylists%2fB017NL22FE%2f%23prime_playlist”,“trackUri”:“x-sonosapi-hls-static:catalog%2ftracks%2fB00KHPBQQ0%2f%3fplaylistAsin%3dB0721N4DFP%26playlistType%3dprimePlaylist?sid=201&flags=0&sn=4”,“transportUri”:"",“enqueuedUri”:“x-rincon-cpcontainer:0006206ccatalog%2fplaylists%2fB017NL22FE%2f%23prime_playlist”,“metaData”:"<DIDL-Lite xmlns:dc=“http://purl.org/dc/elements/1.1/” xmlns:upnp=“urn:schemas-upnp-org:metadata-1-0/upnp/” xmlns:r=“urn:schemas-rinconnetworks-com:metadata-1-0/” xmlns=“urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/”><item id=“0006206ccatalog%2fplaylists%2fB017NL22FE%2f%23prime_playlist” parentID=“00082064catalog%2fplaylists%2f%23prime_playlists” restricted=“true”>dc:titleBest of Coldplay<\u002fdc:title>upnp:classobject.container.playlistContainer<\u002fupnp:cl…[TRUNCATED]
+214ms ║║Executed [Master Bedroom SONOS].setTrack (22ms)
+237ms ║║Executed physical command [Master Bedroom SONOS].play() (22ms)
+238ms ║║Executed [Master Bedroom SONOS].play (23ms)
+240ms ║╚Execution stage complete. (118ms)
+241ms ╚Event processed successfully (241ms)
02/01/2018, 16:55:39 +179ms
+1ms ╔Received event [Home].time = 1514912140727 with a delay of -1548ms
+142ms ║RunTime Analysis CS > 31ms > PS > 66ms > PE > 46ms > CE
+145ms ║Runtime (52388 bytes) successfully initialized in 66ms (v0.2.101.20171227) (143ms)
+146ms ║╔Execution stage started
+399ms ║║Executed virtual command executeRoutine (227ms)
+404ms ║║Executed virtual command wait (0ms)
+405ms ║║Requesting a wake up for Tue, Jan 2 2018 @ 4:55:49 PM GMT (in 10.0s)
+410ms ║╚Execution stage complete. (265ms)
+411ms ║Setting up scheduled job for Tue, Jan 2 2018 @ 4:55:49 PM GMT (in 9.995s)
+418ms ╚Event processed successfully (418ms)
02/01/2018, 16:55:29 +146ms
+1ms ╔Received event [Home].time = 1514912130933 with a delay of -1787ms
+119ms ║RunTime Analysis CS > 23ms > PS > 60ms > PE > 35ms > CE
+121ms ║Runtime (52287 bytes) successfully initialized in 60ms (v0.2.101.20171227) (120ms)
+122ms ║╔Execution stage started
+265ms ║║Comparison (boolean) true is (boolean) true = true (2ms)
+267ms ║║Condition #54 evaluated true (132ms)
+287ms ║║Comparison (boolean) false is (boolean) true = false (1ms)
+288ms ║║Condition #90 evaluated false (21ms)
+289ms ║║Condition group #28 evaluated false (state did not change) (156ms)
+299ms ║║Comparison (boolean) true is (boolean) false = false (2ms)
+300ms ║║Condition #61 evaluated false (9ms)
+301ms ║║Condition group #55 evaluated false (state did not change) (10ms)
+312ms ║║Comparison (boolean) false is (boolean) false = true (2ms)
+313ms ║║Condition #68 evaluated true (9ms)
+322ms ║║Comparison (boolean) true is (boolean) true = true (1ms)
+323ms ║║Condition #80 evaluated true (9ms)
+324ms ║║Condition group #62 evaluated true (state did not change) (20ms)
+325ms ║║Cancelling statement #62’s schedules…
+1572ms ║║Executed physical command [Master Bedroom SONOS].playTextAndRestore([Morning, its going to be a great day, now get up lazy bum!, 50]) (1236ms)
+1573ms ║║Executed [Master Bedroom SONOS].playTextAndRestore (1238ms)
+1576ms ║║Cancelling statement #32’s schedules…
+1580ms ║║Executed virtual command wait (0ms)
+1581ms ║║Requesting a wake up for Tue, Jan 2 2018 @ 4:55:40 PM GMT (in 10.0s)
+1585ms ║╚Execution stage complete. (1463ms)
+1587ms ║Setting up scheduled job for Tue, Jan 2 2018 @ 4:55:40 PM GMT (in 9.995s)
+1754ms ╚Event processed successfully (1754ms)
02/01/2018, 16:25:29 +672ms
+1ms ╔Received event [Home].test = 1514910329672 with a delay of 0ms
+127ms ║RunTime Analysis CS > 16ms > PS > 66ms > PE > 44ms > CE
+130ms ║Runtime (52283 bytes) successfully initialized in 66ms (v0.2.101.20171227) (127ms)
+131ms ║╔Execution stage started
+142ms ║║Comparison (enum) on is (string) on = true (2ms)
+143ms ║║Condition #12 evaluated true (8ms)
+144ms ║║Condition group #null evaluated true (state did not change) (10ms)
+147ms ║║Cancelling statement #48’s schedules…
+1228ms ║║Executed virtual command executePiston (1072ms)
+1244ms ║║Executed virtual command setVariable (7ms)
+1253ms ║║Executed virtual command setVariable (3ms)
+1259ms ║║Executed virtual command wait (2ms)
+1260ms ║║Requesting a wake up for Tue, Jan 2 2018 @ 4:55:30 PM GMT (in 1800.0s)
+1264ms ║╚Execution stage complete. (1134ms)
+1265ms ║Setting up scheduled job for Tue, Jan 2 2018 @ 4:55:30 PM GMT (in 1799.996s)
+1271ms ╚Event processed successfully (1271ms)


#17

how can set to loading holidays or how to create holidays for my country?


#18

sorry don’t understand your question?


#19

how can set the christmas for example as holidays?
is already somewhere as holidays that i can add it as a code or i must ad somewhere 25/12/17 is holiday and 31/12/17 and 1/1/18 is holliday too

and every other unique holliday for my country


#20

i just have a virtual switch that i turn on or off when im on holiday. But if you have the same holidays every year, you could have a piston set a variable to true or false depending on the dates?

on these days set variable to true else false