The Time value in HouseBot

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
PRIME
Member
Posts: 29
Joined: Tue Sep 23, 2003 11:00 pm

The Time value in HouseBot

Post by PRIME »

Hi Scott, I guess you'll be the only one able to answer this question.

My question is, how does the "Greater Than" and the "Less Than" logic in a condition work with system time? Is the logic decided based on AM/PM or on 24-hour time format? In either case, how does it work?

I hope my questions make sense :?:



Thanks in advance,

- John
=====================

Trust is good but control is better...
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

John,



HouseBot stores all times in a format that is neither 24/hour or 12/ampm. It is simply the number of seconds since 1970 (a common way that computers store time). So when you need to compare times, it is a simple operation that is independent of the time format that is displayed. Greater or LessThan work the same for comparing times as any other numeric value.



Scott
PRIME
Member
Posts: 29
Joined: Tue Sep 23, 2003 11:00 pm

Post by PRIME »

Hi Scott,



Sorry, I'm not sure I understand it quite yet.

Let's assume a hypothetical senerio.

Let's say I have a task (we'll keep it simple) that tests for current time as follows:



If (system.time>7:00AM) AND

(system.time<2:00PM) THEN

execute something

Else

execute something else



If indeed the system time is converted to number of seconds, how does this task decide the conditions if it is enabled?

Since this is really a daily task (because every single day has a 7:00AM and a 2:00PM in it), how often is the number of seconds calculated?



I'm not sure if I'm getting my question across, but I hope I am :D



Thanks,

- John
=====================

Trust is good but control is better...
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

John,



Your question gets at the heart of the Task management system and how Task conditions are evaluated. I'll give you the basic rule for how this works and then how it applies to your example.



A Task is evaluated whenever any of the Property Values in it's condition list changes.



In your example, the first set of actions ("execute something") would execute every second (since that's how often the SystemTime.Time Property Value changes) between 7:00:01am and 1:59:59pm. And for every OTHER second (from 2:00pm till 7:00am) the second set of actions ("execute something else") would execute. This is probably not what you want to happen.



The primary reason that I made the Time Without Seconds Property in the System Time Device was for condition testing like this. If you use the Time Without Seconds Property in your example, the same things happen, but only every minute (instead of every second). This is a little better use of the system CPU.



Generally the the type of time checking that you have in your example is also combined with another condition statement such as AND Motion Detector.PowerState Is On. In this case, the Task will be evaluated every minute and also when the Motion Detector changes, but will only execute its task list when all three conditions are met.



In my setup, I have two different Tasks that do things around SunSet. One task simply tests the SystemTime.Sunrise Indicator for 0 and turns some outside lights on. The other one (for the inside lights) uses a condition to turn things on 1/2 hour BEFORE sunset. To do this, setup a condition to test the SystemTime.TimeAndDate Property. For the 'Value' set it to SUNSET_DATE_AND_TIME - Days=0, Hours=00, Minutes=30, Seconds=00. You can do any type of variations on this as well.



Hope I hit the answer to your questions somewhere in here.

Scott
PRIME
Member
Posts: 29
Joined: Tue Sep 23, 2003 11:00 pm

Post by PRIME »

Thanks Scott, it does answer my question.

So then by using the "=" in a time conditon, it is only executed once per day. For instance



If (system.time=2:00PM)Then

execute actionA



In the above task, action A gets executed once a day. Is this correct?





Also, just to clarify your last paragraph for me, by setting SUNSET_DATE_AND_TIME to 30 mintues, we are telling the system that sunset is now 30 minutes away: Perform some actions. Did I understand correctly?



Thanks,

- John
=====================

Trust is good but control is better...
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

PRIME wrote:If (system.time=2:00PM)Then
This would only be executed once a day. However, it would be better to use SystemTime.TimeWithoutSeconds for the comparison instead of Time.



If you look closely at the 'value' that uses "SUNSET_DATE_AND_TIME", you'll notice that it subtracts (note the minus sign) 30 minutes from the current sunset time. It doesn't actually change the sunset time.



Scott
PRIME
Member
Posts: 29
Joined: Tue Sep 23, 2003 11:00 pm

Post by PRIME »

Ah I see. Sorry, I didn't look closely enough at it. I should have seen that :oops: Wow, pretty engeneous. Great job once again Scott. Just love the software. If you ever decide to market it, you can count me in for sure :D It seems to be able to do everything that I have searched for.



Thanks again for all your patience and explanations,

- John
=====================

Trust is good but control is better...
PRIME
Member
Posts: 29
Joined: Tue Sep 23, 2003 11:00 pm

Post by PRIME »

Hi Scott, just one more question: :D


If you look closely at the 'value' that uses "SUNSET_DATE_AND_TIME", you'll notice that it subtracts (note the minus sign) 30 minutes from the current sunset time. It doesn't actually change the sunset time.


By the same token, can I use the "+" to perform stuff at a specified time AFTER sunset? And I imagine this method can be used with the "SUNRISE_DATE_AND_TIME" as well?



Thanks,

- John
=====================

Trust is good but control is better...
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

PRIME wrote:By the same token, can I use the "+" to perform stuff at a specified time AFTER sunset? And I imagine this method can be used with the "SUNRISE_DATE_AND_TIME" as well?
You got it :!:



Scott
Post Reply