Det mesta fungerar jättebra, men jag kan inte få lokala QA-variabler att fungera i ZeroBrane.
Globala variabler är OK, men lokala QA-variabler blir bara NIL. Gör jag något fel eller varför funkar det inte?
Jag har en liten kodsnutt nedan som visar problemet.
Code: Select all
function QuickApp:onInit()
self:debug("onInit")
self.tempSensorID = tonumber(self:getVariable("Temp_Sensor_ID"))
self.valveSwitchID = tonumber(self:getVariable("Valve_Switch_ID"))
self.localCloud = fibaro.getGlobalVariable("cloudValue")
setInterval(
function()
self:main()
end,
1000 * 60
)
self:main()
end
function QuickApp:main()
self:debug("Function main har startat")
print("A ",self.tempSensorID)
print("B ",self.valveSwitchID)
print("C ",self.localCloud)
A nil
B nil
C 96.1
och debuggen visar...
[27.02.2021] [16:44:52] |[31;1mERROR[0m|: QuickApp crashed: fibaroapiHC3.lua:364: Wrong parameter type, number required. Provided param 'nil' is type of nil
fibaroapiHC3.lua:364: Wrong parameter type, number required. Provided param 'nil' is type of nil
stack traceback:
fibaroapiHC3.lua:5604: in function <fibaroapiHC3.lua:5602>
[C]: in function 'error'
fibaroapiHC3.lua:275: in function '__assert_type'
fibaroapiHC3.lua:295: in function '__fibaro_get_device_property'
fibaroapiHC3.lua:364: in function 'get'
fibaroapiHC3.lua:368: in function 'getValue'
...tudio\myprograms\HC3\Bevattningsautomatik Cloud 2021.lua:49: in function 'main'
...tudio\myprograms\HC3\Bevattningsautomatik Cloud 2021.lua:23: in function 'onInit'
fibaroapiHC3.lua in function '__init'
fibaroapiHC3.lua in function 'QuickApp'
fibaroapiHC3.lua in function 'start'
fibaroapiHC3.lua:5598: in function 'fun'
fibaroapiHC3.lua in function <fibaroapiHC3.lua:1095>
[C]: in function 'xpcall'
fibaroapiHC3.lua:5601: in function 'startUp'
fibaroapiHC3.lua:5625: in main chunk
[C]: in function 'dofile'
...tudio\myprograms\HC3\Bevattningsautomatik Cloud 2021.lua:7: in function <...tudio\myprograms\HC3\Bevattningsautomatik Cloud 2021.lua:1>
...tudio\myprograms\HC3\Bevattningsautomatik Cloud 2021.lua:138: in main chunk
Program completed in 0.45 seconds (pid: 14008).