Page 2 of 2

Re: [SOLVED]iTunes Pause and Speak script

PostPosted: Thu Jan 01, 2015 3:11 pm
by jay (support)
If that's the case, I'm not sure how his script above is working since the access to the state will return a string. The behavior should be that it always executes the script unless th string value is None...

Re: [SOLVED]iTunes Pause and Speak script

PostPosted: Thu Jan 01, 2015 3:30 pm
by achterberg
Sorry to be keeping this going, but the script was working previously and even works with Jay's code suggestion below (== False). I had added the debug logging as suggested by Matt and the only time it fails (doesn't return) is when the plugin returns false (lower case) as in the log: Alert state is false. It seems to work with True and true.

Re: [SOLVED]iTunes Pause and Speak script

PostPosted: Thu Jan 01, 2015 4:17 pm
by DaveL17
achterberg wrote:
Sorry to be keeping this going, but the script was working previously and even works with Jay's code suggestion below (== False). I had added the debug logging as suggested by Matt and the only time it fails (doesn't return) is when the plugin returns false (lower case) as in the log: Alert state is false. It seems to work with True and true.

This actually might be an implementation thing in the (my) code.

Devices.xml:
Code: Select all
         <State
            id = "alertStatus">
            <ValueType>String</ValueType>
            <TriggerLabel>Alert Status</TriggerLabel>
            <ControlPageLabel>Alert Status</ControlPageLabel>
         </State>

plugin.py
Code: Select all
      if not parsed_simplejson['alerts']:
         dev.updateStateOnServer("alertStatus", value = False)
      else:
         dev.updateStateOnServer("alertStatus", value = True)

I'm not sure how Python (or Indigo) is handling this situation behind the scenes. Indigo wants to get a string back from the plugin, but I'm sending a boolean. In my install (development environment and production environment) I get a state of 'false' when there are no alerts.

I will set the values to be strings like Indigo would expect. I'm hesitant to change the device valueType to boolean until it's time to roll out version 1.0.

Dave

Re: [SOLVED]iTunes Pause and Speak script

PostPosted: Thu Jan 01, 2015 4:25 pm
by achterberg
I get both False and false returned at different times in seemingly no particular order, for what it's worth. But this isn't an issue for me as I explained before, this was a learning exercise. So whatever your timeframe is OK by me.


Sent using Tapatalk

Re: [SOLVED]iTunes Pause and Speak script

PostPosted: Thu Jan 01, 2015 5:17 pm
by DaveL17
achterberg wrote:
I get both False and false returned at different times in seemingly no particular order, for what it's worth. But this isn't an issue for me as I explained before, this was a learning exercise. So whatever your timeframe is OK by me.

Thanks. Still good for me to make the code proper.
Dave