get StateOnServer

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
Sun Jan 29, 2012 12:39 pm
contrast offline
Posts: 11
Joined: Feb 26, 2009
Location: Switzerland

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:

Posted on
Sun Jan 29, 2012 1:31 pm
jay (support) offline
Site Admin
User avatar
Posts: 18256
Joined: Mar 19, 2008
Location: Austin, Texas

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)
Twitter | Facebook | LinkedIn

Posted on
Sun Jan 29, 2012 4:02 pm
contrast offline
Posts: 11
Joined: Feb 26, 2009
Location: Switzerland

Re: get StateOnServer

woooow thx for very fast Answer

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

Posted on
Tue Jan 31, 2012 3:58 pm
contrast offline
Posts: 11
Joined: Feb 26, 2009
Location: Switzerland

Re: get StateOnServer

next problem--

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

thx for help

Posted on
Tue Jan 31, 2012 4:29 pm
jay (support) offline
Site Admin
User avatar
Posts: 18256
Joined: Mar 19, 2008
Location: Austin, Texas

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)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests