IDX in LUA Topic is solved

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Post Reply
maxtrash
Posts: 106
Joined: Tuesday 06 August 2013 1:31
Target OS: -
Domoticz version:
Contact:

IDX in LUA

Post 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?
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: IDX in LUA

Post 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.
maxtrash
Posts: 106
Joined: Tuesday 06 August 2013 1:31
Target OS: -
Domoticz version:
Contact:

Re: IDX in LUA

Post 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)
simonrg
Posts: 329
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8807
Location: North East England
Contact:

Re: IDX in LUA

Post 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
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: IDX in LUA

Post 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
I am not active on this forum anymore.
maxtrash
Posts: 106
Joined: Tuesday 06 August 2013 1:31
Target OS: -
Domoticz version:
Contact:

Re: IDX in LUA

Post 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
Toni
Posts: 66
Joined: Monday 20 July 2015 14:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: IDX in LUA

Post by Toni »

I just created a pull request to address this: https://github.com/domoticz/domoticz/pull/457
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: IDX in LUA

Post by remb0 »

thanks Toni
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest