Strange task behavior
Strange task behavior
I'm having a weird problem with a sprinkler task. I want my sprinklers to come on at 9:00 am on Tue, Thurs, and Sat so I have the following task:
If ('System Time.Time Without Seconds' is Equal '9:00 am') And
If ('System Time. Day Of Week' is Equal 'Tuesday') Or
If ('System Time. Day Of Week' is Equal 'Thursday') Or
If ('System Time. Day Of Week' is Equal 'Saturday') Then
Change 'Sprinkler Timer.Running' to 'Yes'
I'm currently out of the country and my wife called frantically this morning saying that the sprinklers had been on all morning. Apparently they came on at midnight so the days portion of the task seems to be working, but not the time.
The timer is a 30 minute timer that does not repeat. This has been working for quite a while WITHOUT the days in the task - before I had it coming on everyday for a shorter time period. I just added the days to the existing task this week. I'm unsure if it ran all day on Tuesday as nobody was home all day then. I wasn't logging the device changes so I can't be sure.
I notice that if I manually stop the timer, the task will restart it even though it doesn't look like it is supposed to be running. Did I miss something in setting up the task?
Thanks,
Terry
If ('System Time.Time Without Seconds' is Equal '9:00 am') And
If ('System Time. Day Of Week' is Equal 'Tuesday') Or
If ('System Time. Day Of Week' is Equal 'Thursday') Or
If ('System Time. Day Of Week' is Equal 'Saturday') Then
Change 'Sprinkler Timer.Running' to 'Yes'
I'm currently out of the country and my wife called frantically this morning saying that the sprinklers had been on all morning. Apparently they came on at midnight so the days portion of the task seems to be working, but not the time.
The timer is a 30 minute timer that does not repeat. This has been working for quite a while WITHOUT the days in the task - before I had it coming on everyday for a shorter time period. I just added the days to the existing task this week. I'm unsure if it ran all day on Tuesday as nobody was home all day then. I wasn't logging the device changes so I can't be sure.
I notice that if I manually stop the timer, the task will restart it even though it doesn't look like it is supposed to be running. Did I miss something in setting up the task?
Thanks,
Terry
I think the problem may be that you only have SystemTime AND'd to a single day (Tuesday). For Thursday and Saturday, the OR portion becomes true at 12:00AM and stays true all day. It probably needs to look like this:
If ('System Time.Time Without Seconds' is Equal '9:00 am') And
If ('System Time. Day Of Week' is Equal 'Tuesday') Or
If ('System Time.Time Without Seconds' is Equal '9:00 am') And
If ('System Time. Day Of Week' is Equal 'Thursday') Or
If ('System Time.Time Without Seconds' is Equal '9:00 am') And
If ('System Time. Day Of Week' is Equal 'Saturday') Then
Change 'Sprinkler Timer.Running' to 'Yes'
Osler
If ('System Time.Time Without Seconds' is Equal '9:00 am') And
If ('System Time. Day Of Week' is Equal 'Tuesday') Or
If ('System Time.Time Without Seconds' is Equal '9:00 am') And
If ('System Time. Day Of Week' is Equal 'Thursday') Or
If ('System Time.Time Without Seconds' is Equal '9:00 am') And
If ('System Time. Day Of Week' is Equal 'Saturday') Then
Change 'Sprinkler Timer.Running' to 'Yes'
Osler
As an update, I just tried it and it seems to be working. Thanks for the info Osler.
I have to say that this way seems entirely counter-intuitive. A one-time specification of the time branch really should be enough. Scott, any chance of this behavior changing in a future version? If not, could you maybe explain the thinking behind this logic, it doesn't seem to be clicking with me.
Thanks again, the wife will be pleased.
Terry
I have to say that this way seems entirely counter-intuitive. A one-time specification of the time branch really should be enough. Scott, any chance of this behavior changing in a future version? If not, could you maybe explain the thinking behind this logic, it doesn't seem to be clicking with me.
Thanks again, the wife will be pleased.
Terry
Actually, I HAD assumed it wasn't nested. If it's nested it should work as is, methinks.
EDIT: I just looked at the Task help and I don't think you can nest multiple If/Then in HB. You only have If or ElseIf Blocks to work with. The following would probably work more like you expect it to.
Since Scott added the Task execute script functionality, I have moved all of my complex tasks into scripts. It gives you much more control over the logic (FWIW).
Osler
EDIT: I just looked at the Task help and I don't think you can nest multiple If/Then in HB. You only have If or ElseIf Blocks to work with. The following would probably work more like you expect it to.
Code: Select all
If Time = 9:00 AND Day <> Mon AND Day <> Wed AND Day <> Fri AND Day <> Sun Then
turn on sprinkler
Osler
I was just eating lunch and thinking about something very similar to your "negative logic" code example. I may try that when I get some time just to see if it works.
I too have most everything in scripts now. This is one that has been hanging on for a while and since it was working... Adding the day conditions didn't seem like to big of a deal, but I may look at moving this to a script too. It would help to get rid of a few timers, tasks, and devices that the whole process needs. Actually, I think I will develop a script; that will probably make it easier for the wife to change the schedule from her phone too.
Thanks again for the help,
Terry
Edit: For those that may come later with similar issues, here's a screen cap showing the indents in the original (time is 10:00 in this example) It still looks like it should work...
I too have most everything in scripts now. This is one that has been hanging on for a while and since it was working... Adding the day conditions didn't seem like to big of a deal, but I may look at moving this to a script too. It would help to get rid of a few timers, tasks, and devices that the whole process needs. Actually, I think I will develop a script; that will probably make it easier for the wife to change the schedule from her phone too.
Thanks again for the help,
Terry
Edit: For those that may come later with similar issues, here's a screen cap showing the indents in the original (time is 10:00 in this example) It still looks like it should work...
- Attachments
-
- task.PNG (3.79 KiB) Viewed 2392 times
Question Osler (and others); when you move your tasks to scripts, do you still use the timer device in HB when you need timers, or do you have your timers in the scripts too? I can't decide which is the more practical path. On one hand, having HB host timers seems the most efficient process-wise, but then I like the simplicity of having everything in the script.Osler wrote: Since Scott added the Task execute script functionality, I have moved all of my complex tasks into scripts. It gives you much more control over the logic (FWIW).
Osler
TIA,
Terry
-
- HouseBot Guru Extraordinaire
- Posts: 1121
- Joined: Tue Sep 28, 2004 7:49 am
- Location: The Netherlands
Not sure what you all mean by nested in this case, but isn't the HB logic something like below in your example;roussell wrote:It still looks like it should work...
If (Time = 0900 And Day = Tue) Or Day = Thu Or Day = Sat Then...
whereas it should be;
If Time = 0900 And (Day = Tue Or Day = Thu Or Day = Sat) Then...
HB doesn't know the braces part so Osler example should be the way to go. Obviously scripting makes everything much better readable and provides more options.
Below one of my masterpieces. It works so I didn't see a need to create a script for it. Some of the Time portion is Sunrise + X-Minutes (themed sider option) dependant. It opens the curtains at around 7 AM when sunrise is earlier than 7 AM and when sunrise is later than 7 AM + slider time, the curtains will open at that time. All depends on the alarm state as well since opening all of the curtains simultaineously will trigger the alarm. This task took a while before it functioned like it should and I guess it should be much easier to build using a script.
- Attachments
-
- naamloos.JPG (66.62 KiB) Viewed 2368 times
-
- HouseBot Guru Extraordinaire
- Posts: 1121
- Joined: Tue Sep 28, 2004 7:49 am
- Location: The Netherlands
Richard Naninck wrote:Not sure what you all mean by nested in this case, but isn't the HB logic something like below in your example;roussell wrote:It still looks like it should work...
If (Time = 0900 And Day = Tue) Or Day = Thu Or Day = Sat Then...
whereas it should be;
If Time = 0900 And (Day = Tue Or Day = Thu Or Day = Sat) Then...
HB doesn't know the brackets part so Osler example should be the way to go. Obviously scripting makes everything much better readable and provides more options.
Below one of my masterpieces. It works so I didn't see a need to create a script for it. Some of the Time portion is Sunrise + X-Minutes (themed sider option) dependant. It opens the curtains at around 7 AM when sunrise is earlier than 7 AM and when sunrise is later than 7 AM + slider time, the curtains will open at that time. All depends on the alarm state as well since opening all of the curtains simultaineously will trigger the alarm. This task took a while before it functioned like it should and I guess it should be much easier to build using a script.