Hi Again,
Does anyone know how to/best way to have a function repeat an action for x every y?
I have an ASR-RF Z-Wave dual channel boiler actuator. It seems to go into “fail-safe” if it does not receive a command within a 60 min period.
Because of this fail-safe, i need to send a “HeatOn” command every 30 mins to be sure that it stays on. BUT sometimes it does stay ON.
So what I need to do is have the function repeat every 30 mins for 3 hours then after 3 hours, send the OFF command.
I have this as 2 issues really, In the Morning i check if there was any motion in the house in the last 12 hours and if true then turn send the HeatOn command. As this is triggered by a schedule this can work fine with luup.call_delay though i find it to be less elegant than i would like.
My main issue is the evening as i want the heating triggered if there is motion in the house and as such this can get triggered many times an evening but i want it to stay on until 22:30 regardless of motion as I may be flopped in front of the TV not moving much. This when sticking delays in is not great as it will put hundreds of delays in if i put 4 or so 30 min call_delay’s in.
Any ideas how i can optermise my heating realy calls?
This is what i do currently for the evening (triggered by any PIR):
Evening:
local day = luup.variable_get("urn:rts-services-com:serviceId:DayTime", "Status", 105) local Cold = math.floor(luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 87));local t = os.date(‘*t’)
local current_second = t.hour * 3600 + t.min * 60 + t.sec – number of seconds since midnight
local min_time_in_seconds = 5 * 3600 + 45 * 60 – 05:45
local max_time_in_seconds = 21 * 3600 + 30 * 60 – 21:30
local MASTERBEDRADDESIRED = 21
local RADTHERMO = “urn:upnp-org:serviceId:TemperatureSetpoint1_Heat”
local MASTERBEDRAD = 93
local MASTERBEDRADTEMP = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSetpoint1_Heat”,“SetpointTarget”,93)function MasterBedroomRad ()
if (MASTERBEDRADTEMP ~= MASTERBEDRADDESIRED) then
luup.call_action( RADTHERMO, “Set SetCurrentSetpoint”,{ NewCurrentSetpoint= MASTERBEDRADDESIRED}, MASTERBEDRAD)
end
endfunction Heating()
if (current_second > max_time_in_seconds) and (current_second < min_time_in_seconds) then
luup.call_action(“urn:upnp-org:serviceId:HVAC_UserOperatingMode1”, “SetModeTarget”,{ NewModeTarget= “Off”}, 97)
elseif (current_second > min_time_in_seconds) and (current_second < max_time_in_seconds) and (day == “0”) and (Cold < 9) then
luup.call_action(“urn:upnp-org:serviceId:HVAC_UserOperatingMode1”, “SetModeTarget”,{ NewModeTarget= “HeatOn”}, 97)
end
endluup.call_delay(‘Heating’, 0)
luup.call_delay(‘MasterBedroomRad’, 0)
luup.call_delay(‘Heating’, 1800)
luup.call_delay(‘Heating’, 3600)
Morning (Triggered by schedule):
local DININGPIR = 156 local DOGPIR = 158 local FDPIR = 160 local GARAGEPIR = 160 local KITCHENPIR = 157 local LANDINGPIR = 167 local LIVINGPIR = 155 local BDPIR = 161local HSWITCH = 97
local DELAY = 43200local SES_SID = “urn:micasaverde-com:serviceId:SecuritySensor1”
local HVACO_SID = “urn:upnp-org:serviceId:HVAC_UserOperatingMode1”
local Cold= math.floor(luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”, “CurrentTemperature”, 87));
local RADTHERMO = “urn:upnp-org:serviceId:TemperatureSetpoint1_Heat”
local MASTERBEDRADDESIRED = 21
local MASTERBEDRADTEMP = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSetpoint1_Heat”,“SetpointTarget”,93)local t = os.date(‘*t’)
local maxtime = 08 * 3600 + 30 * 60 – 08:30
local current_second = t.hour * 3600 + t.min * 60 + t.sec – number of seconds since midnightlocal lastTripDiPIR = luup.variable_get( SES_SID, “LastTrip”, DININGPIR) or os.time()
local lastTripDoPIR = luup.variable_get( SES_SID, “LastTrip”, DOGPIR) or os.time()
local lastTripFDPIR = luup.variable_get( SES_SID, “LastTrip”, FDPIR) or os.time()
local lastTripGPIR = luup.variable_get( SES_SID, “LastTrip”, GARAGEPIR) or os.time()
local lastTripKPIR = luup.variable_get( SES_SID, “LastTrip”, KITCHENPIR) or os.time()
local lastTripLaPIR = luup.variable_get( SES_SID, “LastTrip”, LANDINGPIR) or os.time()
local lastTripLiPIR = luup.variable_get( SES_SID, “LastTrip”, LIVINGPIR) or os.time()
local lastTripBDPIR = luup.variable_get( SES_SID, “LastTrip”, BDPIR) or os.time()function heating ()
if (current_second < maxtime) and ((os.time() - lastTripDiPIR) < DELAY) or ((os.time() - lastTripDoPIR) < DELAY) or ((os.time() - lastTripFDPIR) < DELAY) or ((os.time() - lastTripGPIR) < DELAY) or ((os.time() - lastTripKPIR) < DELAY) or ((os.time() - lastTripLaPIR) < DELAY) or ((os.time() - lastTripLiPIR) < DELAY) or ((os.time() - lastTripBDPIR) < DELAY) and (Cold <= 7) then
luup.call_action( HVACO_SID, “SetModeTarget”,{ NewModeTarget= “HeatOn”}, HSWITCH)
heatingREPEAT()
end
endfunction heatingOff ()
luup.call_action( HVACO_SID, “SetModeTarget”,{ NewModeTarget= “Off”}, HSWITCH)
endfunction heatingREPEAT ()
if (current_second > maxtime) then
heatingOff()
elseif (current_second < maxtime) then
luup.call_timer(“heating”, “1”, “30m”, “”)
luup.call_timer(“heating”, “2”, “1,2,3,4,5,6,7” , “09:00:00” ,“”)
end
endfunction MasterBedroomRad ()
if (MASTERBEDRADTEMP ~= MASTERBEDRADDESIRED) then
luup.call_action( RADTHERMO, “Set SetCurrentSetpoint”,{ NewCurrentSetpoint= MASTERBEDRADDESIRED}, MASTERBEDRAD)
end
endheating ()
MasterBedroomRad ()
I only just added the heatingREPEAT function today so i have not tested it yet, for the Morning scene i think it would work fine but for the motion triggered scene i know its rubbish and thats what i need to find a good solution for primarily.