nature_remo 0.4.0 → 0.5.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/.travis.yml +1 -1
- data/README.md +6 -0
- data/lib/nature_remo/cli.rb +54 -0
- data/lib/nature_remo/client.rb +18 -0
- data/lib/nature_remo/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c47c9b93e12c6532fdc59cdefa80fe2d606ba3d92230f0351af61fcc273186f
|
4
|
+
data.tar.gz: ac04c05eebed919e016623e3d8663444319c062bc939dce255488ddba27c9dbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f912d9d6000ed4328803b9be5729261f27aa19e4b66e8aab35bbb9240559de2357947bdb8c7620833d55cc142c26535f14d5ac132d97a40805a6a755a9e24878
|
7
|
+
data.tar.gz: 87cc8c7e90b8c9311b0b92cd7038abd25f7ac276f8f5cc07098dfc747a540abf620e5e0fc9630f46ae614f3620e7b9ff545451b8a0da0859a94f413e7ee31a25
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -86,6 +86,12 @@ Send signal
|
|
86
86
|
|
87
87
|
$ natureremo aircon [temperature] [mode] [options]
|
88
88
|
|
89
|
+
$ natureremo aircon_off
|
90
|
+
$ natureremo aircon_on
|
91
|
+
|
92
|
+
$ natureremo aircon_change_temperature +1
|
93
|
+
$ natureremo aircon_change_temperature -1
|
94
|
+
|
89
95
|
<!-- ## Development -->
|
90
96
|
|
91
97
|
<!-- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. -->
|
data/lib/nature_remo/cli.rb
CHANGED
@@ -55,6 +55,60 @@ module NatureRemo
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
desc 'aircon_off', 'Turn off air conditioner'
|
59
|
+
def aircon_off()
|
60
|
+
aircon_id = []
|
61
|
+
appliances_body.each_with_index do |a, i|
|
62
|
+
aircon_id << get_appliance_id(i) if a['type'] == 'AC'
|
63
|
+
end
|
64
|
+
|
65
|
+
if aircon_id.length == 1
|
66
|
+
client.aircon_off aircon_id.first
|
67
|
+
else
|
68
|
+
puts 'This method supports only one air conditioner'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
desc 'aircon_on', 'Turn on air conditioner'
|
73
|
+
def aircon_on()
|
74
|
+
aircon_id = []
|
75
|
+
appliances_body.each_with_index do |a, i|
|
76
|
+
aircon_id << get_appliance_id(i) if a['type'] == 'AC'
|
77
|
+
end
|
78
|
+
|
79
|
+
if aircon_id.length == 1
|
80
|
+
client.aircon_on aircon_id.first
|
81
|
+
else
|
82
|
+
puts 'This method supports only one air conditioner'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
desc 'aircon_change_temperature', 'Change the temperature of the air conditioner'
|
87
|
+
def aircon_change_temperature(difference)
|
88
|
+
diff = difference.to_i
|
89
|
+
return if diff == 0
|
90
|
+
|
91
|
+
aircon_id = []
|
92
|
+
appliance = nil
|
93
|
+
appliances_body.each_with_index do |a, i|
|
94
|
+
appliance = a
|
95
|
+
aircon_id << get_appliance_id(i) if a['type'] == 'AC'
|
96
|
+
end
|
97
|
+
|
98
|
+
if aircon_id.length == 1
|
99
|
+
current_temperature = appliance["settings"]["temp"].to_i
|
100
|
+
if current_temperature != 0
|
101
|
+
client.aircon_setting aircon_id.first, current_temperature + diff
|
102
|
+
|
103
|
+
puts "Temperature set to #{current_temperature + diff}"
|
104
|
+
else
|
105
|
+
puts 'Could not retrieve the air conditioner currently set temperature'
|
106
|
+
end
|
107
|
+
else
|
108
|
+
puts 'This method supports only one air conditioner'
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
58
112
|
desc 'temp', 'Get temperature and humidity'
|
59
113
|
def temp
|
60
114
|
value = client.events
|
data/lib/nature_remo/client.rb
CHANGED
@@ -46,6 +46,24 @@ module NatureRemo
|
|
46
46
|
results
|
47
47
|
end
|
48
48
|
|
49
|
+
def aircon_on(appliance)
|
50
|
+
@client.post do |req|
|
51
|
+
req.url "/1/appliances/#{appliance}/aircon_settings"
|
52
|
+
req.body = {
|
53
|
+
button: ""
|
54
|
+
}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def aircon_off(appliance)
|
59
|
+
@client.post do |req|
|
60
|
+
req.url "/1/appliances/#{appliance}/aircon_settings"
|
61
|
+
req.body = {
|
62
|
+
button: "power-off"
|
63
|
+
}
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
49
67
|
def aircon_setting(appliance, temp = nil, mode = nil, volume = nil)
|
50
68
|
@client.post do |req|
|
51
69
|
req.url "/1/appliances/#{appliance}/aircon_settings"
|
data/lib/nature_remo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nature_remo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ichi-t
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
requirements: []
|
154
|
-
rubygems_version: 3.
|
154
|
+
rubygems_version: 3.1.2
|
155
155
|
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: Nature Remo API client written by Ruby
|