GetLuaInterface can't find device type

Good day,

I made various scenes to control my lights, blinds, temperature and security. Every time I run my AUTOLight, AUTOTemperature, AUTOBlinds I get a log right after that says

GetLuaInterface can’t find device type: -1/0x1ca0bb8 str: (null) <0x74d5a520>

Normally I would ignore that but I’m looking for a possible error in my code as it usally work for few days and I get an ERROR on Lua code. Meanwhile, all my AUTO scene do not fires. According to the scene page, it shows that in fact they were fired according to my trigger but in fact, they were never fires based on my external log I have built wihin.

Code for AUTOLights
–Version 1.0.22
– *************************************************
– IDEAS AND FEATURE TO DEVELOPPED


– Close fireplace lights at the same time if luxlevel > 140
function myerrorhandler( err )
addLog( "ERROR AutoLight: "… err )
end

function inTimeframe(pStart, pEnd)
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 (mNow >= mStart) and (mNow <= mEnd) then
  return true
else
  return false
end

end

function addLog(log)
local filewrite = io.open(“/var/log/cmh/zst.txt”, “a”)
local datetime = os.date(“%c”)
filewrite:write(datetime … " | “… log…”\n")
filewrite:flush()
filewrite:close()
end

function getGlobalValue(variableID,ID)
local tmpValue = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”,variableID, ID)
if tmpValue == nil then
addLog("PRESENCE: Found a nil value, VariableID: “…variableID…” ID: "…ID)
else
return tonumber(tostring(tmpValue))
end
end

function setGlobalValue(variableID,value)
– variableID has to be like newVariable1-5;
luup.call_action(“urn:upnp-org:serviceId:VContainer1”, “SetVariable”…variableID, {[“newVariable”…variableID] = value}, 977)
end

function FlagOff()
luup.call_action(“urn:upnp-org:serviceId:VSwitch1”, “SetTarget”, {newTargetValue = “0”}, 951)
setGlobalValue(“3”,“0”)
end

function closeLight(LightID)
luup.call_action(“urn:upnp-org:serviceId:Dimming1”,“SetLoadLevelTarget”,{ newLoadlevelTarget = “0”}, LightID)
end

function setLightLevel(upLevel,LightID)

– Only send the command if do not equal the upLevel asked.
local currentLevel = tonumber(tostring(luup.variable_get(“urn:upnp-org:serviceId:Dimming1”,“LoadLevelStatus”, LightID)))

if currentLevel ~= upLevel then
luup.call_action(“urn:upnp-org:serviceId:Dimming1”,“SetLoadLevelTarget”,{ newLoadlevelTarget = upLevel}, LightID)
addLog("AUTOLIGHT setlightLevel set light: “…LightID…” to "…upLevel)
end
end

function changeHouseMode()
– Change house mode from sleep to 1 if motion is detected anywhere downstairs.
if inTimeframe(“6:15”,“12:00”) == true then
if getHOUSEMODE() == “3” then
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”,“SetHouseMode”, {Mode = “1”}, 0)

  addLog("AUTOLIGHT: Changing the house mode from Night to Home")
end

end
end

function dimLight(upLevel,LightID)
local currentLevel = 0
local setlightLevel = 0

currentLevel = tonumber((luup.variable_get("urn:upnp-org:serviceId:Dimming1","LoadLevelStatus", LightID)))

addLog("AUTOLIGHT dimLight upLevel: "..upLevel.." LightID: "..LightID.." currentLevel: "..currentLevel.." setlightLevel: "..         setlightLevel) 

if (tonumber(currentLevel) < tonumber(upLevel) or (tonumber(currentLevel) > tonumber(getGlobalValue("Variable3",977)))) then
setlightLevel = tonumber(getGlobalValue("Variable3",977))

-- if upLevel is smaller then setlightLevel, use upLevel as the max.
if setlightLevel > upLevel then
  setlightLevel = upLevel
end

if setlightLevel >= currentLevel then
  luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget = tostring(setlightLevel)},        LightID)
  addLog("AUTOLIGHT setlightLevel TRUE set light: "..LightID.." to "..setlightLevel)      
else
  -- IF autolight wants to reduced the light level based on the LUX. Only allow if was at the previous setting.
  -- In other words, if users changed the light setting, leave it as is.
  
  if currentLevel == 10 or currentLevel == 20 or currentLevel == 30 or currentLevel == 40 or currentLevel == 50 or currentLevel         == 60 or currentLevel == 70 or currentLevel == 80 or currentLevel == 90 or currentLevel == 100 then
    
    luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget = setlightLevel}, LightID)
    addLog("AUTOLIGHT setlightLevel set light: "..LightID.." to "..setlightLevel)  
  end
end

end
end

function getHOUSEMODE()
local housemode = tostring(luup.attr_get “Mode”)
return housemode
end

function motionTrippedDelay(sensor,delay)
– Return true if motion is not tripped and passed delay

local SES_SID = “urn:micasaverde-com:serviceId:SecuritySensor1”

–Check to see if movement somewhere, if not, abord procedure.
local tripped = luup.variable_get( SES_SID, “Tripped”, sensor) or “0”
local lastTrip = luup.variable_get( SES_SID, “LastTrip”, sensor) or os.time()
if (tripped == “1” or (os.time() - lastTrip <= delay)) then

return true

else
return false
end
end

function AutoLightMain()
local LuxLevel = tonumber(tostring(luup.variable_get(“urn:micasaverde-com:serviceId:LightSensor1”,“CurrentLevel”, 897)))

–If blinds was closed based on temp and time, flags represent that dining room was closed.
local closeDiningWeather = tostring(getGlobalValue(“Variable2”,1001))

– LuxLevel must be under 140 or
– if closed the blind in the dining room, use a new threshold
– or if weekdays and no mouvement.
local DELAY = 120 – Seconds

– Sensor 990 = Kitchen
– Sensor 895 = Dining room

– Sensor 1003 = Cam Entrance
– Sensor 835 = Cam Kichen

local kitchenNoMouv = motionTrippedDelay(1023,DELAY)

if (kitchenNoMouv == true) then
– Mouvement detected, reset closeLightNoMouv flag
luup.call_action(“urn:upnp-org:serviceId:VContainer1”, “SetVariable3”, {[“newVariable3”] = “0”}, 986)
addLog(“AUTOLIGHT Mouvement detected, reset closelightnomouv flag”)

elseif (kitchenNoMouv == false) then
– Close lights if no mouvement and weekdays within a time frame
addLog(“AUTOLIGHT no Mouvement detected”)

  local currentWeekDay = os.date("%A")
  if (currentWeekDay == "Monday" or currentWeekDay == "Tuesday" or currentWeekDay == "Wednesday" or currentWeekDay == "Thursday"         or currentWeekDay == "Friday") and inTimeframe("8:00","16:00") == true then
      
      addLog("AUTOLIGHT no Mouvement detected within weekdays and between 8 to 16")  
     local CloseLightNoMouv = tonumber(tostring(getGlobalValue("Variable3",986)))
    
    --if no mouvement is detected and CloseLughtNiMouv is on meaning that the ligths has been turnedoff. Abord procedure
    if CloseLightNoMouv == 1 then
      addLog("AUTOLIGHT abord procedure, lights seem to be closed.")
      return
    end

    --CloseLightsNoMouv
    if CloseLightNoMouv == 0 and inTimeframe("8:00","15:30") then
      luup.call_action("urn:upnp-org:serviceId:VContainer1", "SetVariable3", {["newVariable3"] = "1"}, 986)  
      CloseLightNoMouv = 1
      
      if kitchenNoMouv == false then
        addLog("AUTOLIGHT no Mouvement close all the lights")
        -- no motion in kitchen
        --[[ Home Theater  --]]
        --[[ ht_FrontLight --]]
        closeLight(199)  	
        
        
        --[[ ht_MiddleLight --]]
        closeLight(201)
       
       
        --[[ Kitchen --]]
        --[[kit_Lights --]]
        closeLight(16) 
        
        --[[kit_Hallway_Lights --]]
        closeLight(979) 
        
        --[[ kit_island --]]
        closeLight(54)
        
        --[[ Power Room --]]
        --[[ pr_room --]]
        closeLight(19)
        
        --Lights in dining room
        --[[  Dining Room  --]]
        --[[DR-TableLights  --]]
        closeLight(186)
          
        --[[  DR-PotsLights  --]]
        closeLight(187)
        
        addLog("AUTOLIGHT Close lights in Kitchen, no mouvmement.")  
        return
      end
    end
  end

end

if LuxLevel >= 140 or (closeDiningWeather == “1” and LuxLevel > 25) then
–IF LUX WHEN OVER 90 NEED TO CLOSE THE LIGHTS THAT WAS TURNED ON.
if tonumber(getGlobalValue(“Variable3”,977)) > 0 then
closeLight(186)
closeLight(187)
closeLight(199)
closeLight(201)
closeLight(16)
closeLight(979)
closeLight(54)
closeLight(19)
closeLight(27)
closeLight(25)
closeLight(135)
closeLight(30)
closeLight(32)
closeLight(202)
closeLight(991)
closeLight(979)
setGlobalValue(“3”,“0”)
addLog(“AUTOLIGHT Close all lights, not dark enough.”)
end
addLog(“AUTOLIGHT Not enough dark to launch.”)
return false
end

– Check if motion in Kitchen and dining room.
–bypass if new person arrived (variable4) > then 0 will have the VSswithID
– Start process in housemode is HOME or NIGHT, if night, only lit up first floor only is new person arrived.

if (tostring(getHOUSEMODE()) == “1”) or (tostring(getHOUSEMODE()) == “3” and tonumber(getGlobalValue(“Variable4”,977)) > 0) then
–Open Lights after 4:00
local startTime = “16:30”
local hour = tonumber( startTime:sub( startTime:find(“%d+”) ) )
local minute = tonumber(startTime:sub(-2))
startTime = hour * 100 + minute
local currentTime = os.date(“*t”)
currentTime = currentTime.hour * 100 + currentTime.min
if startTime <= currentTime then
–Open lights kitchen
–Island
setLightLevel(100,16)

  --[[ kit_island --]]
  setLightLevel(50,54)
end

LuxLevel = tonumber(LuxLevel)

--Keep the old light level
setGlobalValue("2",getGlobalValue("Variable3",977))

--Based on the sky condition, if sunny and clear, use the following value else, lower ones.
--local currentSkyCondition = tostring(getGlobalValue("Variable2",1000))
--if currentSkyCondition 

local dayNight = luup.variable_get("urn:rts-services-com:serviceId:DayTime","Status",970)
if LuxLevel <=140 and LuxLevel >= 75 then
  --level 1
  if dayNight == "0" then
    setGlobalValue("3","5")
  else
    setGlobalValue("3","10")
  end 
elseif LuxLevel < 75 and LuxLevel >= 70 then
  --level 2
  if dayNight == "0" then
    setGlobalValue("3","10")
  else
    setGlobalValue("3","20")
  end
elseif LuxLevel < 70 and LuxLevel >= 65 then
  --level 3
  if dayNight == "0" then
    setGlobalValue("3","15")
  else
    setGlobalValue("3","30")
  end
elseif LuxLevel < 65 and LuxLevel >= 60 then
  --level 4
  if dayNight == "0" then
    setGlobalValue("3","20")
  else
    setGlobalValue("3","40")
  end
elseif LuxLevel < 60 and LuxLevel >= 55 then
  --level 5
  if dayNight == "0" then
    setGlobalValue("3","40")
  else
    setGlobalValue("3","50")
  end
elseif LuxLevel < 55 and LuxLevel >= 45 then
  --level 6
  if dayNight == "0" then
    setGlobalValue("3","40")
  else
    setGlobalValue("3","60")
  end
elseif LuxLevel < 45 and LuxLevel >= 25 then
  --level 7
  if dayNight == "0" then
    setGlobalValue("3","40")
  else
    setGlobalValue("3","70")
  end
elseif LuxLevel < 25 and LuxLevel >= 20 then
  --level 8
  if dayNight == "0" then
    setGlobalValue("3","40")
  else
    setGlobalValue("3","80")
  end
elseif LuxLevel < 20 and LuxLevel >= 15 then
  --level 9
  if dayNight == "0" then
    setGlobalValue("3","40")
  else
    setGlobalValue("3","90")
  end
 
elseif LuxLevel < 15 and LuxLevel >= 0 then
  --level 10
  if dayNight == "0" then
    setGlobalValue("3","40")
  else
    setGlobalValue("3","100")
  end
else  
  --Nothing for now.
  setGlobalValue("3","0")
  return
end 

--Only close blinds if in the afternoon and open the fireplace lights.
startTime = "15:30"
hour = tonumber( startTime:sub( startTime:find("%d+") ) )
minute = tonumber(startTime:sub(-2))
startTime = hour * 100 + minute
currentTime = os.date("*t")
currentTime = currentTime.hour * 100 + currentTime.min
 
if startTime <= currentTime and tostring(getGlobalValue("Variable3",977)) == "100" then
  
  local sBlindDenBlind1 = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", 969)
  local sBlindDen12 = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", 51)
  local sBlindLR12_Den = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", 49)
  local sBlindMB_Blind = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", 53)
  local sBlindHU_Blind = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", 175)
  
  if sBlindDenBlind1 == "0" then
    -- must close the blind
     luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, 969)
  end
  
  if sBlindDen12 == "0" then
    -- must close the blind
     luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, 51)
  end
   
  if sBlindLR12_Den == "0" then
    -- must close the blind
     luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, 49)
  end
   
  if sBlindMB_Blind == "0" then
    -- must close the blind
     luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, 53)
  end
  
  if sBlindHU_Blind == "0" then
    -- must close the blind
     luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, 175)
  end
  
  --Open fireplace lights
  local sFireplaceLight = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", 991)
  if tostring(getGlobalValue("Variable3",977)) ~= tostring(getGlobalValue("Variable2",977)) and sFireplaceLight =="0" then
    luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="1" },991)
  end
end

--Patch, check if kitchen pot lights are on, if so, abord procedure, looks like the lights are on.
local currentLevel = tonumber((luup.variable_get("urn:upnp-org:serviceId:Dimming1","LoadLevelStatus", 16)))
local currentLevelHU = tonumber((luup.variable_get("urn:upnp-org:serviceId:Dimming1","LoadLevelStatus", 25)))
if tostring(getGlobalValue("Variable3",977)) == tostring(getGlobalValue("Variable2",977)) and (currentLevel > 0 and dayNight == "0") or (currentLevel > 0 and currentLevelHU > 0 and dayNight == "1") then
  -- SHOULD CHECK THE LIGHT STATUS TOO. I HAD TO RESET THE FLAG IT TOUGHT THAT IT WAS A THE RIGHT MODE.
  
  return
end

--flag on
luup.call_action("urn:upnp-org:serviceId:VSwitch1", "SetTarget", {newTargetValue = "1"}, 951)
addLog("AUTOLIGHT VSSwitch ON")

--[[  Dining Room  --]]
--[[DR-TableLights  --]]
dimLight(10,186)

--[[ Home Theater  --]]
--[[ ht_FrontLight --]]
dimLight(40,199)  	
 
--[[ ht_MiddleLight --]]
dimLight(40,201)

--[[ Kitchen --]]
--[[kit_Lights --]]
dimLight(100,16) 

--[[kit_Hallway_Lights --]]
dimLight(100,979) 

--[[ kit_island --]]
dimLight(50,54)

--[[ Power Room --]]
--[[ pr_room --]]
dimLight(20,19)

-- Only light up the second floor if NOT in goodnight mode and new person arrived

if getHOUSEMODE() == "3" then
  return
end
--[[  DR-PotsLights  --]]
dimLight(100,187)	
  
--THIS PART WON'T BE EXECUTED IF HOUSE IS IN GOODNIGHT

-- Only open lights on the second floor within that time frame
--MUST CHECK THE SEASON AND ADAPT THE TIME (16HRS) DO NOT WORK FOR NOVEMBER
local pStart = "16:00"   -- Start of time period
local hS, mS = string.match(pStart,"(%d+)%:(%d+)")
local mStart = (hS * 60) + mS
local tNow = os.date("*t")
local mNow = (tNow.hour * 60) + tNow.min

if (mNow >= mStart) then
  -- If later then pStart, open lights
  --[[ Highway upstairs --]]
  --[[ hu_potLight_Zak --]]
  dimLight(100,27)
  
  --[[ hu_PotLights --]]
  dimLight(100,25)          
  
  --[[ hu_stairLight --]]
  dimLight(20,135)          
  
  --[[ Master Bed --]]
  --[[ mb_Ceiling --]]
  dimLight(40,30)
  
  --[[ mb_DadaBedSide --]]
  dimLight(100,32)
  
  --[[ mb_MamaLight --]]
  dimLight(100,202)  
end  

end
end

local checkmouv = motionTrippedDelay(1023,400)
if checkmouv then
– Check if should change the house mode from sleep to home
local status = xpcall( changeHouseMode, myerrorhandler )
end

–Only start the process if not in GoodNight
if getHOUSEMODE() == “1” or (getHOUSEMODE() == “2” and
tonumber(getGlobalValue(“Variable4”,977)) >0) or (getHOUSEMODE() == “3” and
tonumber(getGlobalValue(“Variable4”,977)) > 0) then

if tonumber(tostring(getGlobalValue(“Variable4”,977))) > 0 then
addLog("AUTOLIGHT launch with: Housemode= "… getHOUSEMODE() … " New person arrived ID: "… getGlobalValue(“Variable4”,977))
end

local status = pcall(AutoLightMain)
if (not status) then
luup.log(“AUTOLIGHT:Error calling: AutoLight”)
addLog(“ERROR AUTOLIGHT”)
end
end

if you cant find one give me your address Im holding one right now in my hands,ill send it to you.