PDA

View Full Version : Compute the time a door was open


jhendric1
Mar 19, 2010, 11:03 PM
I'm trying to compute the time a door has been left opened using the compute elements and have come up with the following:

opened = _formatTime( _now() , "$I:$M:$S" )
closed = _formatTime( _now() , "$I:$M:$S" )
totaltime = closed - opened

Looking at flags in HCA, I see the opened and closed flags update with the times. Its the subtraction I cannot get to work. Totaltime always comes up 0.

What I'm trying to accomplish is if the door has been left open too long I will have a wav file play. If I can get this to work, then I'll add a total time opened for the whole day(I'm curious). BTW the door I'm talking about is the one on the refridgerator. I already have an element to count when its opened... about 80 times a day with 4 kids.

ewelin
Mar 20, 2010, 02:23 AM
I think the problem is that you're trying to do a calculation on strings. I haven't played around with the time stuff too much, but hopefully that gives you a jolt in the right direction.

80 times a day... wow that's crazy! This is a great idea though. Curious what are you using to monitor that status of the door?

jhendric1
Mar 20, 2010, 02:38 PM
Thanks for the help. I will dig further into strings and variables. I am using a ds10a. One magnet on the freezer door and one on the fridge so if either one is opened I get a trigger. The side of the refrigerator is against a wall so thats were they are located, out of sight.

What started all of this was I had bought a new storm door for the front door and a year later, the hydraulic cylinders that keep it from slamming were wore out. I replaced them and after some thought, started counting when everyone leaves the house and comes home, kids goes out to play, come in for a drink, go back out, come back in, etc. Believe it or not, the front door opens around 20,000 times a year with summers being the worst. So then, with the refridgerator being one of the household energy hogs, I wondered how many times it was opened. So now I'm curious on how long the door was left opened.

mjl
Mar 20, 2010, 09:18 PM
For a while I monitored my refrigerator with a wireless temperature sensor inside the fridge - I mainly wanted to know when the breaker tripped, but as a side effect you could see the temperature go up whenver the door was opened. I just used the temperature sensor from my wireless weather station because it was portable and easy. Once the fridge problem was fixed, I put the temp sensor back wheere it was. This wouldn't be as precise as a door sensor, but it measures the effect it has on cooling the contents.