Set Error State not working

Posted on
Mon Mar 27, 2023 6:55 am
racarter offline
User avatar
Posts: 477
Joined: Jun 18, 2016
Location: North Yorkshire, UK

Set Error State not working

I have the following code in a plugin:

Code: Select all
                            if muted:
                                dev.description = "MUTED"
                                dev.replaceOnServer()
                                dev.setErrorStateOnServer("Error")
                            else:
                                dev.description = ""
                                dev.replaceOnServer()
                                dev.setErrorStateOnServer(None)

When the code runs, if muted is True the Notes field shows the word "MUTED" but the device does not turn red or show the "Error" text.

Any suggestions gratefully received!

Posted on
Mon Mar 27, 2023 10:56 am
jay (support) offline
Site Admin
User avatar
Posts: 18221
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Set Error State not working

I'm not seeing that behavior - I wonder if maybe there's a race condition. Try doing the setErrorStateOnServer before doing the replaceOnServer call.

[MODERATOR NOTE]: moved topic to the sdk support forum

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Mar 27, 2023 11:58 am
racarter offline
User avatar
Posts: 477
Joined: Jun 18, 2016
Location: North Yorkshire, UK

Re: Set Error State not working

Same result Jay.

Posted on
Mon Mar 27, 2023 12:02 pm
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Set Error State not working

Shot in the dark -- any chance the device in question is not owned by your plugin?

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Mar 27, 2023 12:03 pm
racarter offline
User avatar
Posts: 477
Joined: Jun 18, 2016
Location: North Yorkshire, UK

Re: Set Error State not working

Definitely mine Dave!

Posted on
Mon Mar 27, 2023 12:32 pm
jay (support) offline
Site Admin
User avatar
Posts: 18221
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Set Error State not working

Reload the plugin in an interactive shell, get the dev instance, then try to set the error state that way.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Mar 27, 2023 1:06 pm
racarter offline
User avatar
Posts: 477
Joined: Jun 18, 2016
Location: North Yorkshire, UK

Re: Set Error State not working

OK, this is weird.

I've added code to check the device props immediately before and after setting the error state. Before the set statement it shows "errorState: " and after it shows "errorState: Error" as it should, but next time through the code the 'before' check shows errorState blank again - in other words, the set error is not being remembered. My plugin has no other set error statements (I've commented out the error clearing code).

Posted on
Mon Mar 27, 2023 5:37 pm
jay (support) offline
Site Admin
User avatar
Posts: 18221
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Set Error State not working

That is very odd. Pretty sure there's something in your plugin that's resetting it. I wonder if that section of code is getting called twice, once with muted True followed by False?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Mar 28, 2023 12:37 am
racarter offline
User avatar
Posts: 477
Joined: Jun 18, 2016
Location: North Yorkshire, UK

Re: Set Error State not working

The only setErrorStateOnServer statement is the one that sets it to “Error”. There are no others - I have them commented out. Is there any other call which could reset the error state?

Posted on
Tue Mar 28, 2023 2:34 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Set Error State not working

racarter wrote:
The only setErrorStateOnServer statement is the one that sets it to “Error”. There are no others - I have them commented out. Is there any other call which could reset the error state?

Yes, any subsequent device update will reset the error state.

From the documentation for updateStateOnServer(key='keyName', value='Value', clearErrorState=True):
Use this method to update the value of one of your device's states on the server. The server will propagate the change out to any connected clients and fire any triggers that are defined on that state. Pass “true” (default) or “false” on the clearErrorState parameter (not required) to have the error state of the device (set with setErrorStateOnServer above) cleared.

Posted on
Tue Mar 28, 2023 3:08 am
racarter offline
User avatar
Posts: 477
Joined: Jun 18, 2016
Location: North Yorkshire, UK

Re: Set Error State not working

Thanks Jon, I’d read that, but I don’t include the clearErrorState parameter in my updates. Unless Indigo defaults to clearErrorState = True in the absence of a specific declaration?

Posted on
Tue Mar 28, 2023 3:19 am
racarter offline
User avatar
Posts: 477
Joined: Jun 18, 2016
Location: North Yorkshire, UK

Re: Set Error State not working (RESOLVED)

Yep. Turns out you have to explicitly include clearErrorState=False in any device updates to avoid resetting the error state.

Posted on
Tue Mar 28, 2023 4:03 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Set Error State not working (RESOLVED)

racarter wrote:
Yep. Turns out you have to explicitly include clearErrorState=False in any device updates to avoid resetting the error state.

Yes, that's why the docs say ... Pass “true” (default) ... when referring to the clearErrorState parameter. :wink:

Posted on
Tue Mar 28, 2023 10:11 am
jay (support) offline
Site Admin
User avatar
Posts: 18221
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Set Error State not working

Right. The most common use-case is that some error occurs, so an update to a device won't happen again until the error condition is resolved. Obviously, that's just the common use-case, we added the flag so that you could maintain the error state through device updates if you wanted.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 18 guests