Question on persistence

Posted on
Wed Aug 21, 2013 11:57 pm
rhanson offline
Posts: 192
Joined: Apr 30, 2013

Question on persistence

So if I understand this right, if I want a plugin store data and have that available across sessions, it should be part of pluginprops? Is there a way to tap into the SQLogger to store info in the database? Or is there any other mechanism to store data that doesn't really belong in pluginprops?

One plugin basically extends the IOM to add properties that aren't there. This way, I can store extra info like time stamps, the reason a trigger was fired (by me), etc. and still access native IOM props. These properties aren't anything that the user should know about, they are only there for internal use. But they need to persist across plugin restarts, server restarts, etc. And, they need to be accessible by other plugins. The SQLogger is a clean place to put it, but I don't really want to start polluting that, and that's not what it's for. This pile of data might be large, as it depends on the number of devices. Is that something that should be stuffed into pluginprops anyway?

In most of the plugin code I've looked at, they basically initialize themselves by asking relevant info from the device itself, or the configui data, and they don't really need info created in previous sessions to persist.

Posted on
Thu Aug 22, 2013 9:42 am
jay (support) offline
Site Admin
User avatar
Posts: 18221
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Question on persistence

I wouldn't use the SQL Logger's db - primarily because it might not be where you expect it (or even present if they don't have it enabled).

If you're storing a lot of data then you could just create your own file (SQLite or otherwise) and store it somewhere. You can get the path to the server installation folder by calling the indigo.server.getInstallFolderPath() method. Then write your db file into the Preferences/Plugins directory in there. When a new version of Indigo comes out the installer moves that whole folder over so the user won't have to move it manually or repoint your plugin to it.

If the data is device specific, then store it in the device's props. Then, other plugins can read (only) those props by getting the source plugin's props from the device:

Code: Select all
otherPluginProps = device.globalProps["your.other.plugins.id"]


Note that only the source plugin can write to those props, so if you need multiple plugins writing to them then you'll need to use your own data store.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 7 guests

cron