Today the bug happened again.
I have a kind of watchdog implemented which catches the bug, but it still remains a strange issue.
The watchdog checks every minute if the dummy switch state is 'on' and latschange is greater than 1 minute.
In that case the watchdog triggers the dummy again by setting it to 'on'.
The code that should be executed when the dummy switches on, switches the dummy off.
Suggestions are welcome
Log from dummy switch
Code: Select all
2021-11-11 07:32:01 Off EventSystem/AssistWakeUp2_2
2021-11-11 07:30:01 On timer
Global log:
Code: Select all
2021-11-11 07:30:01.370 Status: Schedule item started! Name: tWakeupAssist, Type: On Time, DevID: 50, Time: 2021-11-11 07:30:01
2021-11-11 07:32:00.485 Status: Notification: WakeUpAssistant Trigger Failed
2021-11-11 07:32:01.036 Status: LUA: =============== tWakeupAssist DEBUG ====================
2021-11-11 07:32:01.036 Status: LUA: 1:
2021-11-11 07:32:01.036 Status: LUA: Variable:WakeUpAssistTriggered: 1
2021-11-11 07:32:01.036 Status: LUA: 2:
2021-11-11 07:32:01.036 Status: LUA: Variable:WakeUpAssistStarted: 452
2021-11-11 07:32:01.036 Status: LUA: 3:
2021-11-11 07:32:01.036 Status: LUA: Group:SleepAssistantBoven: On
2021-11-11 07:32:01.036 Status: LUA: 4:
2021-11-11 07:32:01.036 Status: LUA: Ikea Socket 02: On FOR 15
2021-11-11 07:32:01.036 Status: LUA: 5:
2021-11-11 07:32:01.036 Status: LUA: Group:Woon Lamp: On AFTER 10
2021-11-11 07:32:01.036 Status: LUA: 6:
2021-11-11 07:32:01.036 Status: LUA: tWakeupAssist: Off
2021-11-11 07:32:01.036 Status: LUA: =============== tWakeupAssist DEBUG ====================
Code: Select all
commandArray = {}
--============== SETTINGS =========================
local LuxLow = 800
--=================================================
local tNow = os.date("*t");
local tNowInMin = tNow.min + tNow.hour * 60
local ZonOp = tonumber(timeofday['SunriseInMinutes']);
local ZonOnder = tonumber(timeofday['SunsetInMinutes'])
local t = os.date("*t");
local Taan = uservariables["VerwarmingAanTemp"]
local Tuit = uservariables["VerwarmingUitTemp"]
local mCrestaTemp,mCrestaHumidity
local doLog = false
-- functions
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 = round((os.difftime (t1, t2) / 60),0)
return difference
end
local function tprint (t, indent, done) -- introduced done to prevent infinite loops for tables with self-references
local done = done or {}
indent = indent or 0
for key, value in pairs (t) do
pre = (string.rep (" ", indent)) -- indent it
if type (value) == "table" and not done[value] then
done [value] = true
print (pre .. tostring (key) .. ":");
tprint (value, indent + 2, done)
elseif type(value) == 'function' and not done[value] then
print( pre .. (tostring (key) .. "()"))
else
pre = pre .. (tostring (key) .. ": ")
print (pre .. tostring(value))
end
end
end
for deviceName,deviceValue in pairs(devicechanged) do
-------------------------------------------------------------
-- WAKE ASSIST
-------------------------------------------------------------
if otherdevices_svalues['Profiel'] ~= '40' then
if (deviceName=='tWakeupAssist') then
if deviceValue == "On" and otherdevices['SkipWakeupassistant'] ~= 'On' and (otherdevices['WakeUpAssistant'] == 'On') then
--- UITZETTEN GAAT VIA GLOBALS, HIER WORDT TRIGGER GEZET
if (otherdevices_svalues['Profiel']~='30') then -- niet uitzetten als profiel op nooituit staat
commandArray[#commandArray + 1] = {['Variable:WakeUpAssistTriggered']='1'}
commandArray[#commandArray + 1] = {['Variable:WakeUpAssistStarted']=tostring(tNowInMin)}
end
--- UITZETTEN GAAT VIA GLOBALS
commandArray[#commandArray + 1] = {['Group:SleepAssistantBoven'] = 'On'}
--commandArray[#commandArray + 1] = {['Slaap Licht'] = "On"} -- Activatie device voor group SleepAssistantBoven
commandArray[#commandArray + 1] = {['Ikea Socket 02'] = "On FOR 15"} -- lamp op logeerkamer 15 minuten aan
if (((tNowInMin <= ZonOp) and (uservariables['LuxAlive'] == 0)) or ((tonumber(otherdevices['LuxMeter']) < LuxLow) and uservariables['LuxAlive'] == 1)) then
commandArray[#commandArray + 1] = {['Group:Woon Lamp'] = "On AFTER 10"}
end
if otherdevices_svalues['NotificationLevel']=='20' then -- NotificationLevel Debug
commandArray[#commandArray + 1] = {['SendNotification']='WakeUpAssistant Triggered'}
end
-- WakeUpAssistant uit functie onderdrukken via NooitUit_Auto
if otherdevices['NooitUit_Auto'] == 'On' then
if otherdevices_svalues['Profiel']~='30' then
commandArray[#commandArray + 1] = {['Profiel'] = "Set Level: 30"}
commandArray[#commandArray + 1] = {['NooitUit_Auto'] = "Off"}
if otherdevices_svalues['NotificationLevel']~='0' then -- Notification not muted
commandArray[#commandArray + 1] = {['SendNotification']='Profiel geschakeld naar NooitUit_Auto, als je morgen de uitfunctie van WakeUpAssistant ook wilt onderdrukken, kies dan een profiel en zet NooitUit_Auto weer aan'}
end
end
end
--==================================================================================================================
-- KRABBEN REPORT
----------------------------------
if otherdevices_svalues['NotificationLevel']~='0' then -- NotificationLevel not muted
local sCrestaTemp, sCrestaHumidity = otherdevices_svalues['Tuin Temp']
--local mCrestaTemp = otherdevices_svalues['Tuin Temp']
mCrestaTemp, mCrestaHumidity = otherdevices_svalues['Tuin Temp']:match("([^;]+);([^;]+)")
local mMin = otherdevices_svalues['Minimum Temp']
if tonumber(mCrestaTemp) < 3 and tonumber(mMin) < 0.5 then
os.execute ('(/bin/sleep 20 && /home/pi/domoticz/scripts/autokrabben.sh > /dev/null)&')
commandArray[#commandArray + 1] = {['SendNotification']='Krabben Report, temperatuur:' ..tostring(mCrestaTemp)}
end
end
--==================================================================================================================
if deviceValue == "On" and #commandArray >= 2 then
commandArray[#commandArray + 1] = {['tWakeupAssist'] = "Off"}
end
elseif deviceValue == "Off" or otherdevices['SkipWakeupassistant'] == 'On' or otherdevices['WakeUpAssistant'] == 'Off' then
if deviceValue ~= "Off" then
commandArray[#commandArray + 1] = {['tWakeupAssist'] = "Off"}
end
if otherdevices['SkipWakeupassistant'] ~= 'Off' then
commandArray[#commandArray + 1] = {['SkipWakeupassistant']='Off'}
end
end
--==================================================================================================================
elseif (otherdevices['WakeUpAssistant'] ~= 'On') and tostring(uservariables['WakeUpAssistantTriggered']) ~= '0' then
commandArray[#commandArray + 1] = {['Variable:WakeUpAssistTriggered']='0'}
end
end
--================================================================
-- Skip WakeUpAssistant
--================================================================
local t = tonumber(uservariables["WakeUpAssistantNextMinutes"] - tNowInMin)
if deviceName == 'SkipWakeupassistant' then
t = tonumber(uservariables["WakeUpAssistantNextMinutes"] - tNowInMin)
if deviceValue == 'On' then
if t < 0 or t > 90 then -- WakeUpAssistant mag geskipt worden, maximaal 1 uur voor de wekker, en ook niet na de wekker
commandArray[#commandArray + 1] = {['SkipWakeupassistant']='Off'}
end
end
end
--================================================================
-- DEBUG
--================================================================
if otherdevices['tWakeupAssist'] == 'On' and deviceName == 'tWakeupAssist' then
print("=============== tWakeupAssist DEBUG ====================")
if #commandArray == 0 then
print ('tWakeupAssist -empty commandArray-')
print('sValue of Profiel: ' .. tostring(otherdevices_svalues['Profiel'] ) )
else
tprint(commandArray)
end
print("=============== tWakeupAssist DEBUG ====================")
end
end
return commandArray
rpi4 - zigbee2mqtt - roborock - espeasy - rfxcom - homewizard p1 - otgw - homebridge - surveillance station - egardia - goodwe - open weather map - wol - BBQ detection - rsync backup