renstar 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/renstar.rb +27 -24
- data/lib/renstar/api_client/api_object.rb +3 -6
- data/lib/renstar/discovery.rb +42 -0
- data/lib/renstar/thermostat.rb +4 -33
- data/lib/renstar/version.rb +1 -1
- data/lib/renstar.rb +1 -0
- 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: 617260529f9b3d241c8b6f0a4489d9eac7f871a998b9f2e0b42c0ee54e322491
|
4
|
+
data.tar.gz: 3a7560d9559b8c40272a991449bf6d06916fccd4dbc7914e98a5c58d0c84bdd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83fd7c65c7162f8c6c9582a6c8525aa49f14c4c578b56e866581fff21fcfa554afe387396ef399d800993787ec378a1066f3da5cb39ee086a5675e9cc188c119
|
7
|
+
data.tar.gz: 1bcf749dad62edddb0d6be3b4c8e081eb08bdef1ad4389bc86b372ad7fb6e3bef6d3369764f8c157d19c6b76f1de21b10bd1444c0098edd2e211f30cfb4b9b7b
|
data/bin/renstar.rb
CHANGED
@@ -8,30 +8,30 @@ options = {}
|
|
8
8
|
|
9
9
|
# DEFAULT_OPTIONS = { all: false }.freeze
|
10
10
|
|
11
|
-
USAGE = '
|
11
|
+
USAGE = ' Usage: renstar.rb command [value]
|
12
12
|
|
13
13
|
Informational Commands:
|
14
|
-
info
|
15
|
-
sensors
|
16
|
-
runtimes -
|
17
|
-
alerts
|
18
|
-
|
14
|
+
info - Show current settings
|
15
|
+
sensors - Show current Sensor reading
|
16
|
+
runtimes - Show last 7 days of usage times
|
17
|
+
alerts - Show alerts and their statuses
|
18
|
+
|
19
19
|
Control Commands:
|
20
20
|
Note: Temp values are integers. Device settings determine units.
|
21
|
-
heat $TEMP
|
22
|
-
cool $TEMP
|
21
|
+
heat $TEMP - Heat to $TEMP
|
22
|
+
cool $TEMP - Cool to $TEMP
|
23
23
|
auto $LO_TEMP $HI_TEMP - Keep temp in between two temps
|
24
|
-
off
|
25
|
-
fan_on
|
26
|
-
fan_off
|
27
|
-
fan_toggle
|
28
|
-
schedule_on
|
29
|
-
schedule_off
|
30
|
-
schedule_toggle
|
31
|
-
home
|
32
|
-
away
|
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"
|
33
33
|
|
34
|
-
'
|
34
|
+
'
|
35
35
|
|
36
36
|
Options = Struct.new(:thermostat)
|
37
37
|
args = Options.new
|
@@ -67,18 +67,21 @@ if args.thermostat
|
|
67
67
|
puts "Using: #{thermo.location}"
|
68
68
|
else
|
69
69
|
thermos = Renstar::Thermostat.search
|
70
|
+
if thermos.empty?
|
71
|
+
puts 'No thermostats found'
|
72
|
+
exit 0
|
73
|
+
end
|
70
74
|
thermos.each do |t|
|
71
75
|
puts "Found: #{t.location} #{t.usn}"
|
72
76
|
end
|
73
77
|
thermo = thermos.first
|
74
78
|
puts "Using: #{thermo.location} - #{thermo.usn}"
|
75
79
|
end
|
76
|
-
command = nil
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
80
|
+
command = if ARGV.nil? || ARGV.empty?
|
81
|
+
'info'
|
82
|
+
else
|
83
|
+
ARGV
|
84
|
+
end
|
82
85
|
|
83
86
|
response = thermo.send(*command)
|
84
87
|
case response
|
@@ -7,14 +7,11 @@ module Renstar
|
|
7
7
|
def initialize(raw_hash)
|
8
8
|
@raw_hash = raw_hash
|
9
9
|
raw_hash.each do |key, value|
|
10
|
-
if key == 'ts'
|
11
|
-
|
12
|
-
else
|
13
|
-
instance_variable_set("@#{key}", value)
|
14
|
-
end
|
10
|
+
value = Time.at(value) if key == 'ts'
|
11
|
+
instance_variable_set("@#{key}", value)
|
15
12
|
|
16
13
|
define_singleton_method(key) do
|
17
|
-
|
14
|
+
instance_variable_get("@#{key}")
|
18
15
|
end
|
19
16
|
end
|
20
17
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ssdp'
|
4
|
+
require 'socket'
|
5
|
+
|
6
|
+
module Renstar
|
7
|
+
# Helper module for handling SSDP and IP details for discovery thermostats on
|
8
|
+
# the network
|
9
|
+
module Discovery
|
10
|
+
# Discovery timeout when searching for thermostats
|
11
|
+
DEFAULT_TIMEOUT = 3
|
12
|
+
SERVICE = 'venstar:thermostat:ecp'
|
13
|
+
|
14
|
+
def search(timeout = DEFAULT_TIMEOUT)
|
15
|
+
all_thermos = []
|
16
|
+
ips.each do |ip|
|
17
|
+
all_thermos << ssdp_search(ip, timeout)
|
18
|
+
end
|
19
|
+
all_thermos.flatten
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def ips
|
25
|
+
Socket.ip_address_list.select do |ip|
|
26
|
+
ip.ipv4? && !ip.ipv4_loopback?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# do an SSDP search using the given IP from a found local interface
|
31
|
+
def ssdp_search(ip, timeout = DEFAULT_TIMEOUT)
|
32
|
+
puts "Searching subnet associated with #{ip.ip_address}"
|
33
|
+
ssdp = SSDP::Consumer.new({ bind: ip.ip_address })
|
34
|
+
thermos = ssdp.search(service: SERVICE, timeout: timeout)
|
35
|
+
thermos.map do |thermo|
|
36
|
+
location = thermo[:params]['Location']
|
37
|
+
usn = thermo[:params]['USN']
|
38
|
+
Renstar::Thermostat.new(location, usn)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/renstar/thermostat.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'ssdp'
|
4
|
-
require 'socket'
|
5
3
|
require_relative 'api_client'
|
4
|
+
require_relative 'discovery'
|
6
5
|
|
7
6
|
module Renstar
|
8
7
|
# Thermostat object
|
@@ -11,13 +10,12 @@ module Renstar
|
|
11
10
|
# Home/Away, and Off
|
12
11
|
#
|
13
12
|
class Thermostat
|
14
|
-
SERVICE = 'venstar:thermostat:ecp'
|
15
13
|
USN_REGEX = /^(\w+):(\w+)+:((?:[0-9a-fA-F]{2}:?)+):name:(.*):type:(.*)/
|
16
|
-
DEFAULT_TIMEOUT = 3
|
17
14
|
|
18
15
|
attr_reader :location, :usn, :cached_info
|
19
16
|
|
20
17
|
include APIClient
|
18
|
+
extend Discovery
|
21
19
|
|
22
20
|
def initialize(location, usn = nil)
|
23
21
|
if location && usn
|
@@ -32,25 +30,6 @@ module Renstar
|
|
32
30
|
@cached_info = info
|
33
31
|
end
|
34
32
|
|
35
|
-
def self.search(timeout = DEFAULT_TIMEOUT)
|
36
|
-
all_thermos = []
|
37
|
-
ips = Socket.ip_address_list.select do |ip|
|
38
|
-
ip.ipv4? &&
|
39
|
-
!ip.ipv4_loopback?
|
40
|
-
end
|
41
|
-
ips.each do |ip|
|
42
|
-
puts "Searching subnet associated with #{ip.ip_address}"
|
43
|
-
ssdp = SSDP::Consumer.new({ bind: ip.ip_address })
|
44
|
-
thermos = ssdp.search(service: SERVICE, timeout: timeout)
|
45
|
-
thermos.each do |thermo|
|
46
|
-
location = thermo[:params]['Location']
|
47
|
-
usn = thermo[:params]['USN']
|
48
|
-
all_thermos << Renstar::Thermostat.new(location, usn)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
all_thermos
|
52
|
-
end
|
53
|
-
|
54
33
|
def update
|
55
34
|
@cache_timestamp = Time.now
|
56
35
|
@cached_info = info
|
@@ -113,11 +92,7 @@ module Renstar
|
|
113
92
|
end
|
114
93
|
|
115
94
|
def fan_toggle
|
116
|
-
|
117
|
-
fan_off
|
118
|
-
else
|
119
|
-
fan_on
|
120
|
-
end
|
95
|
+
@cached_info.fan == 1 ? fan_off : fan_on
|
121
96
|
end
|
122
97
|
|
123
98
|
def schedule_off
|
@@ -133,11 +108,7 @@ module Renstar
|
|
133
108
|
end
|
134
109
|
|
135
110
|
def schedule_toggle
|
136
|
-
|
137
|
-
schedule_off
|
138
|
-
else
|
139
|
-
schedule_on
|
140
|
-
end
|
111
|
+
@cached_info.schedule == 1 ? schedule_off : schedule_on
|
141
112
|
end
|
142
113
|
|
143
114
|
def home
|
data/lib/renstar/version.rb
CHANGED
data/lib/renstar.rb
CHANGED
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.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Rodrigues
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- lib/renstar/api_client/control.rb
|
69
69
|
- lib/renstar/api_client/query.rb
|
70
70
|
- lib/renstar/api_client/settings.rb
|
71
|
+
- lib/renstar/discovery.rb
|
71
72
|
- lib/renstar/thermostat.rb
|
72
73
|
- lib/renstar/version.rb
|
73
74
|
- renstar.gemspec
|