Class: LifxDash::Monitor
- Inherits:
-
Object
- Object
- LifxDash::Monitor
- Defined in:
- lib/lifx_dash/monitor.rb
Instance Attribute Summary collapse
-
#iface ⇒ Object
readonly
Returns the value of attribute iface.
-
#mac ⇒ Object
readonly
Returns the value of attribute mac.
-
#selector ⇒ Object
readonly
Returns the value of attribute selector.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(token: nil, mac: nil, selector: "all", iface: "en0") ⇒ Monitor
constructor
A new instance of Monitor.
- #run ⇒ Object
Constructor Details
#initialize(token: nil, mac: nil, selector: "all", iface: "en0") ⇒ Monitor
Returns a new instance of Monitor.
8 9 10 11 12 13 |
# File 'lib/lifx_dash/monitor.rb', line 8 def initialize(token: nil, mac: nil, selector: "all", iface: "en0") @iface = iface @token = token @mac = mac @selector = selector end |
Instance Attribute Details
#iface ⇒ Object (readonly)
Returns the value of attribute iface.
6 7 8 |
# File 'lib/lifx_dash/monitor.rb', line 6 def iface @iface end |
#mac ⇒ Object (readonly)
Returns the value of attribute mac.
6 7 8 |
# File 'lib/lifx_dash/monitor.rb', line 6 def mac @mac end |
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
6 7 8 |
# File 'lib/lifx_dash/monitor.rb', line 6 def selector @selector end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/lifx_dash/monitor.rb', line 6 def token @token end |
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/lifx_dash/monitor.rb', line 15 def run puts "Starting lifx_dash monitor ..." puts " * listening on #{iface} for Dash button #{mac} presses to toggle #{selector} bulb(s)" LifxDash::Capturer.new(iface).listen do |pkt, source_mac_addr| if source_mac_addr == mac LOGGER.info "Detected Dash button press from MAC address: #{mac} -- pkt summary: #{pkt.peek}" lifx_api.toggle(selector) end end end |