Do i need to paste te complete script? i tried it but it dit not work......
Here is the complete code and edited by myself whats the best for me....
Nothing happend at 09:30 en 09:35 today....
Code: Select all
-- EvoSchedule
--[[
this script will update setpoints based on schedules entered in the description field of (Evo) setpoint devices.
schedule should be formatted like:
schedule:{"sunday":{"09:30":"21.5”,”09:35”:”18.5”},”wednesday":{"08:05":"22","15:40":"23"}}
for valid days look in convertKey function (keys are case sensitive)
time can be entered with a granularity of 5 minutes. If that is not granular enough,
the on = { timer string below must be changed to "every minute)"
your setpointDevice(s) are to be entered in the variable allSetpoints
]]--
return {
on = { timer = { "every 5 minutes" }},
logging = { level = domoticz.LOG_DEBUG,
marker = "EvoSchedule" },
execute = function(dz)
local allSetpoints = {"Thuis: Thermostat","EvoTouch woonkamer 3","Thuis: EvoTouch"} -- all evo devices (minimal 1)
local function convertKey(key)
if key == "allDays" or key == "alleDagen" then return true end
if key == "weekend" then return dz.time.matchesRule("on sat,sun")
elseif key == "workday" or key == "werkdag" then return dz.time.matchesRule("on mon,tue,wed,thu,fri")
elseif key == "sunday" or key == "zondag" then return dz.time.matchesRule("on sun")
elseif key == "saturday" or key == "zaterdag" then return dz.time.matchesRule("on sat")
elseif key == "monday" or key == "maandag" then return dz.time.matchesRule("on mon")
elseif key == "tuesday" or key == "dinsdag" then return dz.time.matchesRule("on tue")
elseif key == "wednesday" or key == "woensdag" then return dz.time.matchesRule("on wed")
elseif key == "thursday" or key == "donderdag" then return dz.time.matchesRule("on thu")
elseif key == "friday" or key == "vrijdag" then return dz.time.matchesRule("on fri")
end
return true
end
local function processAllSetpoints()
for i=1,#allSetpoints do -- walk over all declared setPoint devices
local mySetpoint = dz.devices(allSetpoints[i])
-- string.find(mySetpoint.description,"schedule:(%d+)"
dz.log("Looking at device " .. mySetpoint.name .. ". This device is type: " .. mySetpoint.deviceType .. ", subtype: " .. mySetpoint.deviceSubType,dz.LOG_DEBUG)
if (mySetpoint.description):find("schedule:") then
local _,_,schedule = (mySetpoint.description):find("schedule:(.*)")
dz.log(schedule,dz.LOG_DEBUG)
local control = dz.utils.fromJSON(schedule)
for day,setpoints in pairs(control) do
local msg = "evaluating " .. day
if convertKey(day) then
dz.log(msg .. " <<== true",dz.LOG_DEBUG)
for clockTime,setpoint in pairs(setpoints) do
msg = "evaluating setpoint of " .. mySetpoint.name .. " on " .. day .. " at " .. clockTime .. " to " .. setpoint .. " degrees"
if dz.time.matchesRule("at " .. clockTime) then
dz.log(msg .. " <<== will be set now",dz.LOG_DEBUG)
mySetpoint.updateSetPoint(setpoint,dz.EVOHOME_MODE_PERMANENT_OVERRIDE)
-- 2nd parm necessary for evo Devices
-- and will be ignored by standard setPoint devices
else
dz.log(msg .. " <<== NOT now",dz.LOG_DEBUG)
end
end
else
dz.log(msg .. " <<== false",dz.LOG_DEBUG)
end
end
else
dz.log("Device " .. mySetpoint.name .. " does not have a schedule in description field",dz.LOG_DEBUG)
end
end
end
processAllSetpoints()
end
}