Module: Dirigera::OnOffBehaviour

Included in:
Light, Outlet
Defined in:
lib/dirigera/on_off_behaviour.rb

Instance Method Summary collapse

Instance Method Details

#offObject



17
18
19
20
21
22
# File 'lib/dirigera/on_off_behaviour.rb', line 17

def off
  response = @client.patch("/devices/#{id}", [{ attributes: { isOn: false } }])
  raise "Failed to update attribute isOn" unless response.code == 202

  @data['attributes']['isOn'] = false
end

#off?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/dirigera/on_off_behaviour.rb', line 6

def off?
  !on?
end

#onObject



10
11
12
13
14
15
# File 'lib/dirigera/on_off_behaviour.rb', line 10

def on
  response = @client.patch("/devices/#{id}", [{ attributes: { isOn: true } }])
  raise "Failed to update attribute isOn" unless response.code == 202

  @data['attributes']['isOn'] = true
end

#on?Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/dirigera/on_off_behaviour.rb', line 2

def on?
  @data['attributes']['isOn']
end