CommandArray not executed Topic is solved

Moderator: leecollings

azonneveld
Posts: 179
Joined: Wednesday 02 October 2019 7:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands
Contact:

Re: CommandArray not executed

Post by azonneveld »

waaren wrote: Thursday 11 March 2021 8:46 Maybe you will see some interesting values when you add some prints. Something like below?

Code: Select all

    if #commandArray == 0 then 
        print ('tWakeupAssist -empty commandArray-') 
        print('sValue of Profiel: '  .. tostring(otherdevices_svalues['Profiel'] ) )
        -- Any other interesting device values Here ? 
    else
        tprint(commandArray)
    end
Today this gave the following hit:

Code: Select all

2021-03-16 06:10:01.732 Status: LUA: =============== tWakeupAssist DEBUG ====================
2021-03-16 06:10:01.732 Status: LUA: tWakeupAssist -empty commandArray-
2021-03-16 06:10:01.732 Status: LUA: sValue of Profiel: 20
2021-03-16 06:10:01.732 Status: LUA: =============== tWakeupAssist DEBUG ==================== 
2021-03-16 06:10:01.988 Status: LUA: =============== tWakeupAssist DEBUG ====================
2021-03-16 06:10:01.988 Status: LUA: 1:
2021-03-16 06:10:01.988 Status: LUA: tWakeupAssist: Off
2021-03-16 06:10:01.988 Status: LUA: 2:
2021-03-16 06:10:01.988 Status: LUA: Variable:WakeUpAssistTriggered: 1
2021-03-16 06:10:01.989 Status: LUA: 3:
2021-03-16 06:10:01.989 Status: LUA: Variable:WakeUpAssistStarted: 370
2021-03-16 06:10:01.989 Status: LUA: 4:
2021-03-16 06:10:01.989 Status: LUA: Slaap Licht: On
2021-03-16 06:10:01.989 Status: LUA: 5:
2021-03-16 06:10:01.989 Status: LUA: Ikea Socket 02: On FOR 15
2021-03-16 06:10:01.989 Status: LUA: 6:
2021-03-16 06:10:01.989 Status: LUA: Group:Woon Lamp: On AFTER 10
2021-03-16 06:10:01.989 Status: LUA: 7:
2021-03-16 06:10:01.989 Status: LUA: Profiel: Set Level: 30
2021-03-16 06:10:01.989 Status: LUA: 8:
2021-03-16 06:10:01.989 Status: LUA: NooitUit_Auto: Off
2021-03-16 06:10:01.989 Status: LUA: 9:
2021-03-16 06:10:01.989 Status: LUA: SendNotification: Profiel geschakeld naar NooitUit_Auto....
2021-03-16 06:10:01.989 Status: LUA: =============== tWakeupAssist DEBUG ==================== 
rpi4 - zigbee2mqtt - roborock - espeasy - rfxcom - homewizard p1 - otgw - homebridge - surveillance station - egardia - goodwe - open weather map - wol - BBQ detection - rsync backup
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: CommandArray not executed

Post by waaren »

azonneveld wrote: Tuesday 16 March 2021 11:28 Today this gave the following hit:
The only thing I can think of is that at 2021-03-16 06:10:01.732 the tWakeupAssist was not 'On' Maybe a print of the state of that device in the
-- Any other interesting device values Here ?
line would help to identify what is going on.

Code: Select all

if #commandArray == 0 then 
        print ('tWakeupAssist -empty commandArray-') 
        print('sValue of Profiel: '  .. tostring(otherdevices_svalues['Profiel'] ) )
        -- Any other interesting device values Here ? 
    else
        tprint(commandArray)
    end
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
azonneveld
Posts: 179
Joined: Wednesday 02 October 2019 7:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands
Contact:

Re: CommandArray not executed

Post by azonneveld »

waaren wrote: Tuesday 16 March 2021 12:08 the tWakeupAssist was not 'On' Maybe a print of the state of that device in the line would help to identify what is going on.
That is possible, since the script is device triggered.
tWakeupAssist could be on, but other devices are still in front in the execution cue.
When the script is executed based on other devices in the cue, the 'otherdevices' command retrieves the state of the tWakeupAssist, and it is 'On'.

I changed the script, now the 'debug' is only triggered on the tWakeupAssist device.
rpi4 - zigbee2mqtt - roborock - espeasy - rfxcom - homewizard p1 - otgw - homebridge - surveillance station - egardia - goodwe - open weather map - wol - BBQ detection - rsync backup
azonneveld
Posts: 179
Joined: Wednesday 02 October 2019 7:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands
Contact:

Re: CommandArray not executed

Post by azonneveld »

I have not seen the error again since upgrade to 2021.1.
rpi4 - zigbee2mqtt - roborock - espeasy - rfxcom - homewizard p1 - otgw - homebridge - surveillance station - egardia - goodwe - open weather map - wol - BBQ detection - rsync backup
azonneveld
Posts: 179
Joined: Wednesday 02 October 2019 7:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands
Contact:

Re: CommandArray not executed

Post by azonneveld »

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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest