No YEAR in restriction?


#1

Hey Peeps,

Out of curiosity, is there a way to set a DATE restriction where you don’t have to enter the year? I want my Xmas piston to only run Nov 25 to Jan 1, no matter what the year.

Suggestions welcomed. :slight_smile:


Light Automation within date range
#2

Rather than using a restriction, you could use an if after the every statement and use

{int(formatDateTime($now, 'MMdd'})) greater than or equal to 1125

If you also want to run it on January first (not sure whether it was inclusive), you would have to add

OR {int(formatDateTime($now, 'MMdd'))} equal to 101

EDIT: you actually can use this in an expression as well - here’s your piston reworked (I used "less than or equal for the January 1st so it is easier to adjust if people want to add a few more days… Also, I don’t have an RGB bulb so it changed that entry to Dimmer 1)


#3

Here’s a similar question, same basic idea as @ahndee’s answer but a bit more readable. Note that with either of these solutions your BETWEEN will need to OR together two conditions like @ahndee showed to handle dates up to Dec 31 and then dates following Jan 1 (reasons described in the other thread).

Eh, not really more readable… the benefit to ahndee’s is that it doesn’t require a BETWEEN at all so you don’t have to worry about representing December 31 and January 1 since the less than or equal takes care of that.


#4

Thanks guys… BOTH are great examples!


#5

I ended up with the following as is looked the cleanest.


#6

You’ll just need OR rather than AND, otherwise you could do one condition for NOT BETWEEN Jan 3 and Nov 24


#7

Oops… you’re right. Nice catch. :wink:


#8

This was timely as I’d rebuilt what I’d had in CoRE in webCoRE and was having some issues. Here’s what I came up with:


Question–the "only while “Home, Evening…” will not trigger when the mode changes, right? e.g. Mode was Away and we return, the mode changes to Evening (or Home).


#9

right, restrictions (only when) do not act as trigger.