Page 1 of 1

[Zwave nodes] Get status / Last seen

Posted: Monday 27 April 2015 10:12
by LiPeR
Hello all :)

I'm looking to get infos from the hardware controller to a LUA script or json
Image
Is there a way ?

Maybe a API from the OZW ?

Thanks in advance :D

Re: [Zwave nodes] Get status / Last seen

Posted: Monday 27 April 2015 12:20
by gizmocuz
What is it exactly what you want?
If you want to get the data as displayed in the table, you can use the json call.
(see the hardware html page)

Re: [Zwave nodes] Get status / Last seen

Posted: Monday 27 April 2015 15:33
by LiPeR
Hello gizmocuz

I didn't found this page on wiki nor the PDF, can you give me the link ?

EDIT : The goal is to send a mail when a device is dead

Thanks :)

Re: [Zwave nodes] Get status / Last seen

Posted: Friday 12 June 2015 8:20
by teekilpi
I was looking for the same thing. What I discovered:

For zwave devices, you actually see two different "last seen" timestamps. One of them is on the hardware-tab that is shown in first post. It get's information from openzwave and gives you timestamp "when was the last time your device was seen and alive", for example it was polled and it responded. The other "last seen" is on other tabs, for example switches-tab, where your device is shown. What it tells you, seems to be "last time your device state was updated". For example switch was switched from off to on or vice versa.

On lua scripts, you have "otherdevices_lastupdated" that refers to the "last time your device state was updated". That is usable in the garage door example. If you wan't to know if wave-device is alive, i.e. powered and on range (but state not changed), you need access to the zwave node information. I couldn't find a place to get that directly in lua.

However, you can get that information through json-interface. If you do something like this:

Code: Select all

wget -qO - 'http://localhost:8080/json.htm?type=openzwavenodes&idx=2'
(where idx=2 is you zwave-hardwareid), you get all the information that is seen on the zwave-hardware tab, including the real "Last seen", Status (Dead, Awake, Sleeping etc). From there you can drill to any information you need.

What I would eventually like to see is something like otherdevices_zwavenodeinfo -function in lua, that would return that information for given node. Using json-interface is a dirty trick, but it works.

Here is simple model to get the idea, using json library and wget:

Code: Select all

commandArray = {}

json = require("json")
local handle
local nodes
local n
local node
local lastseen
local state

handle = io.popen("wget -qO - 'http://localhost:8080/json.htm?type=openzwavenodes&idx=2'")
nodes =  json.decode(handle:read("*a"))
handle:close()

nodes = nodes['result']
for n=1,#nodes do
	node=nodes[n]
-- Here you get access to all nodes one by one
-- node['NodeID'] tells you zwave id and
-- node['LastUpdate'] and node['State'] tells you state of device and last seen information

-- do whatever you want
end

Hope this helps.

Re: [Zwave nodes] Get status / Last seen

Posted: Monday 29 June 2015 7:31
by spudgunman
I just get errors for

JSON:decode must be called in method format...?

Re: [Zwave nodes] Get status / Last seen

Posted: Thursday 13 October 2016 17:43
by tequila
While the above does work, the LastUpdate is way off from what is reported in OZW control panel as LastHeard, which seems to be more accurate to determine whether a node is dead or not. LastUpdate may not change for days or weeks while the node is still working normally.

Any idea how to get the LastHeard value? I tried numerous things but with no success.