Uniqueness of IOM objects

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
Tue Jun 14, 2011 12:23 am
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Uniqueness of IOM objects

If I retrieve a variable repeatedly, I seem to get distinct Python objects that know nothing about each other or the server state. I can call replaceOnServer() to "push" state changes to the server, but I don't offhand see a way to "pull" (update) state from the server into an existing object, nor a way to get notified of server state changes to know to update my plugin state accordingly:
Code: Select all
Connected to Indigo Server 5.0.0 b5 (localhost:1176)
>>> v=indigo.variable.create("test", value="old")
>>> v1=indigo.variables[v.id]
>>> v1==v
False
>>> v.value
u'old'
>>> v1.value
u'old'
>>> v.value = "new"
>>> v.replaceOnServer()
>>> v1.value
u'old'
>>> v1.replaceOnServer()
>>> v.value
u'new'

How do you suggest we handle this? It seems to make it difficult to keep and track server state in a plugin. If I want a single Python IOM object to track server state as it evolves, how would I go about doing that?

Thanks
-- perry

Posted on
Tue Jun 14, 2011 6:33 am
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Uniqueness of IOM objects

Code: Select all
v.refreshFromServer()


refreshFromServer() works on any of the server IOM objects. It's in various example sections but it appears I've yet to add it to the method lists - I'll get it added today.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jun 14, 2011 10:52 am
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: Uniqueness of IOM objects

refreshFromServer() works on any of the server IOM objects. It's in various example sections but it appears I've yet to add it to the method lists - I'll get it added today.


Good. So is there a Pythonic way to get notified when an existing IOM object's server state has changed? Or do I need to set up temporary triggers for each of these cases (and clean them up, and recover from problems, etc.)? This really is begging for a facility that does not require database changes to work...

Cheers
-- perry

Posted on
Fri Jun 17, 2011 1:31 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Uniqueness of IOM objects

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. You can also call the same method on the triggers and variables lists if you want to be notified of changes to them.

Image

Posted on
Fri Jun 17, 2011 2:37 pm
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: Uniqueness of IOM objects

support 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. You can also call the same method on the triggers and variables lists if you want to be notified of changes to them.


Excellent; just what I was looking for. And I understand the associated performance issues.

Thanks
-- perry

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests

cron