View unanswered posts | View active topics It is currently Tue May 21, 2013 9:18 pm



Reply to topic  [ 5 posts ] 
 get StateOnServer 
Author Message

Joined: Feb 26, 2009
Posts: 7
Location: Switzerland
Post get StateOnServer
Hello

if there a Way to get the State of a plugin Device???

I try to write a plugin to control my Nuvo Essentia.
I need to get the State "zoneOnOff" of my Device to Toggle Power On and Off
or if there another way to do toggle my deviceState "zoneOnOff

my Problem --->
---> if StateOnServer((key="zoneOnOff") = True):
MESSAGE = MESSAGEZoneStart + zone + "OFF" + MESSAGEEnd
self.sendUDP(MESSAGE, dev, logMessage)
dev.updateStateOnServer(key="zoneOnOff", value=False)
else:
MESSAGE = MESSAGEZoneStart + zone + "ON" + MESSAGEEnd
self.sendUDP(MESSAGE, dev, logMessage)
dev.updateStateOnServer(key="zoneOnOff", value=True)

pleas help me, i use indigo a long time but plugin programming and Python is new for me...
English is not my native language --> sorry :cry:


Sun Jan 29, 2012 12:39 pm
Profile WWW
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6655
Location: Austin, Texas
Post Re: get StateOnServer
You get the states when you get the device object from the server:

Code: Select all
# Get the opposite boolean value of zoneOnOff's current value
newValue = not dev.states["zoneOnOff"]
# Create the appropriate message - ON if true OFF if false
if newValue:
    MESSAGE = MESSAGEZoneStart + zone + "ON" + MESSAGEEnd
else:
    MESSAGE = MESSAGEZoneStart + zone + "OFF" + MESSAGEEnd
# Send the message
self.sendUDP(MESSAGE, dev, logMessage)
# Update the state
dev.updateStateOnServer(key="zoneOnOff", value=newValue)


If the dev object is old and may not contain up-to-date values, use dev.refreshFromServer() to get it updated.

_________________
Jay (Indigo Support)
Image


Sun Jan 29, 2012 1:31 pm
Profile WWW

Joined: Feb 26, 2009
Posts: 7
Location: Switzerland
Post Re: get StateOnServer
woooow thx for very fast Answer

why i try a lot of hour before i write here for Help :?


Sun Jan 29, 2012 4:02 pm
Profile WWW

Joined: Feb 26, 2009
Posts: 7
Location: Switzerland
Post Re: get StateOnServer
next problem--

is it possible to updateStateOnServer(key='zoneMute', value=True) in all my devices from same plugin

thx for help


Tue Jan 31, 2012 3:58 pm
Profile WWW
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6655
Location: Austin, Texas
Post Re: get StateOnServer
Sure - something like this:

Code: Select all
for dev in indigo.devices.iter("self"):
    dev.updateStateOnServer(key='zoneMute', value=True)


The docs about built-in objects describe iterators.

_________________
Jay (Indigo Support)
Image


Tue Jan 31, 2012 4:29 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: Bing [Bot] and 0 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.