Class: Thermostat

Inherits:
Object
  • Object
show all
Includes:
Proliphix
Defined in:
lib/thermostat.rb

Overview

This is the main class for controlling the Proliphix Thermostat. You must first initialize it with the control point credentials

Constant Summary collapse

VERSION =
'1.0.0'

Constants included from Proliphix

Proliphix::ThermActivePeriod, Proliphix::ThermAverageTemp, Proliphix::ThermConfigHumidyCool, Proliphix::ThermCool1Usage, Proliphix::ThermCool2Usage, Proliphix::ThermCurrentClass, Proliphix::ThermCurrentPeriod, Proliphix::ThermFanMode, Proliphix::ThermFanState, Proliphix::ThermFanUsage, Proliphix::ThermHeat1Usage, Proliphix::ThermHeat2Usage, Proliphix::ThermHvacMode, Proliphix::ThermHvacState, Proliphix::ThermLastUsageReset, Proliphix::ThermSetbackCool, Proliphix::ThermSetbackHeat, Proliphix::ThermSetbackStatus

Instance Method Summary collapse

Constructor Details

#initialize(ip, user, passwd) ⇒ Thermostat

create a new thermostat object. It needs

* ip - the ip address of the thermostat, probably 192.168.1.2
* user - the admin user for the thermostat
* passwd - the admin passwd for the thermostat


19
20
21
# File 'lib/thermostat.rb', line 19

def initialize(ip, user, passwd)
    @network = Proliphix::Network.new(ip, user, passwd)
end

Instance Method Details

#[](reading) ⇒ Object

Get a reading for a constant, returns raw values



24
25
26
# File 'lib/thermostat.rb', line 24

def [](reading)
    return @network.get(reading)
end

#[]=(reading, value) ⇒ Object

Set a reading for a constant.



29
30
31
# File 'lib/thermostat.rb', line 29

def []=(reading, value)
    return @network.set(reading, value)
end

#cool_toObject

Return what temperature the thermostat is attempting to cool to.



49
50
51
52
53
54
55
# File 'lib/thermostat.rb', line 49

def cool_to
    case mode
    when "Cool" then return self[ThermSetbackCool]
    when "Auto" then return self[ThermSetbackCool]
    end
    return nil
end

#cool_to=(value) ⇒ Object

Set the target cool-to temperature. The effects in non cooling mode aren’t well defined.



74
75
76
77
78
79
80
# File 'lib/thermostat.rb', line 74

def cool_to=(value)    
    value *= 10
    if (value > 600) and (value < 900)
        self[ThermSetbackCool] = value.to_i
    end
    cool_to
end

#cooling?Boolean

Are we currently running the AC, returns a boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/thermostat.rb', line 88

def cooling?
    self[ThermHvacState] == "Cool"
end

#fan_off!Object

Turn the fan off



105
106
107
108
# File 'lib/thermostat.rb', line 105

def fan_off!
    self[ThermFanMode] = 1
    self[ThermFanState]
end

#fan_on!Object

Turn the fan on



99
100
101
102
# File 'lib/thermostat.rb', line 99

def fan_on!
    self[ThermFanMode] = 2
    self[ThermFanState]
end

#fan_on?Boolean

Is the fan currently on. It doesn’t matter why it’s on, just that it’s on.

Returns:

  • (Boolean)


94
95
96
# File 'lib/thermostat.rb', line 94

def fan_on?
    self[ThermFanState] == "On"
end

#heat_toObject

Return what temperature the thermostat is attempting to heat to.



40
41
42
43
44
45
46
# File 'lib/thermostat.rb', line 40

def heat_to
    case mode
    when "Heat" then return self[ThermSetbackHeat]
    when "Auto" then return self[ThermSetbackHeat]
    end
    return nil
end

#heat_to=(value) ⇒ Object

Set the target heat-to temperature. The effects in non heating mode aren’t well defined.



64
65
66
67
68
69
70
# File 'lib/thermostat.rb', line 64

def heat_to=(value)
    value *= 10
    if (value > 500) and (value < 800)
        self[ThermSetbackHeat] = value.to_i
    end
    heat_to
end

#heating?Boolean

Are we currently running the heat, returns a boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/thermostat.rb', line 83

def heating?
    self[ThermHvacState] == "Heat"
end

#modeObject

Get the thermostat mode. This will come back as one of “Off”, “Heat”, “Cool”, or “Auto”.



35
36
37
# File 'lib/thermostat.rb', line 35

def mode
    self[ThermHvacMode]
end

#tempObject

Return the current temperature reading on the thermostat



58
59
60
# File 'lib/thermostat.rb', line 58

def temp
    self[ThermAverageTemp]
end