renstar 0.3.1 → 0.4.1
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 +63 -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: ef74d1acc32dc347fad041438f853371966a19c4bd779ffd26fcf95bab9736cf
|
4
|
+
data.tar.gz: 4762e30fee9e46d2da3f3ddd21ea4fe997eba6f1d749abb663e89332909bbd7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0c13d294cec82dcf96ac4508108af60286130bf603f770cff3f9994e1131c26c3623d04d3f89b6a9a3e495e9da054b862b94a540840389426f82672860fb386
|
7
|
+
data.tar.gz: 8675dde8fcafa72ccb7d6a3721fcbeb38576a863d840713b0199ca12cb2789a7138244203febab11496e4bff8914f9d4100f4ecbe7f0ea305cce7c8f3938143d
|
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,91 @@
|
|
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
|
+
Informational Commands:
|
14
|
+
info - Show current settings
|
15
|
+
sensors - Show current Sensor reading
|
16
|
+
runtimes - Last 7 days of usage times
|
17
|
+
alerts - Show alerts and their statuses
|
18
|
+
|
19
|
+
Control Commands:
|
20
|
+
Note: Temp values are integers. Device settings determine units.
|
21
|
+
heat $TEMP - Heat to $TEMP
|
22
|
+
cool $TEMP - Cool to $TEMP
|
23
|
+
auto $LO_TEMP $HI_TEMP - Keep temp in between two temps
|
24
|
+
off - Turn off heating and/or cooling
|
25
|
+
fan_on - Turn on the fan
|
26
|
+
fan_off - Turn on the fan
|
27
|
+
fan_toggle - Toggle the fan on/off
|
28
|
+
schedule_on - Turn on the schedule
|
29
|
+
schedule_off - Turn off the schedule
|
30
|
+
schedule_toggle - Toggle the schedule on/off
|
31
|
+
home - Set "Home"
|
32
|
+
away - Set "Away"
|
12
33
|
|
13
|
-
|
34
|
+
'''
|
35
|
+
|
36
|
+
Options = Struct.new(:thermostat)
|
37
|
+
args = Options.new
|
14
38
|
|
39
|
+
OptionParser.new do |opts|
|
15
40
|
opts.banner = USAGE
|
16
41
|
|
17
|
-
opts.on '-d', '--discover', 'Discover all Renstar devices' do |
|
42
|
+
opts.on '-d', '--discover', 'Discover all Renstar devices' do |_d|
|
18
43
|
options[:discover] = true
|
19
44
|
end
|
20
45
|
|
21
|
-
opts.on '-h', '--help', 'Display this screen' do |
|
46
|
+
opts.on '-h', '--help', 'Display this screen' do |_h|
|
22
47
|
puts opts
|
23
48
|
exit 0
|
24
49
|
end
|
50
|
+
|
51
|
+
opts.on '-tTHERMOSTAT', '--thermostat=THERMOSTAT', 'Use thermostat by host name or IP. No discovery.' do |t|
|
52
|
+
args.thermostat = t
|
53
|
+
end
|
25
54
|
end.parse!
|
26
55
|
|
27
56
|
if options[:discover]
|
28
57
|
thermos = Renstar::Thermostat.search
|
29
|
-
thermos.each do |
|
30
|
-
puts "Found: #{
|
58
|
+
thermos.each do |t|
|
59
|
+
puts "Found: #{t.location} #{t.usn}"
|
31
60
|
end
|
32
61
|
exit 0
|
33
62
|
end
|
34
63
|
|
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 }
|
64
|
+
thermo = nil
|
65
|
+
if args.thermostat
|
66
|
+
thermo = Renstar::Thermostat.new(args.thermostat)
|
67
|
+
puts "Using: #{thermo.location}"
|
68
|
+
else
|
69
|
+
thermos = Renstar::Thermostat.search
|
70
|
+
thermos.each do |t|
|
71
|
+
puts "Found: #{t.location} #{t.usn}"
|
50
72
|
end
|
73
|
+
thermo = thermos.first
|
74
|
+
puts "Using: #{thermo.location} - #{thermo.usn}"
|
75
|
+
end
|
76
|
+
command = nil
|
77
|
+
if ARGV.nil? || ARGV.empty?
|
78
|
+
command = 'info'
|
79
|
+
else
|
80
|
+
command = ARGV
|
81
|
+
end
|
82
|
+
|
83
|
+
response = thermo.send(*command)
|
84
|
+
case response
|
85
|
+
when String
|
86
|
+
puts response
|
87
|
+
when Renstar::APIClient::APIObject
|
88
|
+
response.pp
|
89
|
+
when Array
|
90
|
+
response.each(&:pp)
|
51
91
|
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.1
|
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-
|
11
|
+
date: 2022-10-24 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
|