View unanswered posts | View active topics It is currently Tue May 21, 2013 8:24 am



Reply to topic  [ 5 posts ] 
 Plugin: Waiting for Device Status update 
Author Message

Joined: Mar 16, 2010
Posts: 4
Post 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.


Sun Mar 21, 2010 8:03 pm
Profile

Joined: Mar 19, 2008
Posts: 496
Location: Saratoga, CA
Post 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.


Mon Mar 22, 2010 7:15 am
Profile

Joined: Mar 19, 2008
Posts: 496
Location: Saratoga, CA
Post 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...


Mon Mar 22, 2010 7:54 am
Profile

Joined: Mar 16, 2010
Posts: 4
Post 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.


Fri Apr 02, 2010 2:10 pm
Profile

Joined: Mar 19, 2008
Posts: 496
Location: Saratoga, CA
Post 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!


Fri Apr 02, 2010 5:45 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.