Announcement

Collapse
No announcement yet.

Thermostat Scheduler?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Thermostat Scheduler?

    If I knew how to program or write scripts I would write a scipt or plug in that could do scheduling of my trane z-wave thermostats (or any other for that matter). I have a large vacation house in the mountains (it gets cold) with radiant floor heating (supposedly not supported by trane, but it works) with 9 heating zones. That means 9 thermostats! Trying to set schedules for those using events is becoming a nightmare, especially considering that I don't want bed rooms and living areas to have the same profile. I'd love to see a plug in where I could configure a couple of schedules and then apply them to different thermostats. Of course I would also have an away setting that would override the schedules (like the hold setting on my old LUX programmable thermostat).

    I'm thinking this is a pretty rudimentary thing that should already be out there, but I haven't found anything. Am I missing something?

    Thanks

  • #2
    you are not alone

    I am trying to do pretty much the same thing. Right now I am using about a dozen or more events. Each event has to set, at least, the heat and cool setpoints for every thermostat. I will have 12 stats when fully implemented. I use a virtual device as a flag for set backs like "hold away" or "occupied" that the scheduler will check before executing the normal daily events -- home, away, wake and sleep.

    Using only events for programming multiple stats for multiple occupation schedules at multiple seasons gets complicated quickly. This job would really benefit from an addin or robust script. I would pay good $ for this--it cannot be just the two of us looking to simplify scheduling and control of multiple stats.

    Personally, I am trying to move up the vb.net learning curve, but it's very time consuming...and having remote access to HS may get me fired.

    Comment


    • #3
      doing the same...

      Looks like we are taking the same approach. It's getting complicated, and I am too trying to learn how to write scrpits. Haven't written a line of code for 20 years and the programming languages back then were called pascal and cobol if my memory serves me right...

      Comment


      • #4
        Originally posted by johan View Post
        Looks like we are taking the same approach. It's getting complicated, and I am too trying to learn how to write scrpits. Haven't written a line of code for 20 years and the programming languages back then were called pascal and cobol if my memory serves me right...

        I am in the same boat. I wrote a bunch of Excel macros in VBA about 10 years ago to facilitate my work. Fortunately VB.net is similar and Microsoft gives the Express version away for free. The tenScripting program -- search this message board for it -- makes it a breeze and Microsoft's object browser and intellisense expose the current HomeSeer object model -- which is important because the HomeSeer scripting docs and the thermostat API in the SDK are dated. The learning curve is not all that steep once you get going -- a loop is a loop...

        Here is some code I wrote in VB.Net that may help you get started. The subroutine (now known as a method) "List_Stat_Details" goes through pretty much all of the Thermostat Plug-in's stat properties. My Enumerations (Enum) cover all the thermostat mode and state properties I could find for the various set and get functions of the therm plug-in. The only part of the code that is not self-explanatory is that I use a virtual device in HS to hold the override flag -- I set a global constant for my virtual device's house code & user code.

        I also have a callback working -- see "My_Status_Change_CB" --but right now it just writes a log entry to let me know it is working. Ultimately, I will use this to react to temperature and other changes in my home.

        I have not gotten much further that this, but it won't take long from here. Just need to loop around thermostats for various states of the HVAC system, time of day, and add overrides and other switches, etc. I plan on using one of Leviton's scene or zone controllers to set switches -- away, home, hold, etc.

        Good luck.


        Code:
         
        'Public Module Therms_Dev 'comment this out to run as HS script -- don't forget to comment END MODULE too...
          '******************** VB.Net Script for Thermostat Control **********************
          'Global Constants
          Const gMe As String = "Therms_dev.vb"
          Const gOverRideDeviceCode As String = "O1" 'the hcdc of my virtual device override flag
          'My Temp Constants
          Const Heat_Default As Integer = 67
          Const Cool_Default As Integer = 78
          Dim sMode As String() = {"Off", "Heat", "Cool", "Auto", "Aux_Emerg", "mResume", "Fan Only", "Furnace", "Dry Air", "Moist Air", "Auto Change", "Energy Save Heat", "Energy Save Cool", "Away"} 'Therm Mode Settings
          Private Enum THERM_MODE As Integer
            off = 0
            heat = 1
            cool = 2
            auto = 3
            aux_Emerg = 4
            mResume = 5
            fanOnly = 6
            furnace = 7
            dryAir = 8
            moistAir = 9
            autoChange = 10
            energySaveHeat = 11
            energySaveCool = 12
            away = 13
          End Enum
          Dim sState As String() = {"Idle", "Heating", "Cooling", "Fan  Only", "Pending Heat", "Pending Cool", "Vent Economy"} 'Therm Mode States
          Dim sFanMode As String() = {"Auto", "On Low", "Auto High", "On High", "", "", "", "", "", "", "", "", "", "", "", "Not Selected"} 'Fan Settings
          Private Enum FAN_MODE As Integer
            auto = 0
            onLow = 1
            autoHigh = 2
            onHigh = 3
            notSelected = 15
          End Enum
          Dim sFanState As String() = {"Idle", "Low", "High"} 'Fan States
          Dim sHoldState As String() = {"Hold Off", "Hold On"}  'Hold States
          Dim sRunState As String() = {"Not Running", "Running"}  'Operating States
          Dim sStatus As String() = {"0", "1", "On", "Off", "Dim", "Dim", "", "", "", "", "", "", "", "", "", "", "", "Unknown"}
          Private Enum DEVICE_STATUS As Integer
            isOn = 2
            isOff = 3
            isDim = 4
            isDim2 = 5
            isUnknown = 17
          End Enum
          '*************** MAIN **********************
          Public Sub Main(ByVal Parms As Object)
            Dim oTPI As Scheduler.HSPI_ZWAVETHERM.HSPI
            HS.unRegisterStatusChangeCB(gMe)     
            HS.RegisterStatusChangeCB(gMe, "My_Status_Change_CB") 'calls My_Status_Change_CB on ANY status change
            oTPI = HS.Plugin("ZWave Thermostats")
            If oTPI Is Nothing Then
              HS.WriteLog(gMe, "Plugin not found -- Aborting Sub.")
              Exit Sub
            End If
            List_All_Stat_Details(gMe)
            'Test_Set_Therm_1(oTPI)
            'List_Plugins(gMe)
            HS.WriteLog(gMe, "Completed Script: " & gMe)
          End Sub
          '****************End Main ******************
          Private Sub Test_Set_Therm_1(ByVal oTPI As Scheduler.HSPI_ZWAVETHERM.HSPI)
            Dim bOverRide As Boolean, bOkay As Boolean
            Dim stat As Integer, partition As Integer
            Dim mode As Integer, fan As Integer, heatPoint As Double, coolPoint As Double
            Dim iOverride As Integer
            mode = THERM_MODE.auto
            fan = FAN_MODE.auto
            heatPoint = Heat_Default
            coolPoint = Cool_Default
            If (HS.DeviceExistsRef(gOverRideDeviceCode) = -1) Then
              HS.WriteLog(gMe, "Override device " & gOverRideDeviceCode & " does not exist. Aborting script.")
              Exit Sub
            Else
              iOverride = HS.DeviceStatus(gOverRideDeviceCode)
              If iOverride = DEVICE_STATUS.isOn Then
                bOverRide = True
              ElseIf iOverride = DEVICE_STATUS.isOff Then
                bOverRide = False
              Else
                HS.WriteLog(gMe, "Override device is neither on or off: " & iOverride & ". Aborting script.")
                Exit Sub
              End If
            End If
            HS.WriteLog(gMe, "OverRide Switch = " & bOverRide)
            stat = 1 'use stat #1 as tester
            partition = 1
            If Not bOverRide Then bOkay = Set_Therm(oTPI, stat, partition, mode, fan, heatPoint, coolPoint)
            If bOkay Then
              HS.WriteLog(gMe, "Sucessfully set Thermostat settings.")
            Else
              HS.WriteLog(gMe, "One or more settings were not set.")
            End If
            List_Stat_Details(oTPI, stat)
          End Sub
          '**************My Procs ********************
          Private Function Set_Therm(ByVal t As Object, ByVal i As Integer, ByVal j As Integer, ByVal m As Integer, ByVal f As Integer, ByVal h As Double, ByVal c As Double) As Boolean
            Try
              Dim count As Integer
              count = t.CmdSetMode(i, m, j)
              count = count + t.CmdSetFan(i, f, j)
              count = count + t.CmdSetHeat(i, h, j)
              count = count + t.CmdSetCool(i, c, j)
              If count = 0 Then
                Set_Therm = True 'Success = 0
              Else
                Set_Therm = False 'For all Cmdxxxxx functions: <> 0 = Failure Error Code
              End If
            Catch ex As Exception
              HS.WriteLog(gMe, "Set_Therm -- Well, that didn't work ... Exception: " & ex.ToString)
              Set_Therm = False
            End Try
          End Function
          '*******************************
          Private Function Set_Hold(ByVal t As Object, ByVal i As Integer, ByVal j As Integer, ByVal hold As Integer) As Boolean
            Try
              If t.CmdSetHold(i, hold, j) = 0 Then
                Set_Hold = True 'Success
              Else
                Set_Hold = False
              End If
            Catch ex As Exception
              HS.WriteLog(gMe, "Set Hold -- Well, that didn't work ... Exception: " & ex.ToString)
              Set_Hold = False
            End Try
          End Function
          '*******************************
          Private Sub List_All_Stat_Details(ByVal Log As String)
            Dim oTPI As Scheduler.HSPI_ZWAVETHERM.HSPI
            oTPI = HS.Plugin("ZWave Thermostats")
            If oTPI Is Nothing Then
              HS.WriteLog(Log, "Plugin not found -- Aborting Sub.")
              Exit Sub
            End If
            HS.WriteLog(Log, "The Plugin is: " & oTPI.name)
            HS.WriteLog(Log, "The total number of thermostats is: " & oTPI.NThermostats)
            For i As Integer = 1 To oTPI.NThermostats 'Total number of Thermostats
              List_Stat_Details(oTPI, i)
            Next i
          End Sub
          '**********************************
          'This Sub uses ALL of the Plugin's Documented Properties and methods! 
          Private Sub List_Stat_Details(ByVal oTPI As Scheduler.HSPI_ZWAVETHERM.HSPI, ByVal i As Integer)
            Dim s As String, ss As String, sTemp As String
            With oTPI
              HS.WriteLog(gMe, "The Plugin is: " & .name)
              HS.WriteLog(gMe, "The total number of thermostats is: " & .NThermostats)
              HS.WriteLog(gMe, "Thermostat " & i & " is: " & .ThermName(i) & " at z-wave address " _
                                & .ThermAddress(i) & " with " & .NTemps(i) & " sensor(s). Location: " & .ThermLoc(i))
              For j As Integer = 1 To .NTemps(i)
                s = "--Stat " & i & ", Sensor " & j
                ss = s & " supports"
                If .SupportsStat(i, j) Then
                  'Heat and Cool Settings
                  HS.WriteLog(gMe, s & " current temperature is: " & .GetTemp(i, j))
                  sTemp = s & " Heat setting is : " & .GetHeatSet(i, j)
                  If .SupportsCoolSet(i, j) Then
                    HS.WriteLog(gMe, sTemp & ", Cool setting is: " & .GetCoolSet(i, j))
                  Else
                    HS.WriteLog(gMe, sTemp & ", cool setting is not supported (False).")
                  End If
                  sTemp = ""
                  'Mode & state stuff
                  If .SupportsOperating(i, j) Then
                    HS.WriteLog(gMe, s & " current operating mode: " & .GetOperating(i, j)) 'True = running, false = not running.
                  End If
                  HS.WriteLog(gMe, s & " mode is: " & sMode(.GetModeSet(i, j)) & ".")
                  HS.WriteLog(gMe, s & " fan mode is: " & sFanMode(.GetFanMode(i, j)) & "; fan state is: " & _
                                    sFanState(.GetCurrentFan(i, j)))
                  If .GetModeSet(i, j) = THERM_MODE.auto Then
                    HS.WriteLog(gMe, s & " current mode state is: " & sState(.GetCurrentMode(i, j)))
                  End If
                  'How Controllable is it?
                  If .SupportsDirect(i, j) Then
                    HS.WriteLog(gMe, ss & " direct setting.")
                  Else
                    HS.WriteLog(gMe, ss & " " & .NumSetbacks(i, j) & " setback(s).")
                  End If
                  If .SupportsHold(i, j) Then
                    HS.WriteLog(gMe, s & " hold setting is : " & .GetHoldMode(i, j))
                    HS.WriteLog(gMe, ss & " hold Override? " & .SupportsHoldOverride(i, j))
                  Else
                    HS.WriteLog(gMe, s & " does not support hold.")
                  End If
                  HS.WriteLog(gMe, ss & " Aux/Emergency? " & .SupportsAux(i, j))
                End If
              Next j
            End With
          End Sub
          '*********************************
          Private Sub List_Plugins(ByVal gMe As String)
            Dim col_PlugIns As Collection
            Dim PlugItem As Object
            Dim Caps As Short
            Dim s As String
            Const CA_THERM As Short = &H10  '(16) Supports the Thermostat API
            col_PlugIns = HS.GetPluginsEX
            HS.WriteLog(gMe, "There are " & col_PlugIns.Count.ToString & " plug-ins in your system.")
            For Each PlugItem In col_PlugIns
              If Not PlugItem Is Nothing Then
                HS.WriteLog(gMe, PlugItem.name)
                s = "ERROR"
                s = PlugItem.name
                Caps = PlugItem.capabilities
                If (Caps And CA_THERM) = CA_THERM Then
                  HS.WriteLog(gMe, s & " is a thermostat plug-in.")
                End If
              End If
            Next
          End Sub
          '**********************************
          'HS will run this in event of ANY device Status Change if Registered
          Public Sub My_Status_Change_CB(ByVal parms As Object)
            HS.writelog(gme,"Successfully triggered Call Back Method!")
         
            Dim hc As String, dc As String
            Dim status As Integer, devRef As Integer
            Dim device As Object
            hc = parms(0)     'house code of the device that changed status
            dc = parms(1)     'device code of the device that changed status
            status = parms(2) 'the X10 status that the device changed to.
            devRef = parms(3) 'the device reference number. 
            device = HS.GetDeviceByRef(devRef) 'the device
            If Not Is_Thermostat(device) Then Exit Sub 'check to see if device is temperature or therm settings, etc.
            'do something with the status information
          End Sub
          Private Function Is_Thermostat(ByVal device As Object) As Boolean
            Is_Thermostat = False
            If 1 = 1 Then 'change this to something meaningful
              Is_Thermostat = True
            End If
          End Function
        'End Module ' comment out for HS script

        Comment

        Working...
        X