Class: Hue::Bridge

Inherits:
Object
  • Object
show all
Includes:
Indentation
Defined in:
lib/hue/extensions/bridge.rb

Constant Summary

Constants included from Indentation

Indentation::DEFAULT_INDENTATION_SIZE

Instance Method Summary collapse

Methods included from Indentation

#indent, #puts

Instance Method Details



46
47
48
49
50
# File 'lib/hue/extensions/bridge.rb', line 46

def print_bulbs
  self.bulbs.each do |bulb|
    bulb.print_state
  end
end


5
6
7
8
9
10
11
# File 'lib/hue/extensions/bridge.rb', line 5

def print_config
  puts "Config:"
  indent do
    puts "Application id: #{application_id}"
    puts "Bridge URI: #{bridge_uri}"
  end
end


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/hue/extensions/bridge.rb', line 13

def print_state
  state = self.status
  config = state['config']
  puts "#{config['name']}"
  puts "Button pressed: #{config['linkbutton']}"
  puts "Timestamp: #{config['UTC']}"
  puts "Network configuration:"
  indent do
    puts "IP:      #{config['ipaddress']}"
    puts "Gateway: #{config['gateway']}"
    puts "Mask:    #{config['netmask']}"
    puts "DHCP:    #{config['dhcp']}"
    puts "MAC:     #{config['mac']}"
    if !config['proxyaddress'].strip.empty?
      puts "Proxy:   #{config['proxyaddress']}:#{config['proxyport']}"
    end
  end

  puts "Applications:"
  indent do
    config['whitelist'].each do |key, values|
      puts "#{'%-40s' % key} : #{values['name']}"
    end
  end

  puts "Lights:"
  indent do
    state['lights'].each do |key, values|
      puts "  #{'%2.3s' % key}. #{'%-30s' % values['name']} \t #{values['state']['on'] ? 'ON' : 'OFF'} \t #{values['modelid']} - #{values['type']}"
    end
  end
end