View unanswered posts | View active topics It is currently Wed Apr 16, 2014 1:18 am



Reply to topic  [ 2 posts ] 
 Proliphix Script - Need help to finish 
Author Message

Joined: Jan 25, 2006
Posts: 52
Post Proliphix Script - Need help to finish
Folks

Below is a applescript that was posted by a user in the prolophix applescript forum to get a status from the tstat. Is there anyway someone can modify this so that it shows up as a device in the list (for starters)

*******************************
(* Written by Thiefa4 *)

(* AppleScript 1.10.7 code - Feedback is welcome *)

(* Purpose: Pull stats off of a Proliphix NT20e Internet Thermostat*)

---Define needed variables
set ScheduledTemp to "0.0"
set ExitLoop to false
set AppleLogo to «data utxtF8FF» as Unicode text


---Define your Username, Password & IP to access the device
set username to "XXXXX"
set passwd to "YYYYYY"
set DeviceAddress to "192.168.1.100:80"

---Format your username and password
set userpass to username & ":" & passwd

---Define OID commands you want results for (THE ORDER MATTERS!)
set UserData to "--data OID4.3.2.1= --data OID4.1.1= --data OID4.1.5= --data OID4.1.2= --data OID4.1.3= --data OID4.1.4= --data OID4.1.9= --data OID4.1.10= --data OID4.1.12= --data OID4.1.6= --data OID1.13.2.1= --data OID1.13.2.2= --data OID1.13.2.3= --data OID4.1.11="

---Define Alarm subroutine needed later
on commonAlarmStatus(AlarmName)
set AlarmName to get text 10 thru 10 of AlarmName
if AlarmName = "1" then return "None"
if AlarmName = "2" then return "Yellow Alarm"
if AlarmName = "3" then return "Red Alarm"
end commonAlarmStatus

repeat until ExitLoop

---Define command line for Unix Shell Command
set shellcommand to "curl -u " & userpass & " " & UserData & " http://" & DeviceAddress & "/get"

try
---Launch Unix shell command and store results in a variable
set Result_Using_A_Code to do shell script shellcommand

---Take variable containing OID results and create a list
set AppleScript's text item delimiters to "OID"
set OID_Number_List to (every text item of Result_Using_A_Code)

(* Process the List results by cleaning up the data*)

---thermSensorTemp1 = 4.3.2.1 = Zone Temperature (local sensor)
set thermSensorTemp1 to (item 2 of OID_Number_List) as string

-- variable to true so that we can exit the loop.
set ExitLoop to true

set thermSensorTemp1 to get text 9 thru 10 of thermSensorTemp1 & "." & text 11 thru 11 of thermSensorTemp1 & "º"


----thermHvacMode = 4.1.1 = Current HVAC mode
set thermHvacMode to (item 3 of OID_Number_List) as string
set thermHvacMode to get text 7 thru 7 of thermHvacMode
---Set HvacMode variable for future use
set HvacMode to thermHvacMode
if HvacMode = "2" then set HvacMode to "4"
if HvacMode = "3" then set HvacMode to "5"
---Continue Processing thermHvacMode
if thermHvacMode = "1" then set thermHvacMode to "Not Active"
if thermHvacMode = "2" then set thermHvacMode to "Heat"
if thermHvacMode = "3" then set thermHvacMode to "Cool"
if thermHvacMode = "4" then set thermHvacMode to "Auto"

---thermSetbackHeat = 4.1.5 = Current heat setpoint in deci-degrees Fahrenheit
set thermSetbackHeat to (item 4 of OID_Number_List) as string
set thermSetbackHeat to get text 7 thru 8 of thermSetbackHeat & "." & text 9 thru 9 of thermSetbackHeat & "º"

---thermHvacState = 4.1.2 = Current state of HVAC operation
set thermHvacState to (item 5 of OID_Number_List) as string
set thermHvacState to get text 7 thru 7 of thermHvacState
if thermHvacState = "1" then set thermHvacState to "Initializing"
if thermHvacState = "2" then set thermHvacState to "Off"
if thermHvacState = "3" then set thermHvacState to "Heating"
if thermHvacState = "5" then set thermHvacState to "Cooling"
if thermHvacState = "7" then set thermHvacState to "Waiting "
if thermHvacState = "8" then set thermHvacState to "Inactive"

---thermFanMode = 4.1.3 = Current mode of fan operation
set thermFanMode to (item 6 of OID_Number_List) as string
set thermFanMode to get text 7 thru 7 of thermFanMode
if thermFanMode = "1" then set thermFanMode to "Auto"
if thermFanMode = "2" then set thermFanMode to "On"
if thermFanMode = "3" then set thermFanMode to "Schedule"

---thermFanState = 4.1.4 = Current state of fan operation
set thermFanState to (item 7 of OID_Number_List) as string
set thermFanState to get text 7 thru 7 of thermFanState
if thermFanState = "1" then set thermFanState to "Off"
if thermFanState = "2" then set thermFanState to "Off"
if thermFanState = "3" then set thermFanState to "On"

---thermSetbackStatus = 4.1.9 = Current state of setback operation
set thermSetbackStatus to (item 8 of OID_Number_List) as string
set thermSetbackStatus to get text 7 thru 7 of thermSetbackStatus
if thermSetbackStatus = "1" then set thermSetbackStatus to "Normal"
if thermSetbackStatus = "2" then set thermSetbackStatus to "Hold"
if thermSetbackStatus = "3" then set thermSetbackStatus to "Override"

---thermCurrentPeriod = 4.1.10 = Current Period
set thermCurrentPeriod to (item 9 of OID_Number_List) as string
set thermCurrentPeriod to get text 8 thru 8 of thermCurrentPeriod
---Set CurrentPeriod variable for future use
set CurrentPeriod to thermCurrentPeriod
---Continue processing thermCurrentPeriod
if thermCurrentPeriod = "1" then set thermCurrentPeriod to "Morning"
if thermCurrentPeriod = "2" then set thermCurrentPeriod to "Day"
if thermCurrentPeriod = "3" then set thermCurrentPeriod to "Evening"
if thermCurrentPeriod = "4" then set thermCurrentPeriod to "Night"

---thermActivePeriod = 4.1.12 = Current active period
set thermActivePeriod to (item 10 of OID_Number_List) as string
set thermActivePeriod to get text 8 thru 8 of thermActivePeriod
if thermActivePeriod = "1" then set thermActivePeriod to "Morning"
if thermActivePeriod = "2" then set thermActivePeriod to "Day"
if thermActivePeriod = "3" then set thermActivePeriod to "Evening"
if thermActivePeriod = "4" then set thermActivePeriod to "Night"
if thermActivePeriod = "5" then set thermActivePeriod to "Hold"
if thermActivePeriod = "6" then set thermActivePeriod to "Override"

---thermActivePeriod = 4.1.6 = Current cool setpoint in deci-degrees Fahrenheit
set thermSetbackCool to (item 11 of OID_Number_List) as string
set thermSetbackCool to get text 7 thru 8 of thermSetbackCool & "." & text 9 thru 9 of thermSetbackCool & "º"

---commonAlarmStatus = 1.13.2.1 = Current alarm Status - LowTempAlarm
set LowTempAlarm to (item 12 of OID_Number_List) as string
set LowTempAlarm to commonAlarmStatus(LowTempAlarm)

---commonAlarmStatus = 1.13.2.2 = Current alarm Status - HighTempAlarm
set HighTempAlarm to (item 13 of OID_Number_List) as string
set HighTempAlarm to commonAlarmStatus(HighTempAlarm)

---commonAlarmStatus = 1.13.2.3 = Current alarm Status - FilterReminder
set FilterReminder to (item 14 of OID_Number_List) as string
set FilterReminder to commonAlarmStatus(FilterReminder)

---thermCurrentClass = 4.1.11 = Current Class
set thermCurrentClass to (item 15 of OID_Number_List) as string
set thermCurrentClass to get text 8 thru 8 of thermCurrentClass
---Set CurrentClass variable for future use
set CurrentClass to thermCurrentClass
---Continue processing thermCurrentClass
if thermCurrentClass = "1" then set thermCurrentClass to "In"
if thermCurrentClass = "2" then set thermCurrentClass to "Out"
if thermCurrentClass = "3" then set thermCurrentClass to "Away"

---Modify display to show either Heating or Cooling info
if thermHvacMode = "Heat" then
set HeatorCoolVerbiage to "Current Heat Setting: " & thermSetbackHeat
else
set HeatorCoolVerbiage to "Current Cool Setting: " & thermSetbackCool
end if

---Determine Scheduled Setting if Temperature Overridden or Held
if thermSetbackStatus = "Override" or thermSetbackStatus = "Hold" then
---Setup getting either thermPeriodSetbackHeat or Cool
set ScheduledTempData to "--data OID4.4.1." & HvacMode & "." & CurrentClass & "." & CurrentPeriod & "="

---Define command line for Unix Shell Command
set shellcommand to "curl -u " & userpass & " " & ScheduledTempData & " http://" & DeviceAddress & "/get"

---Launch Unix shell command and store results in a variable
set ScheduledTemp to do shell script shellcommand
---Clean up results
set ScheduledTemp to get text 16 thru 18 of ScheduledTemp
set ScheduledTemp to get text 1 thru 2 of ScheduledTemp & "." & text 3 thru 3 of ScheduledTemp & "º"
end if

---Prepare display to show Override/Hold or Normal SetbackStatus
if thermSetbackStatus = "Override" or thermSetbackStatus = "Hold" then
set UseThisVerbiage to HeatorCoolVerbiage & "

Scheduled Temperate: " & ScheduledTemp & AppleLogo
else
set UseThisVerbiage to HeatorCoolVerbiage
end if


---Format Display for Reporting Thermostat Operation
set OperationalVerbiage to "Current Temperature: " & thermSensorTemp1 & "
" & UseThisVerbiage & "

Current Period: " & thermCurrentPeriod & "
Active period: " & thermActivePeriod & "

Current State of Operation: " & thermSetbackStatus & "

Current Mode of HVAC Operation: " & thermHvacMode & "
Current State of HVAC Operation: " & thermHvacState & "

Current Mode of Fan Operation: " & thermFanMode & "
Current State of Fan Operation: " & thermFanState & "

High Temperature Alarm: " & HighTempAlarm & "
Low Temperature Alarm: " & LowTempAlarm & "
Filter Reminder Alarm: " & FilterReminder

display dialog OperationalVerbiage

on error theMessage
---Place Information about the error in the Event Log
log "This error occurred: " & theMessage

(* The thermostat implements a timeout mechanism, 20 minutes after the last successful access, the user is required to resend authentication information. This will come in the form of a 401 response even if proper credentials were sent in the current request. *)

---if the above error happens, ignore it and try again
if theMessage is not equal to "Can't make item 2 of {\"401 Authorization Required\"} into type string." then

---If the script encounters another error, notify the user & auto exit
display dialog "The Script Encountered a Unrecoverable Error, Exiting" buttons {"Ok"} default button 1 giving up after 4
set ExitLoop to true
end if
end try
end repeat -- until ExitLoop


Thu Mar 01, 2007 5:46 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 13204
Location: Texas
Post Re: Proliphix Script - Need help to finish
Instead of trying to create an Indigo device, you should use Indigo variables to store the state of your thermostat information. For example, create a new Indigo variable from the variable window (select the Windows->Variable List to show the variables window). Give the new variable the name "currentTemp".

From the script below you can then set its value via a line like this:

Code: Select all
tell app "IndigoServer"
  set value of variable "currentTemp" to variablthermSensorTemp1 as string
end

Regards,
Matt


Sat Mar 03, 2007 9:25 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.