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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0fd6a7f7c874793188d8d6b122b91ba813e3dd4c5d9a86797c95a856e7f225e
4
- data.tar.gz: d7bdaf9cba6b8953b9962d4b8de5bea5fef5ca32b64908f411ec57f53184fe96
3
+ metadata.gz: 6c47c9b93e12c6532fdc59cdefa80fe2d606ba3d92230f0351af61fcc273186f
4
+ data.tar.gz: ac04c05eebed919e016623e3d8663444319c062bc939dce255488ddba27c9dbf
5
5
  SHA512:
6
- metadata.gz: eff7363dd9cc0e1d534457c70e3d9e4eb19f1ec7f227ebd716d68e872ff57781b7fd580fada066edb6364274b0487347ccc27998c4045ce04a10b08c5d19eac4
7
- data.tar.gz: cd5d733914c964db662b707bb40bb5bc1abc01797204eadfdb501c0abf91a085c3716a4e13e5e02fdd439c8ea678b364061219bf5a72a96e21d72a2037b081d4
6
+ metadata.gz: f912d9d6000ed4328803b9be5729261f27aa19e4b66e8aab35bbb9240559de2357947bdb8c7620833d55cc142c26535f14d5ac132d97a40805a6a755a9e24878
7
+ data.tar.gz: 87cc8c7e90b8c9311b0b92cd7038abd25f7ac276f8f5cc07098dfc747a540abf620e5e0fc9630f46ae614f3620e7b9ff545451b8a0da0859a94f413e7ee31a25
@@ -2,4 +2,4 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.5.0
5
- before_install: gem install bundler -v 1.16.1
5
+ before_install: gem install bundler -v 2.0.2
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. -->
@@ -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
@@ -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"
@@ -1,3 +1,3 @@
1
1
  module NatureRemo
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
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.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: 2019-11-19 00:00:00.000000000 Z
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.0.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