Plugin: Waiting for Device Status update

Posted on
Sun Mar 21, 2010 8:03 pm
Oliver offline
Posts: 4
Joined: Mar 16, 2010

Plugin: Waiting for Device Status update

Hi,

I am putting together a plugin to control Indigo from the Cisco IP Phone Display using the XML SDK.

Any best practice on how I can ensure commands have been sent and the database updated after I use any of the device control functions ?

For example: cherrypy.server.indigoDb.DeviceTurnOn(cherrypy.server.indigoConn, device, cherrypy.request.remote.ip)
After calling this function, I refresh the webpage, but I still see the "old" values for the device states.
How can I wait with the page generation until the device has (or not) responded and Indigo has updated the database?

best regards,

Oliver.

Posted on
Mon Mar 22, 2010 7:15 am
seanadams offline
Posts: 489
Joined: Mar 19, 2008
Location: Saratoga, CA

Re: Plugin: Waiting for Device Status update

The best solution is to have an asynchronous (ajaxy) interface where you can push device status updates down to the browser at any time - like how Indigo control pages work. Without this, you're not going to see updated device states that result from triggers, scheduled actions, or UI input by other means.

But to answer your question - yes, you could suspend delivery of the web response until you receive the expected status update. This should have a fairly short (eg 5 sec) timeout so the browser isn't hanging around forever in case of an error.

How to implement such a thing depends on how you are designing your client. To do it right you will need a proper event loop, with an async Indigo client and an async http server. I have a general solution for this sort of Indigo client in perl ( http://www.seanadams.com/ha/automogator/ ). Although I haven't tried to collect responses within the handling of an HTTP request as you're describing, it would be feasible.

Posted on
Mon Mar 22, 2010 7:54 am
seanadams offline
Posts: 489
Joined: Mar 19, 2008
Location: Saratoga, CA

Re: Plugin: Waiting for Device Status update

Simpler solutions, such as fetching Restful URLs from Indigo could be done in the context of a cgi script...

Posted on
Fri Apr 02, 2010 2:10 pm
Oliver offline
Posts: 4
Joined: Mar 16, 2010

Re: Plugin: Waiting for Device Status update

Hi Sean,

Thanks for your help! The client on the phone is not very flexible and not really html based but rather xml.

I ended up with the pragmatic solution of just using "delay" of 2 seconds before refreshing the page to the phone.

best regards,

Ollie.

Posted on
Fri Apr 02, 2010 5:45 pm
seanadams offline
Posts: 489
Joined: Mar 19, 2008
Location: Saratoga, CA

Re: Plugin: Waiting for Device Status update

I misunderstood - thought you were writing a separate program to do this and did not realize you were doing this all in the phone. Pretty cool!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests