Module: Ecobee

Defined in:
lib/ecobee.rb,
lib/ecobee/http.rb,
lib/ecobee/token.rb,
lib/ecobee/version.rb,
lib/ecobee/register.rb,
lib/ecobee/thermostat.rb

Defined Under Namespace

Classes: AuthError, HTTP, HTTPError, Register, RetryAuthError, Thermostat, ThermostatError, Token

Constant Summary collapse

API_HOST =
'api.ecobee.com'
API_PORT =
443
API_URI_BASE =
"https://#{API_HOST}:#{API_PORT}"
CONTENT_TYPE =
['application/json', { 'charset' => 'UTF-8' }]
DEFAULT_POLL_INTERVAL =
30
DEFAULT_FILES =
[
  '~/Library/Mobile Documents/com~apple~CloudDocs/.ecobee_token',
  '~/.ecobee_token'
]
AUTH_ERRORS =
%w{
  authorization_expired
  authorization_pending 
  invalid_client 
  slow_down 
}
FAN_MODES =
%w{auto on}
HVAC_MODES =
%w{auto auxHeatOnly cool heat off}
MAX_LOG_LENGTH =
1200
AUTH_PAD =
30
REFRESH_PAD =
240
SCOPES =
[:smartWrite, :smartRead]
DEFAULT_SCOPE =
VERSION =
"0.3.3"

Class Method Summary collapse

Class Method Details

.FanMode(mode) ⇒ Object



51
52
53
54
55
# File 'lib/ecobee.rb', line 51

def self.FanMode(mode)
  { 'auto'        => 'Auto',
    'on'          => 'On'
  }.fetch(mode, 'Unknown')
end

.Mode(mode) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/ecobee.rb', line 57

def self.Mode(mode)
  { 'auto'        => 'Auto',
    'auxHeatOnly' => 'Aux Heat Only',
    'cool'        => 'Cool',
    'heat'        => 'Heat',
    'off'         => 'Off'
  }.fetch(mode, 'Unknown')
end

.Model(model) ⇒ Object



66
67
68
69
70
71
72
73
74
75
# File 'lib/ecobee.rb', line 66

def self.Model(model)
  { 'idtSmart'    => 'ecobee Smart',
    'idtEms'      => 'ecobee Smart EMS',
    'siSmart'     => 'ecobee Si Smart',
    'siEms'       => 'ecobee Si EMS',
    'athenaSmart' => 'ecobee3 Smart',
    'athenaEms'   => 'ecobee3 EMS',
    'corSmart'    => 'Carrier or Bryant Cor',
  }.fetch(model, "Unknown (#{model})")
end

.ResponseCode(code) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/ecobee.rb', line 77

def self.ResponseCode(code)
  {  0 => 'Success',
     1 => 'Authentication failed.', 
     2 => 'Not authorized.',
     3 => 'Processing error.',
     4 => 'Serialization error.',
     5 => 'Invalid request format.',
     6 => 'Too many thermostat in selection match criteria.',
     7 => 'Validation error.',
     8 => 'Invalid function.',
     9 => 'Invalid selection.',
    10 => 'Invalid page.',
    11 => 'Function error.',
    12 => 'Post not supported for request.',
    13 => 'Get not supported for request.',
    14 => 'Authentication token has expired. Refresh your tokens.',
    15 => 'Duplicate data violation.',
    16 => 'Invalid token. Token has been deauthorized by user. You must ' +
          're-request authorization.'
  }.fetch(code.to_i, 'Unknown Error.')
end

.Selection(arg = {}) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/ecobee.rb', line 99

def self.Selection(arg = {})
  { 'selection' => {
      'selectionType' => 'registered',
      'selectionMatch' => '',
      'includeRuntime' => 'false',
      'includeExtendedRuntime' => 'false',
      'includeElectricity' => 'false',
      'includeSettings' => 'false',
      'includeLocation' => 'false',
      'includeProgram' => 'false',
      'includeEvents' => 'false',
      'includeDevice' => 'false',
      'includeTechnician' => 'false',
      'includeUtility' => 'false',
      'includeAlerts' => 'false',
      'includeWeather' => 'false',
      'includeOemConfig' => 'false',
      'includeEquipmentStatus' => 'false',
      'includeNotificationSettings' => 'false',
      'includeVersion' => 'false',
      'includeSensors' => 'false',
    }.merge(Hash[*arg.map { |k,v| [k.to_s, v.to_s] }.flatten])
  }
end