Some times we have to use idx instead of DeviceName in scripts. (commandArray['UpdateDevice']..)
But when you change a device the idx change, then you msut to check every script.... and that's no good for mental health
So I wonder if is there any way to get the IDX using the name of devices, in lua at least
(Now I'm tring to set the mode for a thermostat and the only way is UpdateDevice)
Thanks
Last edited by juankar on Thursday 19 May 2016 11:33, edited 1 time in total.
Nightmares or not; there currently is a lua object/array available named "otherdevices_idx" which can be used to map device names to device ids. I'm not sure when this was added though, so it might only be available in beta for now.
Use it like this: otherdevices_idx["Bathroom Light"]
Mac mini w/ ESXi running Ubuntu w/ Domoticz custombuild, SolarEdge 3500Wp, S0 Meter, P1 Smart Meter, RFXtrx433e, Aeotec Z-Stick Gen5
I must be blind !!!
I read the wiki pages and I ddidn't see anything about this table passed to lua, but now (after reading this post) I've seen all info is in wiki Events page
Well but I've learned two things:
1. I must read all and every Word in wiki,
2. I've added a sqlite3 to lua and now I know how to acces domoticz database
juankar wrote:Well but I've learned two things:
1. I must read all and every Word in wiki,
2. I've added a sqlite3 to lua and now I know how to acces domoticz database
We can learn from mistakes !
That's what's great about this forum, none of us are as smart as all of us.
Now you are smarter, it would great if could you add some guidance on using sqlite3 and accessing the database in Lua to the Wiki.
It's made me think that SQL is well documented and if the database structure is well documented, then this might be a way of getting very flexible access to the data that Domoticz holds from Lua, without having to construct another framework. The obvious catch is that writing to the database allows the possiblity of breaking it.