Module: Winker::Devices::OnOff
- Included in:
- Winker::Device, LightBulb
- Defined in:
- lib/winker/devices/on_off.rb
Instance Method Summary collapse
- #check_last_powered ⇒ Object
- #off ⇒ Object
- #off? ⇒ Boolean
- #on ⇒ Object
- #powered? ⇒ Boolean (also: #on?)
- #updates_finished? ⇒ Boolean
Instance Method Details
#check_last_powered ⇒ Object
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 |
#off ⇒ Object
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
30 31 32 |
# File 'lib/winker/devices/on_off.rb', line 30 def off? !powered? end |
#on ⇒ Object
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?
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
4 5 6 7 |
# File 'lib/winker/devices/on_off.rb', line 4 def updates_finished? check_last_powered return true end |