Elapsed time

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
Timoh
Advanced Member
Posts: 260
Joined: Thu Feb 02, 2006 12:56 pm
Location: Montreal - Canada

Elapsed time

Post by Timoh »

How do I calculate elapsed time?

I'm writing %%System Time.TimeAndDate%% to a User Time property called "HVAC.AC Run".
Then a few minutes later I'm trying to perform
%%System Time.TimeAndDate%%-%%HVAC.AC Run%% and sending it to a User TimeSpan property.

Obviously it's not working and I'm getting th error...
Unable to parse default time span value ["Year=2008, Month=01, Day=22, Hour=20, Minute=42, Second=41"-"Hour=00, Minute=00"]

Thanks
Tim
yaccri
HouseBot Special Member
Posts: 304
Joined: Wed May 07, 2003 2:19 pm
Location: Tel-Aviv, Israel
Contact:

Post by yaccri »

If what you are trying to do is to set a device after some time, you can use a sleep timer and a related task.
Timoh
Advanced Member
Posts: 260
Joined: Thu Feb 02, 2006 12:56 pm
Location: Montreal - Canada

Post by Timoh »

No... I'm trying to calculate how long a device has been running. Or how long a property had the same value before it changed
Tim
Timoh
Advanced Member
Posts: 260
Joined: Thu Feb 02, 2006 12:56 pm
Location: Montreal - Canada

Post by Timoh »

Anyone? Scott?

How do a calculate how long a property has had the same value?

i.e. Property Values...
Fan (boolean)
Fan Run Time (Time and Date)
Fan Elapsed (Timespan)

When Fan changes from 0 to 1, I write the system time to the Fan Run Time property.

When Fan changes back to 0, I need to know who long it was set to 1.
I'm trying "System Time"-"Fan Run Time" using PV and in a script and can't get it to work, nor can I think of another way to do it without parsing out the time string completely in a script.

Tim
spike5884
Senior Member
Posts: 129
Joined: Thu Aug 26, 2004 8:08 am
Location: WI

Post by spike5884 »

Check DateDiff function in VBScript

Here is a sample that shows the duration in minutes:

Code: Select all

StartTime = GetPropertyValue( "TestTimeScript.StartTime" )
CurrentTime = GetPropertyValue( "System Time.TimeAndDate" )

MsgBox DateDiff("n",StartTime,CurrentTime)
TestTimeScript.StartTime is a Time property set to handle Time and Date.
Thanks,
Scott J
aka spike5884
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Post by Richard Naninck »

It's too bad we don't have a simple epoch date available. Meaning amount of seconds from a baseline like 01-01-1978 or so until now. That always gives a single value in seconds and it is very easy to calculate time differences in seconds of of it.

I am with Spike. Have a task put your start time in a property and use a different property for end time. Once end time gets set, trigger a script that calculates the difference using DateDiff. That way you can be sure all remains fine even when the fan is turned on just before midnight and turned off just after midnight. It might be possible using stuff you wrote in your first post, but I haven't used that much so I couldn't tell you why or what goes wrong.

If you have a running script doing your fan control for you, you might even run all of these variables internally in the script without having to create tasks and properties to trigger and store these values.
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

I think a script is your best option too. It would be nice if a timespan could be initialized with the result of the difference/subtraction of two date properties... but it doesn't work that way now. Nice feature request though.
Scott
Post Reply