This object is in archive! 

Adding hours, minutes and/or seconds to a time?

Henrik Andersson shared this question 7 years ago
Need Answer

Hi,

I want to check whether an event occurs within, lets say, 30 minutes of another event e.g. the sunset. I have successfully been able to "filter out" the time of the sunset via the virtual weather station. How can I add 30 minutes to that time to be able to compare it to the current time? The +-operator does not seem to be working with times.


/Henrik

Best Answer
photo

Henrik,

Unfortunately, Zipato stuff doesn't have any support for time and date outside of the schedulers. The variables cannot hold numbers large enough to work with UnixTime or similar, even if you were to retrieve the values from external sources.

A workaround would be to work with *minute* counter variables, and to have a rule scheduled to run every minute to increment that variable. This way, you only add 1880 per day, and can fairly easily device a way to reset and start over if you hit the maximum number allowed.

By having a global variable holding the minute count, you can access this in your other rules and thus check if x minutes have lapsed since whenever...

Replies (5)

photo
1

I think I have it working. I wanted to have a rule activate a light between one hour before sunset and one hour after sunrise. I created to variables for that that get populated in a scheduled rule.

photo
1

use the astro offset in the scheduler, +30. This will trigger teh scheduler 30 minutes after sunset. Then you can compare this to the time now.

photo
1

Hi Adrian,

I have the astro offset part figured out. It is how to compare two times that I have trouble with... I did get an answer from Zipato support and their take on it was to split the times up in hour, minute and second parts and then compare these individually. This will most likely work even though it seems like a tedious way of building rules...

photo
photo
1

Henrik,

Unfortunately, Zipato stuff doesn't have any support for time and date outside of the schedulers. The variables cannot hold numbers large enough to work with UnixTime or similar, even if you were to retrieve the values from external sources.

A workaround would be to work with *minute* counter variables, and to have a rule scheduled to run every minute to increment that variable. This way, you only add 1880 per day, and can fairly easily device a way to reset and start over if you hit the maximum number allowed.

By having a global variable holding the minute count, you can access this in your other rules and thus check if x minutes have lapsed since whenever...

photo
2

That is a really good idea Robert! Thanks. I think I'll try it out. Also, lets hope that Zipato adds building blocks in the rules creator to be able to work with time and date variables in a more efficient way. Their recommendation now is to split the times up in hour, minute and second parts and then compare these individually...

photo
photo
1

Robert, I was trying to get in touch with you. I remember you mentioned you use Life360 and successfully integrated it to zipabox to track locations. what "between"service are you using to connect life360 with the virtual sensor?

photo
1

Attila, I'll start a new thread on this so it's searchable

photo
Leave a Comment
 
Attach a file