renstar 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/README.md +12 -4
- data/bin/renstar.rb +40 -23
- data/lib/renstar/api_client/api_object.rb +0 -1
- data/lib/renstar/api_client/control.rb +0 -1
- data/lib/renstar/api_client/query.rb +0 -1
- data/lib/renstar/api_client/settings.rb +0 -1
- data/lib/renstar/thermostat.rb +5 -4
- data/lib/renstar/version.rb +1 -1
- data/renstar.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec271b5f2fff4930b2689574a8dbffda3a7aa956ee2b251771cb3c37ea3eea99
|
4
|
+
data.tar.gz: c44ba6940104204e8cae7ba9531134e94fa22df79d39b224ae2a92968bcaf2e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49c89698f8df31b6f6410af9ab6d0cf2607fb3c637aaa1bd0afb044a33393285614e31b679877e7a9bc6aecc258d830f512203a018adc0ab2b2e903ebeaac0c1
|
7
|
+
data.tar.gz: 92a4ca9dfc653a48bada22b2f0f8d658739b106e116f58ac96872724dc070c5cdb3341b5567c3a67c27c0dbbde42f249662fd81cfa83acd662bd39bedd4bebca
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.4
|
data/README.md
CHANGED
@@ -22,6 +22,10 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Using the included binary
|
24
24
|
|
25
|
+
Well, OK, it's just a script that uses the library, but it wraps all of the
|
26
|
+
functionality and lets you just control your thermostat if that's all you're
|
27
|
+
here for.
|
28
|
+
|
25
29
|
When installing the gem, we install `renstar.rb` for you automatically. You can
|
26
30
|
pass the `-h` flag for more info.
|
27
31
|
|
@@ -29,17 +33,21 @@ The help page does not list all the accepted commands or their values but all of
|
|
29
33
|
the methods below are supported. The binary just passes your arguments to the
|
30
34
|
methods below.
|
31
35
|
|
32
|
-
So, if you want to cool your house to 72 using the binary, you can do this
|
33
|
-
|
36
|
+
So, if you want to cool your house to 72 using the binary, you can do this in
|
37
|
+
your favorite shell:
|
38
|
+
```bash
|
34
39
|
renstar.rb cool 72
|
35
40
|
```
|
36
41
|
|
37
42
|
You can apply the logic above to any of the methods below for the same effect.
|
38
43
|
|
39
44
|
### Note about thermostat selection
|
45
|
+
|
40
46
|
The binary chooses the first thermostat it finds on the network, so you may get
|
41
|
-
unexpected results if you have more than one on your network.
|
42
|
-
|
47
|
+
unexpected results if you have more than one on your network.
|
48
|
+
|
49
|
+
You can use the `-t` option to pass the hostname or IP address of a thermostat
|
50
|
+
if you know it and don't want to wait for autodiscovery to find it.
|
43
51
|
|
44
52
|
## Using the library
|
45
53
|
|
data/bin/renstar.rb
CHANGED
@@ -1,51 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'renstar'
|
2
4
|
require 'optparse'
|
3
5
|
require 'ostruct'
|
4
|
-
require 'pry'
|
5
6
|
|
6
7
|
options = {}
|
7
8
|
|
8
|
-
#DEFAULT_OPTIONS = { all: false }.freeze
|
9
|
+
# DEFAULT_OPTIONS = { all: false }.freeze
|
9
10
|
|
11
|
+
USAGE = ' Usage: renstar.rb command [value]'
|
10
12
|
|
11
|
-
|
13
|
+
Options = Struct.new(:thermostat)
|
14
|
+
args = Options.new
|
12
15
|
|
13
16
|
OptionParser.new do |opts|
|
14
|
-
|
15
17
|
opts.banner = USAGE
|
16
18
|
|
17
|
-
opts.on '-d', '--discover', 'Discover all Renstar devices' do |
|
19
|
+
opts.on '-d', '--discover', 'Discover all Renstar devices' do |_d|
|
18
20
|
options[:discover] = true
|
19
21
|
end
|
20
22
|
|
21
|
-
opts.on '-h', '--help', 'Display this screen' do |
|
23
|
+
opts.on '-h', '--help', 'Display this screen' do |_h|
|
22
24
|
puts opts
|
23
25
|
exit 0
|
24
26
|
end
|
27
|
+
|
28
|
+
opts.on '-tTHERMOSTAT', '--thermostat=THERMOSTAT', 'Use thermostat by host name or IP. No discovery.' do |t|
|
29
|
+
args.thermostat = t
|
30
|
+
end
|
25
31
|
end.parse!
|
26
32
|
|
27
33
|
if options[:discover]
|
28
34
|
thermos = Renstar::Thermostat.search
|
29
|
-
thermos.each do |
|
30
|
-
puts "Found: #{
|
35
|
+
thermos.each do |t|
|
36
|
+
puts "Found: #{t.location} #{t.usn}"
|
31
37
|
end
|
32
38
|
exit 0
|
33
39
|
end
|
34
40
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
puts "
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
case response
|
44
|
-
when String
|
45
|
-
puts response
|
46
|
-
when Renstar::APIClient::APIObject
|
47
|
-
response.pp
|
48
|
-
when Array
|
49
|
-
response.each {|x| x.pp }
|
41
|
+
thermo = nil
|
42
|
+
if args.thermostat
|
43
|
+
thermo = Renstar::Thermostat.new(args.thermostat)
|
44
|
+
puts "Using: #{thermo.location}"
|
45
|
+
else
|
46
|
+
thermos = Renstar::Thermostat.search
|
47
|
+
thermos.each do |t|
|
48
|
+
puts "Found: #{t.location} #{t.usn}"
|
50
49
|
end
|
50
|
+
thermo = thermos.first
|
51
|
+
puts "Using: #{thermo.location} - #{thermo.usn}"
|
52
|
+
end
|
53
|
+
command = nil
|
54
|
+
if ARGV.nil? || ARGV.empty?
|
55
|
+
command = 'info'
|
56
|
+
else
|
57
|
+
command = ARGV
|
58
|
+
end
|
59
|
+
|
60
|
+
response = thermo.send(*command)
|
61
|
+
case response
|
62
|
+
when String
|
63
|
+
puts response
|
64
|
+
when Renstar::APIClient::APIObject
|
65
|
+
response.pp
|
66
|
+
when Array
|
67
|
+
response.each(&:pp)
|
51
68
|
end
|
data/lib/renstar/thermostat.rb
CHANGED
@@ -12,6 +12,7 @@ module Renstar
|
|
12
12
|
#
|
13
13
|
class Thermostat
|
14
14
|
SERVICE = 'venstar:thermostat:ecp'
|
15
|
+
USN_REGEX = /^(\w+):(\w+)+:((?:[0-9a-fA-F]{2}:?)+):name:(.*):type:(.*)/
|
15
16
|
DEFAULT_TIMEOUT = 3
|
16
17
|
|
17
18
|
attr_reader :location, :usn, :cached_info
|
@@ -19,12 +20,12 @@ module Renstar
|
|
19
20
|
include APIClient
|
20
21
|
|
21
22
|
def initialize(location, usn = nil)
|
22
|
-
if location && usn
|
23
|
+
if location && usn
|
23
24
|
@location = location
|
24
25
|
@usn = usn
|
25
26
|
else
|
26
|
-
@location = "http
|
27
|
-
@usn =
|
27
|
+
@location = "http://#{location}/"
|
28
|
+
@usn = ''
|
28
29
|
end
|
29
30
|
|
30
31
|
@cache_timestamp = Time.now
|
@@ -39,7 +40,7 @@ module Renstar
|
|
39
40
|
end
|
40
41
|
ips.each do |ip|
|
41
42
|
puts "Searching subnet associated with #{ip.ip_address}"
|
42
|
-
ssdp = SSDP::Consumer.new({bind: ip.ip_address})
|
43
|
+
ssdp = SSDP::Consumer.new({ bind: ip.ip_address })
|
43
44
|
thermos = ssdp.search(service: SERVICE, timeout: timeout)
|
44
45
|
thermos.each do |thermo|
|
45
46
|
location = thermo[:params]['Location']
|
data/lib/renstar/version.rb
CHANGED
data/renstar.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = 'https://github.com/mikerodrigues/renstar'
|
14
14
|
spec.required_ruby_version = '>= 3.0.0'
|
15
15
|
|
16
|
-
spec.metadata['allowed_push_host'] =
|
16
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
17
17
|
|
18
18
|
spec.metadata['homepage_uri'] = spec.homepage
|
19
19
|
spec.metadata['source_code_uri'] = 'https://github.com/mikerodrigues/renstar'
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Rodrigues
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -49,6 +49,7 @@ extensions: []
|
|
49
49
|
extra_rdoc_files: []
|
50
50
|
files:
|
51
51
|
- ".gitignore"
|
52
|
+
- ".ruby-version"
|
52
53
|
- Gemfile
|
53
54
|
- LICENSE
|
54
55
|
- README.md
|