SQL Logging and Custom Device Plugin

Forum rules

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo

Posted on
Sat May 28, 2011 1:45 pm
jamus offline
Posts: 179
Joined: Dec 01, 2007

SQL Logging and Custom Device Plugin

I'm working on a custom device plugin.

Is it somehow possible to log the states via SQL? I don't my states in the SQL database, even though it's updating in the GUI.

Posted on
Sat May 28, 2011 2:18 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: SQL Logging and Custom Device Plugin

You can subscribe to all device changes with indigo.devices.subscribeToChanges(), described here and here, which will have the server forward all device changes to your plugin by calling the following methods in your plugin (if you define them): deviceCreated, deviceUpdated, deviceDeleted.

The same holds true for triggers and variables, and will work for schedules and action groups once we finish those (by GM).

Just call the appropriate indigo.*.subscribeToChanges() in the startup() method of your plugin and you'll begin receiving those messages.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat May 28, 2011 2:39 pm
jamus offline
Posts: 179
Joined: Dec 01, 2007

Re: SQL Logging and Custom Device Plugin

jay wrote:
You can subscribe to all device changes with indigo.devices.subscribeToChanges(), described here and here, which will have the server forward all device changes to your plugin by calling the following methods in your plugin (if you define them): deviceCreated, deviceUpdated, deviceDeleted.

The same holds true for triggers and variables, and will work for schedules and action groups once we finish those (by GM).

Just call the appropriate indigo.*.subscribeToChanges() in the startup() method of your plugin and you'll begin receiving those messages.


The second link says I don't have permissions, but it looks like that link is for 5.1 documentation?

In any case, I don't think I explained my issue clearly.

My custom device has a few states (volts, current kilowatts, etc). My plugin is updating the state in the GUI just fine, but I'd also like to update the SQL database with the new states.

Edit: Maybe I should also ask this: Is it the plugin's or Indigo's responsibility to log the data to the SQL database? If it's my responsibility, how do I go about doing it (use Indigo's API or use Python's sqlite3 API)

Posted on
Sat May 28, 2011 3:17 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: SQL Logging and Custom Device Plugin

Sorry, fixed the link.

And yes, I did misread your post. Our SQL logger will eventually get plugin defined device state changes into the DB. Our intention all along has been to rewrite the logger as a plugin - if we don't get it done by GM it will be done very soon after.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Jun 17, 2011 12:11 pm
bschollnick2 offline
Posts: 1355
Joined: Oct 17, 2004
Location: Rochester, Ny

Re: SQL Logging and Custom Device Plugin

jay wrote:
You can subscribe to all device changes with indigo.devices.subscribeToChanges(), described here and here, which will have the server forward all device changes to your plugin by calling the following methods in your plugin (if you define them): deviceCreated, deviceUpdated, deviceDeleted.

The same holds true for triggers and variables, and will work for schedules and action groups once we finish those (by GM).

Just call the appropriate indigo.*.subscribeToChanges() in the startup() method of your plugin and you'll begin receiving those messages.


Jay,

Is there a way for the subscribeToChanges() function allow you to filter, or specifically choose a single (or class of) devices?

------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG

Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu

Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33

Posted on
Fri Jun 17, 2011 1:21 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: SQL Logging and Custom Device Plugin

Not currently - you'll need to implement the filtering in your plugin code.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests