Problem w/setErrorStateOnServer()

Posted on
Thu Sep 12, 2013 3:44 pm
berkinet offline
User avatar
Posts: 3297
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Problem w/setErrorStateOnServer()

I am unable to get setErrorStateOnServer() to work. (see code below). The lines before and after (I had log statements surrounding the command) are executed and its in a try block and Exception path is not followed - so, I know it is being executed. Could it be because I have assigned a custom state in getDeviceDisplayStateId()?

Code: Select all
               if metric in self.apcupsdCap[dev.id]:
                    dev.updateStateOnServer(key=metric, value=value)  # FIRST update the state
                     if metric == 'STATUS' and value == 'COMMLOST' and not self.apcupsdCommError:
                        dev.setErrorStateOnServer(u'x')  # THEN set the state error
                        self.apcupsdCommError = True
                    elif metric == 'STATUS' and value == 'ONLINE' and self.apcupsdCommError:
                        dev.setErrorStateOnServer(None)
                        self.apcupsdCommError = False

Posted on
Thu Sep 12, 2013 3:57 pm
matt (support) offline
Site Admin
User avatar
Posts: 21426
Joined: Jan 27, 2003
Location: Texas

Re: Problem w/setErrorStateOnServer()

Could the problem be that shortly after the setErrorStateOnServer() call there is an updateStateOnServer() call? That will clear the error state. You can prevent updateStateOnServer() from clearing it by passing the optional argument clearErrorState=False.

Image

Posted on
Thu Sep 12, 2013 4:06 pm
berkinet offline
User avatar
Posts: 3297
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Problem w/setErrorStateOnServer()

Yup. The state updates are in a loop. clearErrorState=False solved the problem. Thanks

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests