Module: Winker::Devices::OnOff

Included in:
Winker::Device, LightBulb
Defined in:
lib/winker/devices/on_off.rb

Instance Method Summary collapse

Instance Method Details

#check_last_poweredObject



9
10
11
12
13
# File 'lib/winker/devices/on_off.rb', line 9

def check_last_powered
  wait_for_update( Proc.new{@updated_at < @obj_data.last_reading.powered_updated_at.to_time}) do
    self.refresh
  end
end

#offObject



25
26
27
28
# File 'lib/winker/devices/on_off.rb', line 25

def off
  #turn off device
  update(desired_state: {powered: "false"})
end

#off?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/winker/devices/on_off.rb', line 30

def off?
  !powered?
end

#onObject



20
21
22
23
# File 'lib/winker/devices/on_off.rb', line 20

def on
  #turn on device
  update(desired_state: {powered: "true"})
end

#powered?Boolean Also known as: on?

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/winker/devices/on_off.rb', line 15

def powered?
  check_last_powered
  @obj_data.last_reading.powered
end

#updates_finished?Boolean

Returns:

  • (Boolean)


4
5
6
7
# File 'lib/winker/devices/on_off.rb', line 4

def updates_finished?
  check_last_powered
  return true
end