-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRakefile
executable file
·49 lines (43 loc) · 1.23 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
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
45
46
47
48
49
require "bundler/gem_tasks"
$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/lib")
require 'simple_upnp'
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
namespace :simple_upnp do
task :search do
puts "Searching for devices...\n"
include_location_details = true
devices = SimpleUpnp::Discovery.search()
devices.each do |device|
puts 'Device Found: '
puts device.to_json(include_location_details)
puts ''
end
end
task :find_hue do
puts "Searching for Phillips Hue...\n"
include_location_details = true
hue_device = nil
SimpleUpnp::Discovery.find do |device|
device_json = device.to_json(include_location_details)
if device_json['root']
if device_json['root']['device']
if device_json['root']['device']['friendlyName']
friendlyName = device_json['root']['device']['friendlyName']
if friendlyName =~ /Philips hue/
hue_device = device
break
end
end
end
end
end
if hue_device
puts 'Device Found: '
puts hue_device.to_json(include_location_details)
puts ''
end
end
end