Applescript to Python Conversion
Posted: Fri Dec 13, 2019 10:07 am
I Finally found some time to upgrade from 2008 Mac pro to 2018 Mac Mini i7 6 core / Indigo 7.4 so will need to convert Applescripts to Python. Can anyone please help in providing some basic syntax conversion guidance for the following Applescript that is used primarily as differential temperature control for whole house fan / HVAC system:
- Code: Select all
set insideTempVal to value of variable "2251_indoorTemp" as number
if insideTempVal is 32 then
return
end if
-- Set the value of a variable.
-- If the variable doesn't exist, create it.
on stringForHVACMode(inMode)
if (inMode = offMode) then
return "offMode"
else if (inMode = heatOn) then
return "heatOn"
else if (inMode = coolOn) then
return "coolOn"
else if (inMode = heatCoolOn) then
return "heatCoolOn"
else if (inMode = runProgramHeat) then
return "runProgramHeat"
else if (inMode = runProgramCool) then
return "runProgramCool"
else if (inMode = runProgramAuto) then
return "runProgramAuto"
end if
end stringForHVACMode
set ACstate to value of variable "NorthAC" as boolean
set NACstandby to value of variable "NAC_standby" as boolean
set outsideTempVal to value of variable "2251_outdoorTemp" as number
set fanIsOn to on state of device "Whole House Switch"
set windowIsOpen to on state of device "triggerlinc"
set indoorTempHi to value of variable "2251_indoorTempHi" as boolean
if insideTempVal ≤ 73.8 or outsideTempVal - 0.5 > insideTempVal or not windowIsOpen then
if fanIsOn then
turn off "Whole House Switch"
log "1.inside temp lower than outside-fan off"
end if
else if windowIsOpen and insideTempVal > 74 and outsideTempVal + 0 ≤ insideTempVal then
if not fanIsOn then
turn on "Whole House Switch"
log "2.Fan going on"
end if
end if