Class: RubyMyq::Device::GarageDoor

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_myq/device/garage_door.rb

Instance Method Summary collapse

Constructor Details

#initialize(device, headers) ⇒ GarageDoor

Returns a new instance of GarageDoor.



8
9
10
11
12
13
# File 'lib/ruby_myq/device/garage_door.rb', line 8

def initialize(device, headers)
  @device = device
  @headers = headers
  # API response includes incorrect verion number and http rather than https
  @device_uri = @device['href'].gsub(/v5/, 'v5.1').gsub(/http/, 'https')
end

Instance Method Details

#closeObject



23
24
25
# File 'lib/ruby_myq/device/garage_door.rb', line 23

def close
  change_door_state('close')
end

#nameObject



15
16
17
# File 'lib/ruby_myq/device/garage_door.rb', line 15

def name
  @device['name']
end

#openObject



19
20
21
# File 'lib/ruby_myq/device/garage_door.rb', line 19

def open
  change_door_state('open')
end

#statusObject



27
28
29
30
# File 'lib/ruby_myq/device/garage_door.rb', line 27

def status
  state = request_door_state
  state['door_state']
end

#status_sinceObject



32
33
34
35
# File 'lib/ruby_myq/device/garage_door.rb', line 32

def status_since
  state = request_door_state
  state['last_update']
end