different schedules for each month

hey guys

this might too easy, but im new at this. would appreciate the help.
i’m trying to come up with scenes for my AC in a remote warehouse. need a timer for 7 months and another timer for the other 5 months of the year.

This is entirely analogous to this situation:
[url=http://forum.micasaverde.com/index.php/topic,14964.msg113659.html#msg113659]http://forum.micasaverde.com/index.php/topic,14964.msg113659.html#msg113659[/url]
where the need was to toggle between either of two schedules on a day-to-day basis.

In a nutshell, a solution is to set up both schedules which always run, but the one which is not selected by the setting of a Virtual Switch (in your case, I suppose, “Summer or Winter” mode) is terminated before it actually runs.

In that example the switch between modes is manual (not too onerous, I would have thought if just twice a year) but there’s no reason why you couldn’t automate that switchover too.

Hope this helps.

akbooer

thanks for the info.
but this is the point, how to automate the switch over ?
yes this is a Summer / winter twice a year switch.

cant this be done with a code for a monthly schedules ?

If you use a VirtualSwitch as suggested by @akbooer, you could create a scene that runs once a day - say at 00:01:00 - with Luup code to set the switch if it is summer. The following example will set the switch between May 10th and September 15th.

Replace with the device number of your VirtualSwitch.

[code]local dt = os.date(“*t”)
local month = dt.month
local day = dt.day
local summer
local VSID =
local ssmon = 5 – Start of summer (month)
local ssday = 10 – Start of summer (day)
local esmon = 9 – End of summer (month)
local esday = 15 – End of summer (day)

if ((month == ssmon) and (day >= ssday))
or ((month == esmon) and (day <= esday))
or ((month > ssmon) and (month < esmon)) then summer = 1 else summer = 0 end

luup.call_action(“urn:upnp-org:serviceId:VSwitch1”,“SetTarget”,{newTargetValue=summer},VSID)
[/code]

Beat me to it @RexBeckett!

Yes, agree, a scene run every day. But I did this with monthly granularity:

local schedule = {0,0,0,0, 1, 1, 1, 1, 0,0,0,0}   -- 12 entries, Jan-Dec, set to 1 if Summer mode
VSwitch.set("Summer Mode", schedule[tonumber(os.date('%m'))])

Thanks alto all. Appreciate the help on this.

I’ll give it a shot.

[quote=“akbooer, post:5, topic:175501”]Beat me to it @RexBeckett!
Yes, agree, a scene run every day. But I did this with monthly granularity:[/quote]

or instead of basing the decision on the month, might be smarter to base it on current external or/and internal temperature (to be global-warming proof) …

The code is giving “error in lua code for scenes and events”, my VS id is 43, this is only thing i added. Ay suggestions ?

[quote=“RexBeckett, post:4, topic:175501”]If you use a VirtualSwitch as suggested by @akbooer, you could create a scene that runs once a day - say at 00:01:00 - with Luup code to set the switch if it is summer. The following example will set the switch between May 10th and September 15th.

Replace with the device number of your VirtualSwitch.

[code]local dt = os.date(“*t”)
local month = dt.month
local day = dt.day
local summer
local VSID =
local ssmon = 5 – Start of summer (month)
local ssday = 10 – Start of summer (day)
local esmon = 9 – End of summer (month)
local esday = 15 – End of summer (day)

if ((month == ssmon) and (day >= ssday))
or ((month == esmon) and (day <= esday))
or ((month > ssmon) and (month < esmon)) then summer = 1 else summer = 0 end

luup.call_action(“urn:upnp-org:serviceId:VSwitch1”,“SetTarget”,“newTargetValue”,summer,VSID)
[/code][/quote]

Copy and paste your code exactly as it is on your Vera. We’ll want to eliminate silly mistakes (such as you leaving the angle brackets in when you substituted the switch ID) before digging deeper.

Hi futzle

i doubled check, it all ok. i re-created that scene. now error is gone, but its not changing the VS status when i run the scene.
this is what i did so far.
created a scene “is it summer” set a schedule to run daily at 12:01 am, inserted the lua code as is with device ID. VS is off. it should turn VS to ON since its summer. it didnt.

i was testing so i can go ahead and create two more scenes based on the VS status, is this right ?

or the Lua code is for the two scenes and i should automate the VS switch with a certain matching scenes for summer or winter, i’m confused ?

[quote=“daiz, post:10, topic:175501”]i was testing so i can go ahead and create two more scenes based on the VS status, is this right ?

or the Lua code is for the two scenes and i should automate the VS switch with a certain matching scenes for summer or winter, i’m confused ?[/quote]

… I think we’ll all be confused until you post the actual scene configuration and code that you are using.

if you’d like to help, provide your thoughts on how it should be done, how many scenes, lua code below to be in both scenes, etc.

i dont have much to post as i said earlier

I thought I had done that already.

worked great. thanks ALL

im having the same problem
the script is not updating my vitual switch

i tried both scripts

please help
here is what i currently have

local dt = os.date(“*t”)
local month = dt.month
local day = dt.day
local summer
local VSID = 32
local ssmon = 5 – Start of summer (month)
local ssday = 10 – Start of summer (day)
local esmon = 9 – End of summer (month)
local esday = 30 – End of summer (day)

if ((month == ssmon) and (day >= ssday))
or ((month == esmon) and (day <= esday))
or ((month > ssmon) and (month < esmon)) then summer = 1 else summer = 0 end

luup.call_action(“urn:upnp-org:serviceId:VSwitch1”,“SetTarget”,“newTargetValue”,summer,VSID)

i have also tried

local schedule = {0,0,0,0, 1, 1, 1, 1, 1,0,0,0} – 12 entries, Jan-Dec, set to 1 if Summer mode
VSwitch.set(“Summer Mode”, schedule[tonumber(os.date(‘%m’))])

i have a virtual switch called Summer mode
but the status is never changed

perhaps i did something wrong in the scene

the scene currently has no devices selected as its my understanding this is done by LUUP
and schedule is set to everyday at 12am
however i am forcing it to run
it says it runs
but the status of the adapter remains at 0

as a test i tried to run only this

VSwitch.set(“Summer mode”,1)
but still nothing is changed
virtual adapter still is off

Please help

[quote=“charettepa, post:15, topic:175501”]im having the same problem
the script is not updating my vitual switch

i tried both scripts

please help
here is what i currently have

local dt = os.date(“*t”)
local month = dt.month
local day = dt.day
local summer
local VSID = 32
local ssmon = 5 – Start of summer (month)
local ssday = 10 – Start of summer (day)
local esmon = 9 – End of summer (month)
local esday = 30 – End of summer (day)

if ((month == ssmon) and (day >= ssday))
or ((month == esmon) and (day <= esday))
or ((month > ssmon) and (month < esmon)) then summer = 1 else summer = 0 end

luup.call_action(“urn:upnp-org:serviceId:VSwitch1”,“SetTarget”,“newTargetValue”,summer,VSID)[/quote]
Change the last line to:

luup.call_action("urn:upnp-org:serviceId:VSwitch1","SetTarget",{newTargetValue=summer},VSID)

thank you so much
i have been working on this all day

that worked

has the script requirement chaged
or was it a typo in your original post?

also i have anoth script id like to implement
currently i have an app on my phone that runs the “welcome home” scene as soon as im in wifi range
one of the items in the scene is to turn on the outdoor light

is there a way to say turn on light only if its night time
i already have the day night plugin
im assuming the if will be a luup statement

thanks again in advance

If the LUUP code for a SCENE returns a false then the actions for the scene will not be executed.

thats perfect
what would be the required luup code to check for
day/night