Why won't this code work

Trying to get a scene to only run between two time periods. Ive just moved to UI7 from UI5 where the code below used to work!!!

[code]local function checkTime()
local pStart = “09:00” – Start of time period
local pEnd = “21:00” – End of time period
local allow = true – true runs scene during period, false blocks it
local hS, mS = string.match(pStart,“(%d+)%:(%d+)”)
local mStart = (hS * 60) + mS
local hE, mE = string.match(pEnd,“(%d+)%:(%d+)”)
local mEnd = (hE * 60) + mE
local tNow = os.date(“*t”)
local mNow = (tNow.hour * 60) + tNow.min

if mEnd >= mStart then

 return (((mNow >= mStart) and (mNow <= mEnd)) == allow)

else
return (((mNow >= mStart) or (mNow <= mEnd)) == allow)

end end[/code]

If this is the entire body of code in your scene, it won’t work because all it does is define a function, it doesn’t execute it. Do you have “return checkTime()” after the part you’ve posted?

Thank you that’s all i needed to get the grey matter working again. All working now…

[code]local function checkTime()
local pStart = “20:00” – Start of time period
local pEnd = “07:30” – End of time period
local allow = true – true runs scene during period, false blocks it
local hS, mS = string.match(pStart,“(%d+)%:(%d+)”)
local mStart = (hS * 60) + mS
local hE, mE = string.match(pEnd,“(%d+)%:(%d+)”)
local mEnd = (hE * 60) + mE
local tNow = os.date(“*t”)
local mNow = (tNow.hour * 60) + tNow.min

if mEnd >= mStart then

 return (((mNow >= mStart) and (mNow <= mEnd)) == allow)

else
return (((mNow >= mStart) or (mNow <= mEnd)) == allow)

end end

local lul_tmp = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1” , “CurrentTemperature”,84)

if checkTime() and (tonumber(lul_tmp) <36)

then

luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”, “RunScene”, { SceneNum= “79”}, 0)

else return false
end[/code]

By the way, the “allow” variable doesn’t work the way the comments say, given the implementation. What it will do is invert the sense of the function, so rather than disabling the scene altogether, it will run the scene in the opposite period (that is, when allow=true, your function will return true between 2000 and 0730, but when allow=false, it will return true between 0730 and 2000 and the scene will thus run).

Edit: times to match most recent post