renstar 0.4.2 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/renstar.rb +12 -9
- data/lib/renstar/api_client/api_object.rb +3 -6
- data/lib/renstar/discovery.rb +28 -0
- data/lib/renstar/thermostat.rb +11 -28
- 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: e5990b28a9195f211562ebc90e3164440e0a8e401272fa87c7d9a3f0bf8636a4
|
4
|
+
data.tar.gz: de3c2bc468511bbc4ce4e57030883996384a83572a70fa649fb882980318a78f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08cb4e79d6675044dad081a517a5efd9c683b80e593f566459202084c35962f7c37c7f92448cad5d1a957a1753d972de8cbb7ca96e08db0d86716701af1aec6c'
|
7
|
+
data.tar.gz: 70a6044088c34b6a0c56d410cc63a1bfee460b6a4c2290846d09f03ed9263504f33c2b1706228e459a2be233de1e0a55439aa6a824b7047d2cc7721950ceb51d
|
data/bin/renstar.rb
CHANGED
@@ -8,14 +8,14 @@ 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
14
|
info - Show current settings
|
15
15
|
sensors - Show current Sensor reading
|
16
16
|
runtimes - Show last 7 days of usage times
|
17
17
|
alerts - Show alerts and their statuses
|
18
|
-
|
18
|
+
|
19
19
|
Control Commands:
|
20
20
|
Note: Temp values are integers. Device settings determine units.
|
21
21
|
heat $TEMP - Heat to $TEMP
|
@@ -31,7 +31,7 @@ USAGE = ''' Usage: renstar.rb command [value]
|
|
31
31
|
home - Set "Home"
|
32
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,28 @@
|
|
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
|
+
SERVICE = 'venstar:thermostat:ecp'
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def ips
|
16
|
+
Socket.ip_address_list.select do |ip|
|
17
|
+
ip.ipv4? && !ip.ipv4_loopback?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# do an SSDP search using the given IP from a found local interface
|
22
|
+
def ssdp_search(ip, timeout = 5)
|
23
|
+
puts "Searching subnet associated with #{ip.ip_address}"
|
24
|
+
ssdp = SSDP::Consumer.new({ bind: ip.ip_address })
|
25
|
+
thermos = ssdp.search(service: SERVICE, timeout: timeout)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
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,23 +30,16 @@ module Renstar
|
|
32
30
|
@cached_info = info
|
33
31
|
end
|
34
32
|
|
35
|
-
def self.search(timeout =
|
33
|
+
def self.search(timeout = 3)
|
36
34
|
all_thermos = []
|
37
|
-
ips = Socket.ip_address_list.select do |ip|
|
38
|
-
ip.ipv4? &&
|
39
|
-
!ip.ipv4_loopback?
|
40
|
-
end
|
41
35
|
ips.each do |ip|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
all_thermos << Renstar::Thermostat.new(location, usn)
|
49
|
-
end
|
36
|
+
all_thermos << ssdp_search(ip, timeout)
|
37
|
+
end
|
38
|
+
all_thermos.flatten.map do |thermo|
|
39
|
+
location = thermo[:params]['Location']
|
40
|
+
usn = thermo[:params]['USN']
|
41
|
+
Renstar::Thermostat.new(location, usn)
|
50
42
|
end
|
51
|
-
all_thermos
|
52
43
|
end
|
53
44
|
|
54
45
|
def update
|
@@ -113,11 +104,7 @@ module Renstar
|
|
113
104
|
end
|
114
105
|
|
115
106
|
def fan_toggle
|
116
|
-
|
117
|
-
fan_off
|
118
|
-
else
|
119
|
-
fan_on
|
120
|
-
end
|
107
|
+
@cached_info.fan == 1 ? fan_off : fan_on
|
121
108
|
end
|
122
109
|
|
123
110
|
def schedule_off
|
@@ -133,11 +120,7 @@ module Renstar
|
|
133
120
|
end
|
134
121
|
|
135
122
|
def schedule_toggle
|
136
|
-
|
137
|
-
schedule_off
|
138
|
-
else
|
139
|
-
schedule_on
|
140
|
-
end
|
123
|
+
@cached_info.schedule == 1 ? schedule_off : schedule_on
|
141
124
|
end
|
142
125
|
|
143
126
|
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.4
|
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
|