Class: Wemote::Insight
Overview
This class encapsulates an individual Wemo Insight. It provides methods for getting and setting the insight’s state, as well as a #toggle! method for convenience. Finally, it provides the Switch#poll method, which accepts a block to be executed any time the insight changes state.
Constant Summary collapse
- GET_HEADERS_POWER =
{ "SOAPACTION" => '"urn:Belkin:service:insight:1#GetInsightParams"', "Content-type" => 'text/xml; charset="utf-8"' }
Constants inherited from Switch
Switch::GET_HEADERS, Switch::SET_HEADERS
Instance Attribute Summary
Attributes inherited from Switch
Class Method Summary collapse
-
.all(refresh = false) ⇒ Array
Returns all Insight detected on the local network.
- .device_type ⇒ Object
Instance Method Summary collapse
- #energy ⇒ Object
- #on_today ⇒ Object
- #power ⇒ Object
-
#standby? ⇒ Boolean
Return whether the Insight is standby.
-
#toggle! ⇒ Object
Turn the Insight on or off, based on its current state.
Methods inherited from Switch
#device_type, find, #initialize, #off!, #off?, #on!, #on?, #poll
Constructor Details
This class inherits a constructor from Wemote::Switch
Class Method Details
.all(refresh = false) ⇒ Array
Returns all Insight detected on the local network
29 30 31 32 |
# File 'lib/wemote/insight.rb', line 29 def all(refresh=false) @insights = nil if refresh @insights ||= Wemote::Collection::Insight.new(discover) end |
.device_type ⇒ Object
21 22 23 |
# File 'lib/wemote/insight.rb', line 21 def device_type 'urn:Belkin:device:insight:1' end |
Instance Method Details
#energy ⇒ Object
52 53 54 |
# File 'lib/wemote/insight.rb', line 52 def energy get_insight_params()[:energy] end |
#on_today ⇒ Object
56 57 58 |
# File 'lib/wemote/insight.rb', line 56 def on_today get_insight_params()[:on_today] end |
#power ⇒ Object
48 49 50 |
# File 'lib/wemote/insight.rb', line 48 def power get_insight_params()[:power] end |
#standby? ⇒ Boolean
Return whether the Insight is standby
44 45 46 |
# File 'lib/wemote/insight.rb', line 44 def standby? get_state == :standby; end |
#toggle! ⇒ Object
Turn the Insight on or off, based on its current state
37 38 39 |
# File 'lib/wemote/insight.rb', line 37 def toggle! on? or standby? ? off! : on!; end |