Reposting
Hello, I’m trying to Poll a device in a Scene, but I also need to get the result of the poling (Successful, Error, Aborted, WaitingForCallback etc…)
I’v tried 2 different approach without success, my first try:…
local zErrNbr = 0
local zErrMsg = ""
local zJobNbr = 0
local zArgumt = {}
local zDevice = 39
local zJobSta = 0
local zJobMsg = ""
zErrNbr, zErrMsg, zJobNbr, zArgumt = luup.call_action("urn:micasaverde-com:serviceId:HaDevice1","Poll",{},zDevice)
print (zErrNbr)
print (zErrMsg)
print (zJobNbr)
print (zArgumt)
zJobSta, zJobMsg = luup.job.status(zJobNbr, zDevice)
print (zJobSta)
print (zJobMsg)
…this code below always returns me the code 1 (Polling node ie.: polling in progress I guess)
[tt]
zErrNbr = 0
zErrMsg = “”
zJobNbr = 578
zArgumt = table: 0x1a9cdb0
zJobSta = 1
zJobMsg = “Polling node”
[/tt]
I also tried to add a few “sleep” and call the [tt]luup.job.status(zJobNbr, zDevice)[/tt] a few times but always the code 1.
So I then tried the following:
local zErrNbr = 0
local zErrMsg = ""
local zJobNbr = 0
local zArgumt = {}
local zDevice = 39
local zJobSta = 0
local zJobMsg = ""
local zluljob = {}
function zJobStatus(zluljob)
print ("device #" .. zluljob.device_num)
print ("status " .. zluljob.status)
print ("name " .. zluljob.name)
print ("type " .. zluljob.type)
print ("notes " .. zluljob.notes)
end
luup.job_watch("zJobStatus")
zErrNbr, zErrMsg, zJobNbr, zArgumt = luup.call_action("urn:micasaverde-com:serviceId:HaDevice1","Poll",{},zDevice)
print (zErrNbr)
print (zErrMsg)
print (zJobNbr)
print (zArgumt)
but I get a Runtime error: Line 18: attempt to call field ‘job_watch’ (a nil value) which is the line for LUUP_JOB_WATCH
I also tried to call the function like this luup.job_watch(“zJobStatus”,zDevice) but I got the same error.
Anyone has any idea? is what I’m attempting even feasible? if yes, any help would be appreciated
Thx
Claude
PS.: I’m doing this because I have 2 devices (1 thermostat and 1 heat-pump switch) that sometimes “lose” communication with my vera, and I then have to manually reset the devices… so I am trying to setup a scene that will run every few hours or so, and will attempts to poll these 2 devices, and if the poll fails, then I will send me an Alert on my phone So that I go check the devices with my own eyes and reset the breaker if necessary)