renstar 0.1.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/bin/renstar.rb +26 -34
- data/lib/renstar/thermostat.rb +26 -10
- data/lib/renstar/version.rb +1 -1
- data/renstar.gemspec +3 -3
- metadata +11 -9
- data/Gemfile.lock +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c893e454f0d89cfacea09754a34ce55b14b327a821131fa3f91519d4fb82d194
|
4
|
+
data.tar.gz: 8fea02226bfcd4ec43a170d10cf830ed86430e8ccff222ae81de34933215a8c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66f8f9dd14a24154e426a77fb27bbf907390751e7291a36b88078b4be451b1e264095482b0d5336dfe587837d69e18cf0d573af2b00d65f13402e88b5b8f21d9
|
7
|
+
data.tar.gz: b80c4954be1b7ca521c7ccf0d630b84215e1480082cbd0deabe2408b964d21c72d509826366efc671c682f473e2e6250cbb23985b590a32b82bd5bcfab17487e
|
data/Gemfile
CHANGED
data/README.md
CHANGED
data/bin/renstar.rb
CHANGED
@@ -2,49 +2,41 @@ require 'renstar'
|
|
2
2
|
require 'optparse'
|
3
3
|
require 'ostruct'
|
4
4
|
|
5
|
-
|
6
|
-
DEFAULT_OPTIONS = { all: false }.freeze
|
7
|
-
USAGE = " Usage: renstar.rb command [value]"
|
5
|
+
options = {}
|
8
6
|
|
9
|
-
|
7
|
+
#DEFAULT_OPTIONS = { all: false }.freeze
|
10
8
|
|
11
|
-
@options = OpenStruct.new(DEFAULT_OPTIONS)
|
12
9
|
|
13
|
-
|
14
|
-
opts.banner = USAGE
|
10
|
+
USAGE = " Usage: renstar.rb command [value]"
|
15
11
|
|
16
|
-
|
17
|
-
@options.discover = true
|
18
|
-
end
|
12
|
+
OptionParser.new do |opts|
|
19
13
|
|
20
|
-
|
21
|
-
@options.help = true
|
22
|
-
end
|
23
|
-
end
|
14
|
+
opts.banner = USAGE
|
24
15
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
if @options.discover
|
30
|
-
Renstar.discover.each do |device|
|
31
|
-
puts "#{device.name} #{device.ip}"
|
32
|
-
end
|
33
|
-
exit 0
|
34
|
-
end
|
35
|
-
|
36
|
-
if @options.help
|
37
|
-
puts opts
|
38
|
-
exit 0
|
39
|
-
end
|
16
|
+
opts.on '-d', '--discover', 'Discover all Renstar devices' do |d|
|
17
|
+
options[:discover] = true
|
18
|
+
end
|
40
19
|
|
20
|
+
opts.on '-h', '--help', 'Display this screen' do |h|
|
21
|
+
puts opts
|
22
|
+
exit 0
|
23
|
+
end
|
24
|
+
end.parse!
|
41
25
|
|
26
|
+
if options[:discover]
|
27
|
+
thermos = Renstar::Thermostat.search
|
28
|
+
thermos.each do |thermo|
|
29
|
+
puts "Found: #{thermo.location} #{thermo.usn}"
|
42
30
|
end
|
31
|
+
exit 0
|
43
32
|
end
|
44
33
|
|
45
|
-
@options = RenstarOptions.parse(ARGV)
|
46
34
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
35
|
+
thermos = Renstar::Thermostat.search
|
36
|
+
thermos.each do |thermo|
|
37
|
+
puts "Found: #{thermo.location} #{thermo.usn}"
|
38
|
+
end
|
39
|
+
puts "Using: " + thermos.first.location + " - " + thermos.first.usn
|
40
|
+
unless (ARGV.nil? || ARGV.empty?)
|
41
|
+
puts thermos.first.send(*ARGV)
|
42
|
+
end
|
data/lib/renstar/thermostat.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'ssdp'
|
4
|
+
require 'socket'
|
4
5
|
require_relative 'api_client'
|
5
6
|
|
6
7
|
module Renstar
|
@@ -11,27 +12,42 @@ module Renstar
|
|
11
12
|
#
|
12
13
|
class Thermostat
|
13
14
|
SERVICE = 'venstar:thermostat:ecp'
|
14
|
-
DEFAULT_TIMEOUT =
|
15
|
+
DEFAULT_TIMEOUT = 3
|
15
16
|
|
16
17
|
attr_reader :location, :usn, :cached_info
|
17
18
|
|
18
19
|
include APIClient
|
19
20
|
|
20
|
-
def initialize(location, usn)
|
21
|
-
|
22
|
-
|
21
|
+
def initialize(location, usn = nil)
|
22
|
+
if location && usn then
|
23
|
+
@location = location
|
24
|
+
@usn = usn
|
25
|
+
else
|
26
|
+
@location = "http://" + location + '/'
|
27
|
+
@usn = ""
|
28
|
+
end
|
29
|
+
|
23
30
|
@cache_timestamp = Time.now
|
24
31
|
@cached_info = info
|
25
32
|
end
|
26
33
|
|
27
34
|
def self.search(timeout = DEFAULT_TIMEOUT)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
35
|
+
all_thermos = []
|
36
|
+
ips = Socket.ip_address_list.select do |ip|
|
37
|
+
ip.ipv4? &&
|
38
|
+
!ip.ipv4_loopback?
|
39
|
+
end
|
40
|
+
ips.each do |ip|
|
41
|
+
puts "Searching subnet associated with #{ip.ip_address}"
|
42
|
+
ssdp = SSDP::Consumer.new({bind: ip.ip_address})
|
43
|
+
thermos = ssdp.search(service: SERVICE, timeout: timeout)
|
44
|
+
thermos.each do |thermo|
|
45
|
+
location = thermo[:params]['Location']
|
46
|
+
usn = thermo[:params]['USN']
|
47
|
+
all_thermos << Renstar::Thermostat.new(location, usn)
|
48
|
+
end
|
34
49
|
end
|
50
|
+
all_thermos
|
35
51
|
end
|
36
52
|
|
37
53
|
def update
|
data/lib/renstar/version.rb
CHANGED
data/renstar.gemspec
CHANGED
@@ -24,12 +24,12 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
25
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
26
26
|
end
|
27
|
-
spec.bindir = '
|
28
|
-
spec.executables = spec.files.grep(%r{\
|
27
|
+
spec.bindir = 'bin'
|
28
|
+
spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ['lib']
|
30
30
|
|
31
31
|
spec.add_runtime_dependency 'json'
|
32
|
-
spec.add_runtime_dependency 'ssdp'
|
32
|
+
spec.add_runtime_dependency 'ssdp', '~> 1.1.7'
|
33
33
|
|
34
34
|
# Uncomment to register a new dependency of your gem
|
35
35
|
# spec.add_dependency "example-gem", "~> 1.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: renstar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Rodrigues
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -28,26 +28,28 @@ dependencies:
|
|
28
28
|
name: ssdp
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.1.7
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.1.7
|
41
41
|
description: Control Venstar thermostats with Ruby via their local API.
|
42
42
|
email:
|
43
43
|
- mikebrodrigues@gmail.com
|
44
|
-
executables:
|
44
|
+
executables:
|
45
|
+
- console
|
46
|
+
- renstar.rb
|
47
|
+
- setup
|
45
48
|
extensions: []
|
46
49
|
extra_rdoc_files: []
|
47
50
|
files:
|
48
51
|
- ".gitignore"
|
49
52
|
- Gemfile
|
50
|
-
- Gemfile.lock
|
51
53
|
- LICENSE
|
52
54
|
- README.md
|
53
55
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
renstar (0.1.1)
|
5
|
-
json
|
6
|
-
ssdp
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
json (2.6.1)
|
12
|
-
rake (13.0.6)
|
13
|
-
ssdp (1.1.7)
|
14
|
-
|
15
|
-
PLATFORMS
|
16
|
-
x86_64-linux
|
17
|
-
|
18
|
-
DEPENDENCIES
|
19
|
-
rake (~> 13.0)
|
20
|
-
renstar!
|
21
|
-
|
22
|
-
BUNDLED WITH
|
23
|
-
2.2.22
|