Class: Thermostat
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.2.0'
Constants included from Proliphix
Proliphix::ThermActivePeriod, Proliphix::ThermAuxHeatMode, Proliphix::ThermAuxHeatOffset, 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, Proliphix::ThermSystemTimeSecs
Instance Attribute Summary collapse
-
#network ⇒ Object
readonly
Returns the value of attribute network.
Instance Method Summary collapse
-
#[](reading) ⇒ Object
Get a reading for a constant, returns raw values.
-
#[]=(reading, value) ⇒ Object
Set a reading for a constant.
-
#aux_heat ⇒ Object
Get the aux heat mode.
-
#aux_heat=(value) ⇒ Object
Set the aux heat mode.
-
#aux_heat_offset ⇒ Object
Get the aux heat offset.
-
#aux_heat_offset=(value) ⇒ Object
Set the aux heat offset.
-
#cool_to ⇒ Object
Return what temperature the thermostat is attempting to cool to.
-
#cool_to=(value) ⇒ Object
Set the target cool-to temperature.
-
#cool_usage ⇒ Object
The number of minutes of active cooling since last reset of the counters.
-
#cooling? ⇒ Boolean
Are we currently running the AC, returns a boolean.
-
#fan_off! ⇒ Object
Turn the fan off.
-
#fan_on! ⇒ Object
Turn the fan on.
-
#fan_on? ⇒ Boolean
Is the fan currently on.
-
#fan_usage ⇒ Object
The number of minutes the fan was running since last reset of the counters.
-
#heat_to ⇒ Object
Return what temperature the thermostat is attempting to heat to.
-
#heat_to=(value) ⇒ Object
Set the target heat-to temperature.
-
#heat_usage ⇒ Object
The number of minutes of active heating since last reset of the counters.
-
#heating? ⇒ Boolean
Are we currently running the heat, returns a boolean.
-
#initialize(ip, user, passwd) ⇒ Thermostat
constructor
create a new thermostat object.
-
#mode ⇒ Object
Get the thermostat mode.
-
#system_time ⇒ Object
Get the thermostat system time.
-
#system_time=(value) ⇒ Object
Set the thermostat system time.
-
#temp ⇒ Object
Return the current temperature reading on the thermostat.
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
21 22 23 |
# File 'lib/thermostat.rb', line 21 def initialize(ip, user, passwd) @network = Proliphix::Network.new(ip, user, passwd) end |
Instance Attribute Details
#network ⇒ Object (readonly)
Returns the value of attribute network.
13 14 15 |
# File 'lib/thermostat.rb', line 13 def network @network end |
Instance Method Details
#[](reading) ⇒ Object
Get a reading for a constant, returns raw values
26 27 28 |
# File 'lib/thermostat.rb', line 26 def [](reading) return @network.get(reading) end |
#[]=(reading, value) ⇒ Object
Set a reading for a constant.
31 32 33 |
# File 'lib/thermostat.rb', line 31 def []=(reading, value) return @network.set(reading, value) end |
#aux_heat ⇒ Object
Get the aux heat mode
139 140 141 |
# File 'lib/thermostat.rb', line 139 def aux_heat self[ThermAuxHeatMode] end |
#aux_heat=(value) ⇒ Object
Set the aux heat mode
144 145 146 147 148 149 |
# File 'lib/thermostat.rb', line 144 def aux_heat=(value) if (value == "1") or (value == "2") or (value == "3") then self[ThermAuxHeatMode] = value.to_i end aux_heat end |
#aux_heat_offset ⇒ Object
Get the aux heat offset
152 153 154 |
# File 'lib/thermostat.rb', line 152 def aux_heat_offset self[ThermAuxHeatOffset] end |
#aux_heat_offset=(value) ⇒ Object
Set the aux heat offset
157 158 159 160 161 162 |
# File 'lib/thermostat.rb', line 157 def aux_heat_offset=(value) if (value >= 0) and (value <= 10) self[ThermAuxHeatOffset] = value.to_i end aux_heat_offset end |
#cool_to ⇒ Object
Return what temperature the thermostat is attempting to cool to.
51 52 53 54 55 56 57 |
# File 'lib/thermostat.rb', line 51 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.
76 77 78 79 80 81 82 |
# File 'lib/thermostat.rb', line 76 def cool_to=(value) value *= 10 if (value > 600) and (value < 900) self[ThermSetbackCool] = value.to_i end cool_to end |
#cool_usage ⇒ Object
The number of minutes of active cooling since last reset of the counters.
100 101 102 |
# File 'lib/thermostat.rb', line 100 def cool_usage self[ThermCool1Usage] end |
#cooling? ⇒ Boolean
Are we currently running the AC, returns a boolean
90 91 92 |
# File 'lib/thermostat.rb', line 90 def cooling? self[ThermHvacState] == "Cool" end |
#fan_off! ⇒ Object
Turn the fan off
122 123 124 125 |
# File 'lib/thermostat.rb', line 122 def fan_off! self[ThermFanMode] = 1 self[ThermFanState] end |
#fan_on! ⇒ Object
Turn the fan on
116 117 118 119 |
# File 'lib/thermostat.rb', line 116 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.
111 112 113 |
# File 'lib/thermostat.rb', line 111 def fan_on? self[ThermFanState] == "On" end |
#fan_usage ⇒ Object
The number of minutes the fan was running since last reset of the counters.
105 106 107 |
# File 'lib/thermostat.rb', line 105 def fan_usage self[ThermFanUsage] end |
#heat_to ⇒ Object
Return what temperature the thermostat is attempting to heat to.
42 43 44 45 46 47 48 |
# File 'lib/thermostat.rb', line 42 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.
66 67 68 69 70 71 72 |
# File 'lib/thermostat.rb', line 66 def heat_to=(value) value *= 10 if (value > 500) and (value < 800) self[ThermSetbackHeat] = value.to_i end heat_to end |
#heat_usage ⇒ Object
The number of minutes of active heating since last reset of the counters.
95 96 97 |
# File 'lib/thermostat.rb', line 95 def heat_usage self[ThermHeat1Usage] end |
#heating? ⇒ Boolean
Are we currently running the heat, returns a boolean
85 86 87 |
# File 'lib/thermostat.rb', line 85 def heating? self[ThermHvacState] == "Heat" end |
#mode ⇒ Object
Get the thermostat mode. This will come back as one of “Off”, “Heat”, “Cool”, or “Auto”.
37 38 39 |
# File 'lib/thermostat.rb', line 37 def mode self[ThermHvacMode] end |
#system_time ⇒ Object
Get the thermostat system time
128 129 130 |
# File 'lib/thermostat.rb', line 128 def system_time self[ThermSystemTimeSecs] end |
#system_time=(value) ⇒ Object
Set the thermostat system time
133 134 135 136 |
# File 'lib/thermostat.rb', line 133 def system_time=(value) self[ThermSystemTimeSecs] = value.to_i system_time end |
#temp ⇒ Object
Return the current temperature reading on the thermostat
60 61 62 |
# File 'lib/thermostat.rb', line 60 def temp self[ThermAverageTemp] end |