Class: Hue::Bridge
- Inherits:
-
Object
- Object
- Hue::Bridge
- Defined in:
- lib/hue/bridge.rb
Instance Attribute Summary collapse
-
#dhcp ⇒ Object
readonly
Whether the IP address of the bridge is obtained with DHCP.
-
#gateway ⇒ Object
readonly
Gateway IP address of the bridge.
-
#id ⇒ Object
readonly
ID of the bridge.
-
#ip ⇒ Object
readonly
IP address of the bridge.
-
#ip_whitelist ⇒ Object
readonly
An array of whitelisted user IDs.
-
#mac_address ⇒ Object
readonly
MAC address of the bridge.
-
#name ⇒ Object
Name of the bridge.
-
#network_mask ⇒ Object
readonly
Network mask of the bridge.
-
#proxy_address ⇒ Object
readonly
IP Address of the proxy server being used.
-
#proxy_port ⇒ Object
readonly
Port of the proxy being used by the bridge.
-
#software_update ⇒ Object
readonly
Contains information related to software updates.
-
#software_version ⇒ Object
readonly
Software version of the bridge.
Instance Method Summary collapse
- #add_lights ⇒ Object
- #groups ⇒ Object
-
#has_portal_services? ⇒ Boolean
This indicates whether the bridge is registered to synchronize data with a portal account.
-
#initialize(client, hash) ⇒ Bridge
constructor
A new instance of Bridge.
- #lights ⇒ Object
-
#link_button_pressed? ⇒ Boolean
Indicates whether the link button has been pressed within the last 30 seconds.
- #refresh ⇒ Object
- #scenes ⇒ Object
-
#utc ⇒ Object
Current time stored on the bridge.
Constructor Details
#initialize(client, hash) ⇒ Bridge
Returns a new instance of Bridge.
41 42 43 44 |
# File 'lib/hue/bridge.rb', line 41 def initialize(client, hash) @client = client unpack(hash) end |
Instance Attribute Details
#dhcp ⇒ Object (readonly)
Whether the IP address of the bridge is obtained with DHCP.
39 40 41 |
# File 'lib/hue/bridge.rb', line 39 def dhcp @dhcp end |
#gateway ⇒ Object (readonly)
Gateway IP address of the bridge.
36 37 38 |
# File 'lib/hue/bridge.rb', line 36 def gateway @gateway end |
#id ⇒ Object (readonly)
ID of the bridge.
4 5 6 |
# File 'lib/hue/bridge.rb', line 4 def id @id end |
#ip ⇒ Object (readonly)
IP address of the bridge.
11 12 13 |
# File 'lib/hue/bridge.rb', line 11 def ip @ip end |
#ip_whitelist ⇒ Object (readonly)
An array of whitelisted user IDs.
30 31 32 |
# File 'lib/hue/bridge.rb', line 30 def ip_whitelist @ip_whitelist end |
#mac_address ⇒ Object (readonly)
MAC address of the bridge.
14 15 16 |
# File 'lib/hue/bridge.rb', line 14 def mac_address @mac_address end |
#name ⇒ Object
Name of the bridge. This is also its uPnP name, so will reflect the actual uPnP name after any conflicts have been resolved.
8 9 10 |
# File 'lib/hue/bridge.rb', line 8 def name @name end |
#network_mask ⇒ Object (readonly)
Network mask of the bridge.
33 34 35 |
# File 'lib/hue/bridge.rb', line 33 def network_mask @network_mask end |
#proxy_address ⇒ Object (readonly)
IP Address of the proxy server being used.
17 18 19 |
# File 'lib/hue/bridge.rb', line 17 def proxy_address @proxy_address end |
#proxy_port ⇒ Object (readonly)
Port of the proxy being used by the bridge. If set to 0 then a proxy is not being used.
21 22 23 |
# File 'lib/hue/bridge.rb', line 21 def proxy_port @proxy_port end |
#software_update ⇒ Object (readonly)
Contains information related to software updates.
27 28 29 |
# File 'lib/hue/bridge.rb', line 27 def software_update @software_update end |
#software_version ⇒ Object (readonly)
Software version of the bridge.
24 25 26 |
# File 'lib/hue/bridge.rb', line 24 def software_version @software_version end |
Instance Method Details
#add_lights ⇒ Object
80 81 82 83 84 85 |
# File 'lib/hue/bridge.rb', line 80 def add_lights uri = URI.parse("#{base_url}/lights") http = Net::HTTP.new(uri.host) response = http.request_post(uri.path, nil) (response.body).first end |
#groups ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/hue/bridge.rb', line 87 def groups @groups ||= begin json = JSON(Net::HTTP.get(URI.parse("#{base_url}/groups"))) json.map do |id, data| Group.new(@client, self, id, data) end end end |
#has_portal_services? ⇒ Boolean
This indicates whether the bridge is registered to synchronize data with a portal account.
61 62 63 64 |
# File 'lib/hue/bridge.rb', line 61 def has_portal_services? json = get_configuration json['portalservices'] end |
#lights ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/hue/bridge.rb', line 71 def lights @lights ||= begin json = JSON(Net::HTTP.get(URI.parse(base_url))) json['lights'].map do |key, value| Light.new(@client, self, key, value) end end end |
#link_button_pressed? ⇒ Boolean
Indicates whether the link button has been pressed within the last 30 seconds.
54 55 56 57 |
# File 'lib/hue/bridge.rb', line 54 def json = get_configuration json['linkbutton'] end |
#refresh ⇒ Object
66 67 68 69 |
# File 'lib/hue/bridge.rb', line 66 def refresh json = get_configuration unpack(json) end |
#scenes ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'lib/hue/bridge.rb', line 96 def scenes @scenes ||= begin json = JSON(Net::HTTP.get(URI.parse("#{base_url}/scenes"))) json.map do |id, data| Scene.new(@client, self, id, data) end end end |
#utc ⇒ Object
Current time stored on the bridge.
47 48 49 50 |
# File 'lib/hue/bridge.rb', line 47 def utc json = get_configuration DateTime.parse(json['utc']) end |