Page 1 of 1

Convert to Python

PostPosted: Wed Aug 26, 2020 7:34 am
by ckeyes888
Appreciate any help with this one. Not sure about the "contains" part.

Code: Select all
tell application "IndigoServer"
   set theText to value of variable "Weather_Icon"
   if theText contains "Clear" then
      set the value of variable "Weather_Icon" to "Moon"
   else if theText contains "Cloudy" and theText contains "Mostly" then
      set the value of variable "Weather_Icon" to "Moon_Mostly"
end if
end tell


Thanks,

Carl

Re: Convert to Python

PostPosted: Wed Aug 26, 2020 9:27 am
by jay (support)
The in operator will probably do:

Code: Select all
theText = indigo.variable[ID_OF_Weather_Icon].value
if "Clear" in theText:
    indigo.variable.updateValue(ID_OF_Weather_Icon, value="Moon")
elif "Cloudy" in theText and "Mostly" in theText:
    indigo.variable.updateValue(ID_OF_Weather_Icon, value="Moon_Mostly")

Re: Convert to Python

PostPosted: Wed Aug 26, 2020 3:09 pm
by ckeyes888
Thanks Jay. Works great.

Carl