Very long timer?

I’m writing some rules to set my house in vacation mode. My first thought was to set a timer to vhen i’m expecting to return home, but obviously this can be several days into the future. Is this to long for a timer? Can it cause some unwanted sideeffects, like locking up resources until the timer has finished?

My current code (somewhat truncated):

rule "Vacation mode"
		Item Vacation_EndDate received update
		val nullValue = new DateTimeItem("bogus").state
		if (Vacation_EndDate.state != nullValue) {			
			val DateTime endDate = new DateTime((Vacation_EndDate.state as DateTimeType).calendar.timeInMillis)
			if (endDate.millis > now.millis) {			
				vacationTimer = createTimer(endDate, [|
			} else {

Should I instead make another rule that checks periodically if the endDate has passed?

I wouldn’t use a timer, but a proxy item – say called onHolidays, and switch this one with a cron rule and switch it off with a cron rule; if you make the switch visible on the sitemap you can even amually switch it on or off…

I have a switch in my sitemap, and the Vacation_Set item works like a proxy item. But i have a small webview where I can set the Vacation_EndDate item using javascript and the REST API. (I then use IFTTT to set my Nibe heatpump in vacation mode, which requires a end date). I can then use the switch to manually cancel the vacation mode. So the only thing I need to get it automated is to terminate it automatically at the set time.

How would I use a cron rule? Wouldn’t I need to change the rule every time I go on vacation to set the time?

Probably depends how often you go on a holiday :slight_smile:
… yes, but what if you arrive late or early? You would then manually adjust the thing anyway… but then, it is not for me to question your motives… since I do not go on a holiday – I am on a permanent holiday – I haven’t thought in detail about a solutions :slight_smile:

You’re probably right that the best solution would be to just use the end date for my heatpump an manually turn i off for the rest of the house. Was just looking for input if it’s bad practice to use a timer this way.

Thank you for making me not overcomplicate things :wink:

The problem I see with a timer that it is lost in case the system reboots for whatever reason. The cron kicks in no matter what.
At the end of the day it is a matter of philosophy what automation means for the individual. I think more about repetitive tasks being candidates for automation, in contrast to once off events. :slight_smile:

That is indeed a good reason not to use a timer. Thanks for the input!

This is an interesting subject. I would prefer a solution with two number items as setpoint within sitemap:

  • one for the day of month
  • one for the month
    This two items represent the date of your return from vacation.
    You only need a rule every midnight (or shortly after) to check if your day of return is reached. If it is reached you can set your item Vacation_Set to OFF and all dependent rules are now working as if your back home. If you come back earlier than expected just press the button in your sitemap. If you return later than expected, you can adjust the day and month to your like (best to do it a day in advance…)

Hope this helps,

1 Like

I tried using setpoints at first (for year, month, day and hour), but somehow they got messed up inte my sitemap, and I didn’t like how it looked, so I created a webview instead and post the date directly to the DateTime item. If I want to reschedule i can just select a new date from there. As I wrote earlier, the date is needed to activate vacation mode in my heatpump, and I think that’s all I’m going to use it for. That way i can just flip the swich when i leave home, and flip it again when I get home.