Lil help converting this:
- Code: Select all
set value of variable "wsTemp_Out" to (value of variable "wsTemp_Out" as integer)
to python?
Thanks,
Carl
set value of variable "wsTemp_Out" to (value of variable "wsTemp_Out" as integer)
ckeyes888 wrote:
- Code: Select all
set value of variable "wsTemp_Out" to (value of variable "wsTemp_Out" as integer)
wsTempOut = indigo.variables[123456]
# Getting the integer value
intValue = wsTempOut.getValue(int) # 0 if it can't be converted
intValue = wsTempOut.getValue(int, default=10) # 10 if it can't be converted
indigo.variable.updateValue(123456, value=intValue)
whmoorejr wrote:However, I think a variable is always a string. You can convert it to a integer to use somewhere else in a phthon code, but I don't think you can save it back as an indigo variable that way.... but not sure.
indigo.variable.updateValue(123456, value=str(intValue))
ckeyes888 wrote:Hey,
Lil help converting this:
- Code: Select all
set value of variable "wsTemp_Out" to (value of variable "wsTemp_Out" as integer)
to python?
rszmetro wrote:Hi,
I'm upgrading from 7.1 to the latest version and need to convert Applescripts to Python scripts. I've never done this before and an example would help me understand. Hers is an AppleScript I need to convert.
----------
-- Update Upstairs Temperature
tell application "IndigoServer"
set myThermoDev to device "Thermostat - A/C"
set tempList to temperatures of myThermoDev
set TempUpStairs to first item of tempList as real
set value of variable "tempUpstairs" to first item of tempList as real
end tell
----------
Thanks!
Rob Z
-- Update Upstairs Temperature
tell application "IndigoServer"
set myThermoDev to device "Thermostat - A/C"
set tempList to temperatures of myThermoDev
set TempUpStairs to first item of tempList as real
set value of variable "tempUpstairs" to first item of tempList as real
end tell
-- Update Downstairs Temperature
tell application "IndigoServer"
set myThermoDev to device "Thermostat - HEAT"
set tempList to temperatures of myThermoDev
set TempDownStairs to first item of tempList as real
set value of variable "tempDownstairs" to first item of tempList as real
end tell
-- Calculate tempSetDif
tell application "IndigoServer"
if value of variable "runClimateControl" = "Cool" then
set value of variable "tempSetDif" to ((value of variable "tempSet") - (value of variable "tempDownstairs"))
else if value of variable "runClimateControl" = "Heat" then
set value of variable "tempSetDif" to ((value of variable "tempSet") - (value of variable "tempUpstairs"))
end if
end tell
-- Calculate tempSetBal NEW 3/11/13
tell application "IndigoServer"
if value of variable "runClimateControl" = "Cool" then
if value of variable "tempDownstairs" is less than value of variable "tempSet" then
set value of variable "tempSetBal" to ((value of variable "tempUpstairs") + (5))
else if value of variable "tempDownstairs" is greater than value of variable "tempSet" then
set value of variable "tempSetBal" to ((value of variable "tempSet") - (5))
else if value of variable "tempDownstairs" is equal to value of variable "tempSet" then
set value of variable "tempSetBal" to value of variable "tempSet"
end if
else if value of variable "runClimateControl" = "Heat" then
if value of variable "tempUpstairs" is less than value of variable "tempSet" then
set value of variable "tempSetBal" to ((value of variable "tempUpstairs") + 5)
else if value of variable "tempUpstairs" is greater than value of variable "tempSet" then
set value of variable "tempSetBal" to ((value of variable "tempSet") + 1)
else if value of variable "tempUpstairs" is equal to value of variable "tempSet" then
set value of variable "tempSetBal" to value of variable "tempSet"
end if
end if
end tell
# Update Upstairs Temperature
myThermoDev = indigo.devices["Thermostat - A/C"]
temp = float(dev.states["Temperature"])
indigo.variable.updateValue("tempUpstairs", str(temp))
## or
indigo.variable.updateValue("tempUpstairs", str(indigo.devices["Thermostat - A/C"].states["Temperature"]))
# Update Downstairs Temperature
myThermoDev = indigo.devices["Thermostat - HEAT"]
temp = float(dev.states["Temperature"])
indigo.variable.updateValue("tempDownstairs", str(temp))
# Calculate tempSetDif
if indigo.variable["runClimateControl"].value == "Cool":
indigo.variable.updateValue( "tempSetDif", str( float(indigo.variable["tempSet"].value) - float(indigo.variable["tempDownstairs"].value)) )
elif indigo.variable["runClimateControl"].value == "Heat":
indigo.variable.updateValue( "tempSetDif", str( float(indigo.variable["tempSet"].value) - float(indigo.variable["tempUpstairs"].value)) )
# Calculate tempSetBal NEW 3/11/13
if indigo.variable["runClimateControl"].value == "Cool":
if float(indigo.variable["tempDownstairs"].value) < float(indigo.variable["tempSet"].value):
indigo.variable.updateValue( "tempSetBal", str( float(indigo.variable["tempUpstairs"].value) + 5 ) )
elif float(indigo.variable["tempDownstairs"].value) > float(indigo.variable["tempSet"].value):
indigo.variable.updateValue( "tempSetBal", str( float(indigo.variable["tempSet"].value) - 5 ) )
else:
indigo.variable.updateValue( "tempSetBal", indigo.variable["tempSet"].value )
elif indigo.variable["runClimateControl"].value == "Heat":
if float(indigo.variable["tempUpstairs"].value) < float(indigo.variable["tempSet"].value):
indigo.variable.updateValue( "tempSetBal", str( float(indigo.variable["tempUpstairs"].value) + 5 ) )
elif float(indigo.variable["tempUpstairs"].value) > float(indigo.variable["tempSet"].value):
indigo.variable.updateValue( "tempSetBal", str( float(indigo.variable["tempSet"].value) +1 ) )
else:
indigo.variable.updateValue( "tempSetBal", indigo.variable["tempSet"].value )
rszmetro wrote:Thanks! I think the right side of the scripts are cut off?
Rob
Users browsing this forum: No registered users and 0 guests