Get device list from DB

Posted on
Mon Jul 11, 2016 3:18 pm
jh71283 offline
Posts: 127
Joined: Jun 16, 2014

Get device list from DB

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?

Posted on
Mon Jul 11, 2016 3:39 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Get device list from DB

check out the indigo utilities plugin: http://forums.indigodomo.com/viewforum.php?f=184

Code 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

Posted on
Mon Jul 11, 2016 3:42 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Get device list from DB

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.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jul 13, 2016 2:00 pm
jh71283 offline
Posts: 127
Joined: Jun 16, 2014

Re: Get device list from DB

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?

Posted on
Wed Jul 13, 2016 2:38 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Get device list from DB

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.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jul 13, 2016 6:00 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Get device list from DB

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

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest