renstar 0.2.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c893e454f0d89cfacea09754a34ce55b14b327a821131fa3f91519d4fb82d194
4
- data.tar.gz: 8fea02226bfcd4ec43a170d10cf830ed86430e8ccff222ae81de34933215a8c6
3
+ metadata.gz: 6e0023780425b4b2d649ffaaf881630adb1485a8c54e58934f69c31ba4953bd5
4
+ data.tar.gz: ebbef10e2b31c0c51aa5de4c8b02b82ec6f5d29be6d4526f4ec15c5cbdffde62
5
5
  SHA512:
6
- metadata.gz: 66f8f9dd14a24154e426a77fb27bbf907390751e7291a36b88078b4be451b1e264095482b0d5336dfe587837d69e18cf0d573af2b00d65f13402e88b5b8f21d9
7
- data.tar.gz: b80c4954be1b7ca521c7ccf0d630b84215e1480082cbd0deabe2408b964d21c72d509826366efc671c682f473e2e6250cbb23985b590a32b82bd5bcfab17487e
6
+ metadata.gz: d36ebe45f2767dc4ed9f45f1299828004985fffe6c790913e5a1fad386ba23a59fd25347bb746ce0a2f9d8a88a448c952bfa707d77cfed9522e131477fc6f968
7
+ data.tar.gz: 4ae3c1982c6df2f82e05f45410002259df1a8c21113039dc4d9d4b2484819d432e2584109eb72683a3684e46d55519fe79b3342047904a32c68c7dae5c97db9f
data/README.md CHANGED
@@ -20,13 +20,69 @@ Or install it yourself as:
20
20
 
21
21
  $ gem install renstar
22
22
 
23
- ## Usage
23
+ ## Using the included binary
24
+
25
+ When installing the gem, we install `renstar.rb` for you automatically. You can
26
+ pass the `-h` flag for more info.
27
+
28
+ The help page does not list all the accepted commands or their values but all of
29
+ the methods below are supported. The binary just passes your arguments to the
30
+ methods below.
31
+
32
+ So, if you want to cool your house to 72 using the binary, you can do this:
33
+ ```ruby
34
+ renstar.rb cool 72
35
+ ```
36
+
37
+ You can apply the logic above to any of the methods below for the same effect.
38
+
39
+ The binary chooses the first thermostat it finds on the network, so you may get
40
+ unexpected results if you have more than one on your network. I do plan on
41
+ improving this.
42
+
43
+ You may have trouble with discovery on multi-homed hosts, but I'm working with
44
+ the author of the `ssdp` library to fix this, so I expect it to improve. You can
45
+ install my fork of `ssdp` from github if you need multi-homed support now.
46
+
47
+ ## Using the library
48
+
49
+ First we need to create a `Thermostat` object.
24
50
 
25
51
  * Search for thermostats on the LAN, return the first one found:
26
52
  ```ruby
27
53
  thermo = Renstar::Thermostat.search.first
28
54
  ```
29
55
 
56
+ ### Query
57
+
58
+ These methods let you see the thermostat info (controls and settings status), sensor info, runtimes, and
59
+ alerts.
60
+
61
+ * Get information about the thermostat:
62
+ ```ruby
63
+ thermo.info
64
+ ```
65
+
66
+ * Get the current sensors and their readings:
67
+ ```ruby
68
+ thermo.sensors
69
+ ```
70
+
71
+ * Get runtimes:
72
+ ```ruby
73
+ thermo.runtimes
74
+ ```
75
+
76
+ * See alerts and their status:
77
+ ```ruby
78
+ thermo.alerts
79
+
80
+
81
+ ### Control
82
+
83
+ These methods let you control the thermostat temperature controls, and fan. You
84
+ can use the `info` method to check the current state of these controls.
85
+
30
86
  * Heat to 80 degrees:
31
87
  ```ruby
32
88
  thermo.heat(80)
@@ -42,7 +98,7 @@ thermo.cool(60)
42
98
  thermo.auto(70, 74)
43
99
  ```
44
100
 
45
- * Turn off heeating and/or cooling
101
+ * Turn off heating and/or cooling
46
102
  ```ruby
47
103
  thermo.off
48
104
  ```
@@ -56,7 +112,13 @@ thermo.fan_off
56
112
  thermo.fan_toggle
57
113
  ```
58
114
 
59
- * Control the schedule:
115
+ ### Settings
116
+
117
+ These methods let you change the schedule and vacation settings on your
118
+ thermostat. You can use the `info` method to check the current state of the
119
+ settings.
120
+
121
+ * Set the schedule:
60
122
  ```ruby
61
123
  thermo.schedule_on
62
124
 
@@ -72,8 +134,6 @@ thermo.home
72
134
  thermo.away
73
135
  ```
74
136
 
75
-
76
-
77
137
  ## Development
78
138
 
79
139
  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.
data/bin/renstar.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'renstar'
2
2
  require 'optparse'
3
3
  require 'ostruct'
4
+ require 'pry'
4
5
 
5
6
  options = {}
6
7
 
@@ -38,5 +39,13 @@ thermos.each do |thermo|
38
39
  end
39
40
  puts "Using: " + thermos.first.location + " - " + thermos.first.usn
40
41
  unless (ARGV.nil? || ARGV.empty?)
41
- puts thermos.first.send(*ARGV)
42
+ response = thermos.first.send(*ARGV)
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 }
50
+ end
42
51
  end
@@ -23,18 +23,15 @@ module Renstar
23
23
  @raw_hash
24
24
  end
25
25
 
26
- def human_readable
26
+ def human_readable(type)
27
27
  @raw_hash.map do |key, value|
28
- description = APIClient.key_to_description('runtimes', key)
29
- formatted_value = APIClient.value_to_formatted('runtimes', key, value)
28
+ description = APIClient.key_to_description(type, key)
29
+ formatted_value = APIClient.value_to_formatted(type, key, value)
30
30
  format("%-35<description>s %<formatted_value>s\n",
31
31
  { description: description, formatted_value: formatted_value })
32
32
  end.join
33
33
  end
34
34
 
35
- def pp
36
- puts human_readable
37
- end
38
35
  end
39
36
  end
40
37
  end
@@ -8,6 +8,9 @@ module Renstar
8
8
  # These alerts are for Air filter, Service, and UV Lamp
9
9
  #
10
10
  class Alert < APIObject
11
+ def pp
12
+ puts human_readable('alerts')
13
+ end
11
14
  end
12
15
  end
13
16
  end
@@ -9,6 +9,9 @@ module Renstar
9
9
  # info response from the API for clean access.
10
10
  #
11
11
  class Info < APIObject
12
+ def pp
13
+ puts human_readable('info')
14
+ end
12
15
  end
13
16
  end
14
17
  end
@@ -8,6 +8,9 @@ module Renstar
8
8
  # Breaks down how much time the system spent in various states
9
9
  # like heating or cooling.
10
10
  class Runtime < APIObject
11
+ def pp
12
+ puts human_readable('runtimes')
13
+ end
11
14
  end
12
15
  end
13
16
  end
@@ -7,6 +7,9 @@ module Renstar
7
7
  # Represents an installed sensor in the system
8
8
  # Returns the value of the sensor
9
9
  class Sensor < APIObject
10
+ def pp
11
+ puts human_readable('sensors')
12
+ end
10
13
  end
11
14
  end
12
15
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Renstar
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
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.2.1
4
+ version: 0.3.0
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-08-06 00:00:00.000000000 Z
11
+ date: 2022-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []
94
- rubygems_version: 3.2.22
94
+ rubygems_version: 3.2.33
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Control Venstar thermostats.