Hello
Is it posible to renumber nodes?.
I excluded and include some devices and the node numbers are not consecutive (1,2,3,9,10...) and I would like to get succesive numbres for nodes (1,2,3,4,5...), is ther any way to get succesive numbres for nodes?
Thanks
Node number
Moderator: leecollings
- gizmocuz
- Posts: 2492
- Joined: Thursday 11 July 2013 18:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Top of the world
- Contact:
Re: Node number
The only way is to exclude all your nodes, hard reset the controller, and include them again
but why care? it is just a number
but why care? it is just a number
Quality outlives Quantity!
-
- Posts: 221
- Joined: Saturday 30 August 2014 20:20
- Target OS: Linux
- Domoticz version: 4.
- Location: Spain
- Contact:
Re: Node number
Yes, it's justa anumber.... but an important number if you use it in scripts. Suppose you have several scripts working with a node number if this number change it's necessay to change it in all scripts...
Thanks
Thanks
- jvdz
- Posts: 2269
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Node number
You are talking about the device IDX, not the Zwave unit number ...right?
IDX numbers are indeed used by JSON calls unless you use the DeviceName like LUA does to find the proper device.
Not sure whether you can change the IDX easily as that is an index field in the Database so potentially links to data in other tables already.
Jos
IDX numbers are indeed used by JSON calls unless you use the DeviceName like LUA does to find the proper device.
Not sure whether you can change the IDX easily as that is an index field in the Database so potentially links to data in other tables already.
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 4
- Joined: Monday 21 July 2014 20:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Node number
If you're using LUA then it's not too difficult to convert a device name to either a Domoticz IDX or a Z-Wave node number using a json call such as below - this will return you all of the data for each device. You can then use the JSON library to convert this returned data to an LUA table and pull out the data you want by looking for the matching "Name" node. You can also use this technique for getting at lots of other data such as battery level.
Note: JSON library is available here: http://regex.info/blog/lua/json
e.g. to get the Domoticz IDX
or to get the Z-Wave node number, use the following where <nn> is the Domoticz IDX of your Z-Wave controller)
The <nn> value itself can also be retrieved from the name of the Z-Wave controller in the same way if needed.
Note: JSON library is available here: http://regex.info/blog/lua/json
e.g. to get the Domoticz IDX
Code: Select all
-- Get the data
local html = http.request("http://<ip_address>:<port>/json.htm?type=devices&filter=all&used=true")
-- Decode the JSON formatted string to a Lua table
local tbl = JSON:decode(html)
-- Now process the table as you wish
Code: Select all
http://<ip_address>:<port>/json.htm?type=openzwavenodes&idx=<nn>
-
- Posts: 221
- Joined: Saturday 30 August 2014 20:20
- Target OS: Linux
- Domoticz version: 4.
- Location: Spain
- Contact:
Re: Node number
This is a very useful answer.
I suspect JSON is very useful, but I can't find too much info about how to use it in Domoticz
I suspect JSON is very useful, but I can't find too much info about how to use it in Domoticz

-
- Posts: 4
- Joined: Monday 21 July 2014 20:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Node number
I'm still learning LUA myself, but this is an example of what I've come up with. It's a function that lets you return the value of any parameter from any device. I don't know if it's the most efficient way, but the only other code I've seen involves writing to a temporary file, which can cause problems with permissions and also does a lot of writing to your sd card which is generally held to be a bad thing.
I have the two variables DomoticzIP and DomoticzPort set to the appropriate values as they are used all over the place in my code - you will need to set them correctly for your own system or just replace them with the correct values.
You may also need to include the http sockets library with "http = require('socket.http')" at the top. It's a while since I did this, but I think I found it in this post: http://www.domoticz.com/forum/viewtopic ... 638#p22638
As an example of usage, to get the Domoticz IDX for a device named "Hall_PIR" do this:
You can use the same principle to get info on your Z-Wave devices by using the other url I posted earlier.
I've found it very useful to actually see the data that these calls return. If you start a terminal/console session to your Raspberry PI and type the url using curl you'll get the data returned to the console. For example (change the ip address/port for your system):
Hope that helps.
Code: Select all
function getDeviceValue(sDeviceName, sDeviceParameter)
local html = http.request("http://" .. DomoticzIP .. ":" .. DomoticzPort .. "/json.htm?type=devices&filter=all&used=true")
-- Decode the JSON formatted string to a Lua table
local tbl = JSON:decode(html)
-- Loop through the device data looking for the device name
for _, value in pairs(tbl["result"]) do
if value["Name"] == sDeviceName then
return value[sDeviceParameter]
end
end
return nil
end
You may also need to include the http sockets library with "http = require('socket.http')" at the top. It's a while since I did this, but I think I found it in this post: http://www.domoticz.com/forum/viewtopic ... 638#p22638
As an example of usage, to get the Domoticz IDX for a device named "Hall_PIR" do this:
Code: Select all
local idx = getDeviceValue('Hall_PIR', 'idx')
I've found it very useful to actually see the data that these calls return. If you start a terminal/console session to your Raspberry PI and type the url using curl you'll get the data returned to the console. For example (change the ip address/port for your system):
Code: Select all
curl "http://192.168.1.12:8080/json.htm?type=devices&filter=all&used=true"
Who is online
Users browsing this forum: No registered users and 1 guest