Page 1 of 1
Get device list from DB
Posted:
Mon Jul 11, 2016 3:18 pm
by jh71283
Looking at the database that SQL Logger has produced, I can see the history table for each device / variable, but I can't see any table that describes the devices.
I am trying to create a Web-UI to show graphs etc of the data from indigo, but I need to be able to get device names.
Can anybody suggest anything?
Re: Get device list from DB
Posted:
Mon Jul 11, 2016 3:39 pm
by kw123
check out the indigo utilities plugin:
http://forums.indigodomo.com/viewforum.php?f=184Code is in there to
- get the devices / states -- from the indigo DB not SQL. first get the names / ids from the indigo db then do the sql db query
- print a report with filter for 1..6 ..all states
- list for each devices / variable the number of entries in the SQL-DB
- make a backup
- compress the DB
- ...
Karl
Re: Get device list from DB
Posted:
Mon Jul 11, 2016 3:42 pm
by jay (support)
You're probably going to want to use a
Python script because you'll need to map the device name to the ID used in the SQL Logger DB.
Re: Get device list from DB
Posted:
Wed Jul 13, 2016 2:00 pm
by jh71283
Do you mean I would need to use a python script to dump out the device names and IDs to a table or some other storage, and read it from there?
Re: Get device list from DB
Posted:
Wed Jul 13, 2016 2:38 pm
by jay (support)
Correct. Or, you could attempt to parse it out of the Indigo database directly (it's a structured XML document). That would probably be more difficult than just using a Python script to dump it. Looks like Karl's plugin would be a good start. Though, the Python script to just dump name/ID would be quite simple.
Re: Get device list from DB
Posted:
Wed Jul 13, 2016 6:00 pm
by kw123
check out the code example in the plugins (eg indigo utilities) and many others how to do it ..
dumb question: you know how to look at the plugin.py code in the plugin bundles?
Karl
very basic example
- Code: Select all
for dev in indigo.devices:
indigo.server.log(unicode(dev.id)+u" "+ dev.name+ u" "+ dev.deviceTypeId)
for state in dev.states:
indigo.server.log( dev.name+u" states "+ state + u" "+ unicode(dev.states[state] ))
for var in indigo.variables:
indigo.server.log(unicode(var.id)+u" "+ var.name+ u" "+var.value)
the SQL tables are:
device_history_deviceID
variable_history_deviceID