renstar 0.4.4 → 0.4.6
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/.github/workflows/ci.yml +27 -0
- data/.ruby-version +1 -1
- data/README.md +21 -0
- data/Rakefile +10 -2
- data/bin/renstar.rb +7 -1
- data/lib/renstar/api_client.rb +13 -3
- data/lib/renstar/discovery.rb +1 -1
- data/lib/renstar/thermostat.rb +25 -21
- data/lib/renstar/version.rb +1 -1
- data/renstar.gemspec +1 -0
- data/script/test-supported-rubies +52 -0
- metadata +19 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d565afcb49d0a987fb6c54e0026fd2eb96f795ebf846ead087cc9c1afbab913e
|
|
4
|
+
data.tar.gz: fa3a09141ed51a0c586b899d9a6b7aad61d59c5618af55acaf44cf685341edcd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c39898c02620535be19828bbf95b797136df8f8993cdfd9e61d4da50aed1b5ee78e9365f4887a8a055137c087cc8692b5fc408f1a926ef32f840939a50d3fdad
|
|
7
|
+
data.tar.gz: 79513ae66be4d099d3d04ff254496e4755f3be8c547de9a46c68f5117099313bf443bf548fea646a36d47b7ef6f6fd16007fd573e3d8b849c717ac5d9fa57dcf
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
strategy:
|
|
11
|
+
fail-fast: false
|
|
12
|
+
matrix:
|
|
13
|
+
ruby:
|
|
14
|
+
- '3.3'
|
|
15
|
+
- '3.4'
|
|
16
|
+
- '4.0'
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v5
|
|
20
|
+
|
|
21
|
+
- uses: ruby/setup-ruby@v1
|
|
22
|
+
with:
|
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
|
24
|
+
bundler-cache: true
|
|
25
|
+
|
|
26
|
+
- name: Run test suite
|
|
27
|
+
run: bundle exec rake test
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.4.10
|
data/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Renstar is a Ruby SDK for interacting with the Venstar Thermostat Local API.
|
|
|
4
4
|
|
|
5
5
|
You can control your thermostat programmatically!
|
|
6
6
|
|
|
7
|
+
[](https://codeclimate.com/github/mikerodrigues/renstar/maintainability)
|
|
8
|
+
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
9
11
|
Add this line to your application's Gemfile:
|
|
@@ -143,6 +145,25 @@ thermo.away
|
|
|
143
145
|
|
|
144
146
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
145
147
|
|
|
148
|
+
## Testing
|
|
149
|
+
|
|
150
|
+
Run the full test suite locally with:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
bundle exec rake test
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
If you want to run the suite across the currently maintained MRI branches that
|
|
157
|
+
this project targets, use:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
script/test-supported-rubies
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
That script looks for installed `rbenv` versions matching the maintained MRI
|
|
164
|
+
branches as of July 22, 2026: `3.3`, `3.4`, and `4.0`. CI runs the same matrix
|
|
165
|
+
automatically on every push and pull request.
|
|
166
|
+
|
|
146
167
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
147
168
|
|
|
148
169
|
## Contributing
|
data/Rakefile
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require '
|
|
4
|
-
|
|
3
|
+
require 'rake/testtask'
|
|
4
|
+
|
|
5
|
+
Rake::TestTask.new(:test) do |test|
|
|
6
|
+
test.libs << 'test'
|
|
7
|
+
test.pattern = 'test/**/*_test.rb'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
require 'bundler/gem_tasks' if (ARGV & %w[build install release]).any?
|
|
11
|
+
|
|
12
|
+
task default: :test
|
data/bin/renstar.rb
CHANGED
|
@@ -83,7 +83,13 @@ command = if ARGV.nil? || ARGV.empty?
|
|
|
83
83
|
ARGV
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
begin
|
|
87
|
+
response = thermo.send(*command)
|
|
88
|
+
rescue NoMethodError
|
|
89
|
+
puts "'#{command.join(' ')}' is not a valid command"
|
|
90
|
+
exit 1
|
|
91
|
+
end
|
|
92
|
+
|
|
87
93
|
case response
|
|
88
94
|
when String
|
|
89
95
|
puts response
|
data/lib/renstar/api_client.rb
CHANGED
|
@@ -13,16 +13,26 @@ module Renstar
|
|
|
13
13
|
# The actual client that handles getting, posting, and parsing API responses
|
|
14
14
|
#
|
|
15
15
|
module APIClient
|
|
16
|
+
class APIError < StandardError; end
|
|
17
|
+
class APIUnknownResponseError < StandardError; end
|
|
18
|
+
|
|
16
19
|
def get(endpoint)
|
|
17
20
|
uri = URI(location + endpoint)
|
|
18
|
-
response = Net::HTTP.
|
|
19
|
-
JSON.parse(response)
|
|
21
|
+
response = Net::HTTP.get_response(uri)
|
|
22
|
+
JSON.parse(response.body)
|
|
20
23
|
end
|
|
21
24
|
|
|
22
25
|
def post(endpoint, options = {})
|
|
23
26
|
uri = URI(location + endpoint)
|
|
24
27
|
response = Net::HTTP.post_form(uri, options)
|
|
25
|
-
JSON.parse(response.body)
|
|
28
|
+
json = JSON.parse(response.body)
|
|
29
|
+
if json['error']
|
|
30
|
+
raise APIError, json['reason']
|
|
31
|
+
elsif json['success']
|
|
32
|
+
json
|
|
33
|
+
else
|
|
34
|
+
raise APIUnknownResponseError, response.body
|
|
35
|
+
end
|
|
26
36
|
end
|
|
27
37
|
|
|
28
38
|
include Query
|
data/lib/renstar/discovery.rb
CHANGED
|
@@ -22,7 +22,7 @@ module Renstar
|
|
|
22
22
|
def ssdp_search(ip, timeout = 5)
|
|
23
23
|
puts "Searching subnet associated with #{ip.ip_address}"
|
|
24
24
|
ssdp = SSDP::Consumer.new({ bind: ip.ip_address })
|
|
25
|
-
|
|
25
|
+
ssdp.search(service: SERVICE, timeout: timeout)
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
end
|
data/lib/renstar/thermostat.rb
CHANGED
|
@@ -31,14 +31,12 @@ module Renstar
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def self.search(timeout = 3)
|
|
34
|
-
all_thermos =
|
|
35
|
-
|
|
36
|
-
all_thermos << ssdp_search(ip, timeout)
|
|
34
|
+
all_thermos = ips.flat_map do |ip|
|
|
35
|
+
ssdp_search(ip, timeout)
|
|
37
36
|
end
|
|
37
|
+
|
|
38
38
|
all_thermos.flatten.map do |thermo|
|
|
39
|
-
|
|
40
|
-
usn = thermo[:params]['USN']
|
|
41
|
-
Renstar::Thermostat.new(location, usn)
|
|
39
|
+
Renstar::Thermostat.new(thermo[:params]['Location'], thermo[:params]['USN'])
|
|
42
40
|
end
|
|
43
41
|
end
|
|
44
42
|
|
|
@@ -54,27 +52,14 @@ module Renstar
|
|
|
54
52
|
end
|
|
55
53
|
|
|
56
54
|
def heat(heattemp = nil)
|
|
57
|
-
|
|
58
|
-
if heattemp
|
|
59
|
-
cooltemp = heattemp.to_i + 1
|
|
60
|
-
else
|
|
61
|
-
cooltemp = @cached_info.cooltemp
|
|
62
|
-
heattemp = @cached_info.heattemp
|
|
63
|
-
end
|
|
55
|
+
cooltemp, heattemp = set_temps(heattemp, 1)
|
|
64
56
|
response = control("mode": 1, "cooltemp": cooltemp, "heattemp": heattemp)
|
|
65
57
|
update
|
|
66
58
|
response
|
|
67
59
|
end
|
|
68
60
|
|
|
69
61
|
def cool(cooltemp = nil)
|
|
70
|
-
|
|
71
|
-
if cooltemp
|
|
72
|
-
heattemp = cooltemp.to_i - 1
|
|
73
|
-
# heattemp = cooltemp - @cached_info.setpointdelta
|
|
74
|
-
else
|
|
75
|
-
cooltemp = @cached_info.cooltemp
|
|
76
|
-
heattemp = @cached_info.heattemp
|
|
77
|
-
end
|
|
62
|
+
cooltemp, heattemp = set_temps(cooltemp, 2)
|
|
78
63
|
response = control("mode": 2, "cooltemp": cooltemp, "heattemp": heattemp)
|
|
79
64
|
update
|
|
80
65
|
response
|
|
@@ -134,5 +119,24 @@ module Renstar
|
|
|
134
119
|
update
|
|
135
120
|
response
|
|
136
121
|
end
|
|
122
|
+
|
|
123
|
+
private
|
|
124
|
+
|
|
125
|
+
def set_temps(temp, mode)
|
|
126
|
+
update
|
|
127
|
+
if temp
|
|
128
|
+
if mode == 1
|
|
129
|
+
cooltemp = temp.to_i + 1
|
|
130
|
+
heattemp = temp.to_i
|
|
131
|
+
else
|
|
132
|
+
cooltemp = temp.to_i
|
|
133
|
+
heattemp = temp.to_i - 1
|
|
134
|
+
end
|
|
135
|
+
else
|
|
136
|
+
cooltemp = @cached_info.cooltemp
|
|
137
|
+
heattemp = @cached_info.heattemp
|
|
138
|
+
end
|
|
139
|
+
[cooltemp, heattemp]
|
|
140
|
+
end
|
|
137
141
|
end
|
|
138
142
|
end
|
data/lib/renstar/version.rb
CHANGED
data/renstar.gemspec
CHANGED
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
|
|
31
31
|
spec.add_runtime_dependency 'json'
|
|
32
32
|
spec.add_runtime_dependency 'ssdp', '~> 1.2.0'
|
|
33
|
+
spec.add_development_dependency 'minitest', '~> 5.25'
|
|
33
34
|
|
|
34
35
|
# Uncomment to register a new dependency of your gem
|
|
35
36
|
# spec.add_dependency "example-gem", "~> 1.0"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
5
|
+
rbenv_bin="${RBENV_BIN:-$HOME/.rbenv/bin/rbenv}"
|
|
6
|
+
supported_branches=(3.3 3.4 4.0)
|
|
7
|
+
|
|
8
|
+
if [[ ! -x "$rbenv_bin" ]]; then
|
|
9
|
+
echo "rbenv was not found at $rbenv_bin" >&2
|
|
10
|
+
exit 1
|
|
11
|
+
fi
|
|
12
|
+
|
|
13
|
+
export PATH="$(dirname "$rbenv_bin"):$HOME/.rbenv/shims:$PATH"
|
|
14
|
+
|
|
15
|
+
mapfile -t installed_versions < <("$rbenv_bin" versions --bare)
|
|
16
|
+
|
|
17
|
+
resolve_version() {
|
|
18
|
+
local branch="$1"
|
|
19
|
+
local version=""
|
|
20
|
+
|
|
21
|
+
for candidate in "${installed_versions[@]}"; do
|
|
22
|
+
if [[ "$candidate" == "$branch"* ]]; then
|
|
23
|
+
version="$candidate"
|
|
24
|
+
fi
|
|
25
|
+
done
|
|
26
|
+
|
|
27
|
+
if [[ -n "$version" ]]; then
|
|
28
|
+
printf '%s\n' "$version"
|
|
29
|
+
return 0
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
return 1
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
status=0
|
|
36
|
+
|
|
37
|
+
cd "$repo_root"
|
|
38
|
+
|
|
39
|
+
for branch in "${supported_branches[@]}"; do
|
|
40
|
+
if version="$(resolve_version "$branch")"; then
|
|
41
|
+
echo "==> Running tests on Ruby $version"
|
|
42
|
+
if ! RBENV_VERSION="$version" "$rbenv_bin" exec ruby -Itest \
|
|
43
|
+
-e 'Dir.glob("test/**/*_test.rb").sort.each { |file| require File.expand_path(file) }'; then
|
|
44
|
+
status=1
|
|
45
|
+
fi
|
|
46
|
+
else
|
|
47
|
+
echo "Missing rbenv Ruby for supported branch $branch" >&2
|
|
48
|
+
status=1
|
|
49
|
+
fi
|
|
50
|
+
done
|
|
51
|
+
|
|
52
|
+
exit "$status"
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
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.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Rodrigues
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: json
|
|
@@ -38,6 +37,20 @@ dependencies:
|
|
|
38
37
|
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: 1.2.0
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: minitest
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '5.25'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '5.25'
|
|
41
54
|
description: Control Venstar thermostats with Ruby via their local API.
|
|
42
55
|
email:
|
|
43
56
|
- mikebrodrigues@gmail.com
|
|
@@ -48,6 +61,7 @@ executables:
|
|
|
48
61
|
extensions: []
|
|
49
62
|
extra_rdoc_files: []
|
|
50
63
|
files:
|
|
64
|
+
- ".github/workflows/ci.yml"
|
|
51
65
|
- ".gitignore"
|
|
52
66
|
- ".ruby-version"
|
|
53
67
|
- Gemfile
|
|
@@ -72,13 +86,13 @@ files:
|
|
|
72
86
|
- lib/renstar/thermostat.rb
|
|
73
87
|
- lib/renstar/version.rb
|
|
74
88
|
- renstar.gemspec
|
|
89
|
+
- script/test-supported-rubies
|
|
75
90
|
homepage: https://github.com/mikerodrigues/renstar
|
|
76
91
|
licenses: []
|
|
77
92
|
metadata:
|
|
78
93
|
allowed_push_host: https://rubygems.org
|
|
79
94
|
homepage_uri: https://github.com/mikerodrigues/renstar
|
|
80
95
|
source_code_uri: https://github.com/mikerodrigues/renstar
|
|
81
|
-
post_install_message:
|
|
82
96
|
rdoc_options: []
|
|
83
97
|
require_paths:
|
|
84
98
|
- lib
|
|
@@ -93,8 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
93
107
|
- !ruby/object:Gem::Version
|
|
94
108
|
version: '0'
|
|
95
109
|
requirements: []
|
|
96
|
-
rubygems_version: 3.
|
|
97
|
-
signing_key:
|
|
110
|
+
rubygems_version: 3.6.9
|
|
98
111
|
specification_version: 4
|
|
99
112
|
summary: Control Venstar thermostats.
|
|
100
113
|
test_files: []
|