2016-05-23 21:35:00.368 Error: EventSystem: in script_time_Besparing: [string "function timedifference(s) ..."]:9: field 'day' missing in date table
I think it is not in my script because I changed the code a lot (now it's back to the basis and doesn't make sense, but still got the error.
Is it a domoticz bug in the event system?
my device is working well:
11 RFX 0A2FEA6 12 Slaapkamer Lighting 2 AC Off 6
the script.
Code: Select all
function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
commandArray = {}
-- package.path = package.path .. ';' .. '/home/pi/domoticz/scripts/lua/?.lua'
-- My = require('MyFunc')
-- Variable
Script = 'Besparing' --
Version = 1 --
Notifications = uservariables["Notifications"] -- On/Off
minuten_toegestaan = 15 -- aantal minuten 180 = 3 uur
StateDevice = 'Iemand_thuis'
TH_Hour1 = 8 -- Treshold hour
TH_Hour2 = 10 -- Treshold hour
Nu_Hour =tonumber(os.date('%H',time))
Debug = 'Y'
if ((Nu_Hour >= TH_Hour1) or (Nu_Hour <= TH_Hour2)) then Res_Hour=1 else Res_Hour=0 end
-- if (otherdevices['Slaapkamer']) == 'On' then Slaapkamer=1 else Slaapkamer=0 end -- omgedraait omdat het ook DO set dimmer level to 80% kan hebben ipv on.
-- if (otherdevices['Gang']) == 'On' then Gang=1 else Gang=0 end
if (otherdevices['Iemand_thuis']) == 'On' then Aanwezig=1 else Aanwezig=0 end
-- TDiffGang = My.Round(My.TimeDiff(os.time(),LastChange_Gang)/60,0)
-- TDiffSlaapkamer = My.Round(My.TimeDiff(os.time(),LastChange_Slaapkamer)/60,0)
--logging
print ('______________________________________________________________________')
print('<b style="color:Blue"> '.. Script .. ".......v" .. Version .. "..Debugging= " .. Debug .. '</b>')
if (otherdevices['Bespaar_modus']) == 'Off' then print (". Besparing wordt niet toegepast. ") goto done end
if Debug == 'Y' then
--print ( ". " .. Aanwezig .. " - Iemand thuis? " )
-- print ( ". Slaapkamer : " .. TDiffSlaapkamer .. " minuten geleden naar: " .. (otherdevices['Slaapkamer']) )
else
end
-- Binnen gestelde tijd
-- commandArray['SendNotification']='Bespaaralert!#Gang staat al ' .. minuten_toegestaan .. ' minuten aan!#0#pushover'
-- if ((Aanwezig == 0) and (IetsAan >= 1)) then
-- print(". Niemand thuis terwijl" .. TDiffSlaapkamer .. " aan stond.")
-- commandArray['SendNotification']='Bespaaralert!#Niemand aanwezig en devices aan!#1#pushover'
-- commandArray['Alles']='On'
-- end
--get status of all sensors
--if the sensor is dead for more than 1 day output the name of that sensors
for i, v in pairs(otherdevices) do
timeon = 86400 -- 1 dag in seconden
tc = tostring(i)
print("Alive: " .. tc .. " ");
difference = timedifference(otherdevices_lastupdate[tc])
if (difference > timeon) then
tempdiff = tostring(difference)
--remove garbage from the output, only report nodes that has not update for more than 1 day.
v = i:sub(1,2)
v2 = i:sub(1,4)
v3 = i:sub(1,6)
v4 = i:sub(1,17)
if ( (v ~= 'IP') and (v2 ~= 'Talk') and (v3 ~= 'Tunein') and (v4 ~= 'Living Room - Hub') ) then
print("Dead: " .. tc .. " : " .. difference);
end
end
end
::done::
return commandArray