renstar 0.1.1 → 0.2.0
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/Gemfile +1 -0
- data/bin/renstar.rb +43 -0
- data/lib/renstar/thermostat.rb +28 -12
- data/lib/renstar/version.rb +1 -1
- data/renstar.gemspec +3 -3
- metadata +8 -19
- 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: 395939a21c7674830297c4b637980c6b0ef8dd5a368ac9c7f22046e8acd30f8d
|
4
|
+
data.tar.gz: 76fcd3f4913478ca1993f8b0b9acfd27ab420f23005f55803a98955d5b196a5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85342777ce38973500afc97c66c059c3b8b0e6b023367902d2271b3ece751a2f40c9840fc44e27c792fdf08a86f41467494e07aecc86dfbaa481b6cf471fd2c5
|
7
|
+
data.tar.gz: a30e766bb836c2e682f3f4b4499d8e77aea7cb7cb90e1ac44c8a61398df9e0657223b7e136ccf27cc8512bace3cec41e80e7f238247f6576774b414503194bbb
|
data/Gemfile
CHANGED
data/bin/renstar.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'renstar'
|
2
|
+
require 'optparse'
|
3
|
+
require 'ostruct'
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
|
8
|
+
#DEFAULT_OPTIONS = { all: false }.freeze
|
9
|
+
|
10
|
+
|
11
|
+
USAGE = " Usage: renstar.rb command [value]"
|
12
|
+
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
|
15
|
+
opts.banner = USAGE
|
16
|
+
|
17
|
+
opts.on '-d', '--discover', 'Discover all Renstar devices' do |d|
|
18
|
+
options[:discover] = true
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on '-h', '--help', 'Display this screen' do |h|
|
22
|
+
puts opts
|
23
|
+
exit 0
|
24
|
+
end
|
25
|
+
end.parse!
|
26
|
+
|
27
|
+
if options[:discover]
|
28
|
+
thermos = Renstar::Thermostat.search
|
29
|
+
thermos.each do |thermo|
|
30
|
+
puts "Found: #{thermo.location} #{thermo.usn}"
|
31
|
+
end
|
32
|
+
exit 0
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
thermos = Renstar::Thermostat.search
|
37
|
+
thermos.each do |thermo|
|
38
|
+
puts "Found: #{thermo.location} #{thermo.usn}"
|
39
|
+
end
|
40
|
+
puts "Using: " + thermos.first.location + " - " + thermos.first.usn
|
41
|
+
unless (ARGV.nil? || ARGV.empty?)
|
42
|
+
puts thermos.first.send(*ARGV)
|
43
|
+
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
|
@@ -48,7 +64,7 @@ module Renstar
|
|
48
64
|
def heat(heattemp = nil)
|
49
65
|
update
|
50
66
|
if heattemp
|
51
|
-
cooltemp = heattemp + 1
|
67
|
+
cooltemp = heattemp.to_i + 1
|
52
68
|
else
|
53
69
|
cooltemp = @cached_info.cooltemp
|
54
70
|
heattemp = @cached_info.heattemp
|
@@ -61,7 +77,7 @@ module Renstar
|
|
61
77
|
def cool(cooltemp = nil)
|
62
78
|
update
|
63
79
|
if cooltemp
|
64
|
-
heattemp = cooltemp - 1
|
80
|
+
heattemp = cooltemp.to_i - 1
|
65
81
|
# heattemp = cooltemp - @cached_info.setpointdelta
|
66
82
|
else
|
67
83
|
cooltemp = @cached_info.cooltemp
|
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'
|
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.
|
4
|
+
version: 0.2.0
|
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
|
@@ -24,34 +24,23 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: ssdp
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
description: Control Venstar thermostats with Ruby via their local API.
|
42
28
|
email:
|
43
29
|
- mikebrodrigues@gmail.com
|
44
|
-
executables:
|
30
|
+
executables:
|
31
|
+
- console
|
32
|
+
- renstar.rb
|
33
|
+
- setup
|
45
34
|
extensions: []
|
46
35
|
extra_rdoc_files: []
|
47
36
|
files:
|
48
37
|
- ".gitignore"
|
49
38
|
- Gemfile
|
50
|
-
- Gemfile.lock
|
51
39
|
- LICENSE
|
52
40
|
- README.md
|
53
41
|
- Rakefile
|
54
42
|
- bin/console
|
43
|
+
- bin/renstar.rb
|
55
44
|
- bin/setup
|
56
45
|
- lib/renstar.rb
|
57
46
|
- lib/renstar/api_client.rb
|
data/Gemfile.lock
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
renstar (0.1.0)
|
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
|