Timer and scheduling construct

Hi

I am a little confused still with the use of time and timer constructs within a condition. I have had some strange behavior when playing with these. Can you let me know if I have understood this right please?

Triggers:
Night - Day or night indicates night
Vswitch1on - Vswitch1 is switched on

Conditions and expected behavior:
DawnControl - Night and (05:30:00; Vswitch1on; 07:00:00) - Will be true if Night and Vswitch1 is switched on between 05:30 and 0700
NightControl - Night and (NOT 05:30:00; Vswitch1on; 07:00:00); Vswitch2on < 15 - Will be true if Night and vswitch1 is not on between 05:30 and 07:00 and if Vswitch2 is switched on for less than 15 minutes?

Cheers

NightControl - (NOT NightControl); Vswitch1on < 15

I dont think you can have the condition check itself, you will have to redo that

maybe something like NightControl - NOT (5:30:00;NOW;7:00:00); Vswitch1on < 15

Yep i dont think i have quite got the hang of this yet :slight_smile:

Thing is, even the first part doesnt seem to do what I expect. I have this:
Night and (17:00:00; Vswitch1on; 17:05:00)

I expect this to trigger if its Night, and if Vswitch1 is switched on between the times of 1700 and 1705. What actually happens is Vswitch1 does nothing, but if I flip to Night, regardless of the state of Vswitch1, it causes the action to trigger. That stops once the time window expires. What am I missing here?

This seems to be in conflict with the PLEG status:

Triggers
Name Description Last Trigger State
Vswitch1on VirtualSwitch1 is turned on 2013-09-10 17:12:46.217 false
Night Day or Night indicates Night time. 2013-09-10 17:14:17.026 true
Vswitch1off VirtualSwitch1 is turned off 2013-09-10 17:12:50.818 true
Day Day or Night indicates Day time. 2013-09-10 17:13:18.478 false
Conditions
Name Expression Last True State
Nightcontrol1 (17:00:00; Vswitch1on; 18:05:00) and Night 2013-09-10 17:14:17.032 true
Daycontrol1 Vswitch1off and Day 2013-09-10 17:13:18.489 false

How is Nightcontrol1 evaluating true, when Vswitch1on is false?

Ah… I think maybe I have it… I am expecting this to only trigger if Vswitch1 is toggled between the times after I have set this up. What its actually doing is testing the last time Vswitch1 was on, which from the times shown in status, means it evaluates true as it was switched within the window?

I think you are right. Looking at the status thats whats happening. If you only wanted it to trigger when it is currently on and in the window, you could try this:

Nightcontrol1 (17:00:00; Vswitch1on; 18:05:00) and Night AND Vswitch1on

That meand it has to be triggered in the time, and still be on, and night for it to be true

Would have to do more thinking there is most likely a easier solution to achieve the same, but i think that’ll work for now

Ok thanks. Am just playing around with virtual switches at the moment to get my head around the logic. I used to work with a guy who could write perl scripts that could achieve the same in 2 lines as it took me 20, so I guess this is the same - lots of ways to achieve a goal and trick is knowing the shortest route there :slight_smile:

Indeed. I am still in the learning stages. But with the help of the forum I have learnt a lot, but it is a constant process, and you always get stuck somewhere, and luckily I have always found help here

Note that:

(17:00:00; Vswitch1on; 18:05:00)

Can be true even if Vswitch1 is off.
That’s because this statement only tests the time at which Vswitch1 last became true.

If you always want it to be false when the switch is off you should use:
Vswitch1on AND (17:00:00; Vswitch1on; 18:05:00)

@RichardTSchaefer

I must have learnt something here as you confirmed my conclusion !! I am very pleased.

[quote=“mikee123, post:6, topic:176848”]I think you are right. Looking at the status thats whats happening. If you only wanted it to trigger when it is currently on and in the window, you could try this:

Nightcontrol1 (17:00:00; Vswitch1on; 18:05:00) and Night AND Vswitch1on

That meand it has to be triggered in the time, and still be on, and night for it to be true

Would have to do more thinking there is most likely a easier solution to achieve the same, but i think that’ll work for now[/quote]

[quote=“RichardTSchaefer, post:9, topic:176848”]Note that:

(17:00:00; Vswitch1on; 18:05:00)

Can be true even if Vswitch1 is off.
That’s because this statement only tests the time at which Vswitch1 last became true.

If you always want it to be false when the switch is off you should use:
Vswitch1on AND (17:00:00; Vswitch1on; 18:05:00)[/quote]

I am struggling a bit with understanding that. Can you explain the logic in words to me please?

Thanks

(17:00:00; Vswitch1on; 18:05:00) is true if the switch has been on in that period, but even if you have turned it off it stays true. If you want it only to be true if Vswitch1on is on during that time you say Vswitch1on AND (17:00:00; Vswitch1on; 18:05:00)
That means it has to have been on between 17:00 and 18:05 but also must STILL be on
Hope that makes sense

The following is called a sequence expression:

17:00:00; Vswitch1on; 18:05:00

It is true when the timestamps of each are in order … A timestamp is assigned when a boolean condition variable changes from false to true … or a device variable is changed.

It is only concerned with the Timestamp not the current value.

The sequence expression is one of the more complicated aspects of PLEG/PLTS but also provides a lot of the power … by providing a way to detect the order of events.

Perfect. Got it now I think, thanks both of you.

Right, I’m going to go all newbie on this. I’ve previously used scenes/triggers/etc with lots of variables holding several conditions in order to detect statuses, but it’s all way to cluttering so am giving PLEG a go for my ‘simple’ scenario:

I want to switch on the TV back light when we switch on the TV after sunset. If we switch on the TV before sunset, I want the TV back light to come on when it is sunset.
Then I just want to switch off the TV back light when we switch the TV off again. Unfortunately, because my network is crap (powerline modules) the ping sensor that determines if the TV is on or off sometimes tells me it is off, when it is still on. So I want to leave the back light on, until it has been at least 22:30. If the TV switches off after that time, I want the back light to switch off too.

I’m really struggling setting this up in PLEG, and would really appreciate some pointers on how to define this. I’m sure once you get the ‘ahaaa’ moment, it all makes sense, but for now, I can’t get my head around it.

Also, it would be great if I could have a pointer in the right direction to get ‘day part’ conditions. A condition called ‘morning’ which is true between the hours of 7:00 and 12:00, a condition called ‘day’ which is true between 12:00 and sunset, a condition called ‘evening’ which is true between sunset and 22:30 and finally a condition called ‘night’ which is true between 22:30 and 7:00. Am I correct in setting up a schedule for 7:00 every day (weekdaymorning) and then a condition as follows: (weekdaymorning;NOW;12:00) ?

You can use the new featuers in Version PLEG-5.1 and PLC-5.13

You can have timers called (or any other naming/timing convention you want):

DAY - EveryDay On at Sunrise Off at Sunset
Morning - EveryDay on at Sunrise Off at Noon
Afternoon - EveryDay on at Noon Off at Sunset

I assume noon is after Sunrise and before Sunset! Maybe a problem at the poles!

@Quinten

the ping sensor that determines if the TV is on or off

this sounds interesting, i would like to try to use that. Maybe off topic for this thread, but how do you do that ?

@Richard I think I’ve got the day periods now set up, guess we’ll have to wait till it actually goes through a couple

@mikee123 There are several ping sensors (although I still wrote my own) in the app store/forums, but basically, the TV has a network connection (smart TV), so if the TV is on, it becomes pingable, and when it is off/standby, the network connection goes down with it. Quite simple really…

Thanks for that, never seen it but will read throught the forum, and have a look in the app store. So basically i can determine if any of my devices are on or off as long as they have a ip address on my network. Very interesting. I wonder if i can somehow use that in my sq remote, would make a good addition to some of my scenes, especially for devices which only have a power toggle rather than discrete on off commands. I will look into that.