Page 1 of 1
IDX in LUA
Posted: Saturday 11 April 2015 11:35
by maxtrash
help help
I think I stumbled upon this in the past, but I would really like to have the idx of a device available in LUA. In LUA there's only the device name and there seems no easy way to link the two. Can it please be added?
Re: IDX in LUA
Posted: Saturday 11 April 2015 12:48
by tlpeter
Why do you need the idx?
When you remove a device and add it again then the idx is changed while you can give it the same name?
This will save you changing all the scripts.
Re: IDX in LUA
Posted: Saturday 11 April 2015 13:00
by maxtrash
I would like to send out the idx using openurl. After that something else can respond with json
(/json.htm?type=devices&rid=1)
Json requires idx and not the device name.
I think I've got another solution though. I can use /json.htm?type=devices&filter=all&used=true&order=name which will give back all statusses of all devices. There I can filter out the result with the specific device name after which I also have alll attributes (including idx)
Re: IDX in LUA
Posted: Saturday 11 April 2015 13:29
by simonrg
If you have a look at the check battery level script on the Wiki, here device names are used to retrieve the device idxs:
http://www.domoticz.com/wiki/Battery_level_check
It is also used extensively in the integration of Telegram for remote control of Domoticz:
http://www.domoticz.com/forum/viewtopic ... 500#p39741
Re: IDX in LUA
Posted: Sunday 12 April 2015 12:49
by ThinkPad
See also this script where a idx is used to fill a device with information:
http://domoticz.com/forum/viewtopic.php ... 787#p39762
Re: IDX in LUA
Posted: Thursday 16 April 2015 22:59
by maxtrash
Like I said I was able to solve the issue in node-red.
http://www.domoticz.com/forum/viewtopic ... 120#p40212
It's basically using the same techniques, maybe a bit more elegantly.After a device has changed I am able to produce a message like this which contains all information available (including Idx) so that's nice
Code: Select all
/domoticz/out/json {"5MinuteHistoryDays":1,"ActTime":1429217810,"AllowWidgetOrdering":true,"DashboardType":0,"Latitude":"51.573735","Longitude":"5.089093","MobileType":0,"ServerTime":"Apr 16 2015 22:56:50","Sunrise":"06:43:00","Sunset":"20:35:00","TempScale":1,"TempSign":"C","WindScale":1,"WindSign":"m/s","dontcachehtml":true,"result":{"AddjMulti":1,"AddjMulti2":1,"AddjValue":0,"AddjValue2":0,"BatteryLevel":100,"CustomImage":0,"Data":"17.2 C, 50 %","DewPoint":"6.68","Favorite":1,"HardwareID":1,"HardwareName":"Rfxcom","HaveTimeout":false,"Humidity":50,"HumidityStatus":"Comfortable","ID":"400E","LastUpdate":"2015-04-16 22:56:49","Name":"TX320 Hal","Notifications":"false","PlanID":"0","Protected":false,"ShowNotifications":true,"SignalLevel":6,"SubType":"Cresta, TFA TS34C","Temp":17.2,"Timers":"false","Type":"Temp + Humidity","TypeImg":"temperature","Unit":2,"Used":1,"XOffset":"0","YOffset":"0","idx":"106"},"status":"OK","title":"Devices"}
now I can do anything I want with it
Re: IDX in LUA
Posted: Tuesday 09 February 2016 19:15
by Toni
I just created a pull request to address this:
https://github.com/domoticz/domoticz/pull/457
Re: IDX in LUA
Posted: Wednesday 10 February 2016 21:36
by remb0
thanks Toni