nature_remo 0.4.0 → 0.6.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: 5a60356bea96fa09e00aa147db2e9f91b0fcec96771ddd5e07bcf1c3fa231968
4
+ data.tar.gz: 23c7d98e040a99e0c2f8a7fa6fbb6d336148d0e324e59749f7b69fc2199cd62f
5
5
  SHA512:
6
- metadata.gz: eff7363dd9cc0e1d534457c70e3d9e4eb19f1ec7f227ebd716d68e872ff57781b7fd580fada066edb6364274b0487347ccc27998c4045ce04a10b08c5d19eac4
7
- data.tar.gz: cd5d733914c964db662b707bb40bb5bc1abc01797204eadfdb501c0abf91a085c3716a4e13e5e02fdd439c8ea678b364061219bf5a72a96e21d72a2037b081d4
6
+ metadata.gz: bbeb54be18aaa83484c83545af83abe97315780cca804696179fcc18be67c4055de6041490a34f2a1e2824dbfb4b5add3e563e8aee4ffd7ef17212cec15c9abb
7
+ data.tar.gz: dea3a7bd2cdba7d6f757de5b62df9734e9ef7b93f04f477635eb1d29cbac43fc455e37e5a53661d202c7658a0f39eee3d34ffa2953b8d6235dd2bfa8f143bf1c
@@ -0,0 +1,84 @@
1
+ name: Docker
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ tags: [ 'v*.*.*' ]
7
+ pull_request:
8
+ branches: [ master ]
9
+
10
+ env:
11
+ REGISTRY: ghcr.io
12
+ # github.repository as <account>/<repo>
13
+ IMAGE_NAME: ${{ github.repository }}
14
+
15
+
16
+ jobs:
17
+ build:
18
+
19
+ runs-on: ubuntu-latest
20
+ permissions:
21
+ contents: read
22
+ packages: write
23
+ # This is used to complete the identity challenge
24
+ # with sigstore/fulcio when running outside of PRs.
25
+ id-token: write
26
+
27
+ steps:
28
+ - name: Checkout repository
29
+ uses: actions/checkout@v3
30
+
31
+ # Install the cosign tool except on PR
32
+ # https://github.com/sigstore/cosign-installer
33
+ - name: Install cosign
34
+ if: github.event_name != 'pull_request'
35
+ uses: sigstore/cosign-installer@d6a3abf1bdea83574e28d40543793018b6035605
36
+ with:
37
+ cosign-release: 'v1.7.1'
38
+
39
+
40
+ # Workaround: https://github.com/docker/build-push-action/issues/461
41
+ - name: Setup Docker buildx
42
+ uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
43
+
44
+ # Login against a Docker registry except on PR
45
+ # https://github.com/docker/login-action
46
+ - name: Log into registry ${{ env.REGISTRY }}
47
+ if: github.event_name != 'pull_request'
48
+ uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
49
+ with:
50
+ registry: ${{ env.REGISTRY }}
51
+ username: ${{ github.actor }}
52
+ password: ${{ secrets.GITHUB_TOKEN }}
53
+
54
+ # Extract metadata (tags, labels) for Docker
55
+ # https://github.com/docker/metadata-action
56
+ - name: Extract Docker metadata
57
+ id: meta
58
+ uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
59
+ with:
60
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
61
+
62
+ # Build and push Docker image with Buildx (don't push on PR)
63
+ # https://github.com/docker/build-push-action
64
+ - name: Build and push Docker image
65
+ id: build-and-push
66
+ uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
67
+ with:
68
+ context: .
69
+ push: ${{ github.event_name != 'pull_request' }}
70
+ tags: ${{ steps.meta.outputs.tags }}
71
+ labels: ${{ steps.meta.outputs.labels }}
72
+
73
+ # Sign the resulting Docker image digest except on PRs.
74
+ # This will only write to the public Rekor transparency log when the Docker
75
+ # repository is public to avoid leaking data. If you would like to publish
76
+ # transparency data even for private images, pass --force to cosign below.
77
+ # https://github.com/sigstore/cosign
78
+ - name: Sign the published Docker image
79
+ if: ${{ github.event_name != 'pull_request' }}
80
+ env:
81
+ COSIGN_EXPERIMENTAL: "true"
82
+ # This step uses the identity token to provision an ephemeral certificate
83
+ # against the sigstore community Fulcio instance.
84
+ run: cosign sign ${{ steps.meta.outputs.tags }}@${{ steps.build-and-push.outputs.digest }}
@@ -0,0 +1,33 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on: [push, pull_request]
11
+
12
+ jobs:
13
+ test:
14
+
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ ruby-version: ['3.1.2']
19
+
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - name: Set up Ruby
23
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
24
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
25
+ # uses: ruby/setup-ruby@v1
26
+ uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: ${{ matrix.ruby-version }}
29
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
30
+ - name: Run tests
31
+ env:
32
+ NATURE_TOKEN: ${{ secrets.NATURE_TOKEN }}
33
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## v0.5.1
2
+ - https://github.com/ichi-t/nature_remo/pull/22
3
+
1
4
  ## v0.4.0
2
5
  - make it possible to get **illumination** value
3
6
 
data/Dockerfile ADDED
@@ -0,0 +1,12 @@
1
+ FROM ruby:3.1.2
2
+ LABEL mainteiner="taisuke_ichimura@icloud.com"
3
+
4
+ WORKDIR /app
5
+ COPY ./ /app/
6
+
7
+ RUN gem update --system && \
8
+ gem install bundler -v 2.3.14 && \
9
+ bundle _2.3.14_ install && \
10
+ bundle _2.3.14_ exec rake install:local
11
+
12
+ ENTRYPOINT ["natureremo"]
data/Gemfile.lock CHANGED
@@ -1,31 +1,33 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nature_remo (0.4.0)
5
- faraday (~> 0.17.0)
6
- launchy (~> 2.4.3)
7
- thor (~> 0.20.3)
4
+ nature_remo (0.6.0)
5
+ faraday (~> 2.3.0)
6
+ launchy (~> 2.5.0)
7
+ thor (~> 1.2.1)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- addressable (2.7.0)
12
+ addressable (2.8.0)
13
13
  public_suffix (>= 2.0.2, < 5.0)
14
- crack (0.4.3)
15
- safe_yaml (~> 1.0.0)
16
- faraday (0.17.0)
17
- multipart-post (>= 1.2, < 3)
18
- hashdiff (1.0.0)
19
- launchy (2.4.3)
20
- addressable (~> 2.3)
21
- minitest (5.13.0)
22
- multipart-post (2.1.1)
23
- public_suffix (4.0.1)
24
- rake (13.0.1)
25
- safe_yaml (1.0.5)
26
- thor (0.20.3)
27
- webmock (3.7.6)
28
- addressable (>= 2.3.6)
14
+ crack (0.4.5)
15
+ rexml
16
+ faraday (2.3.0)
17
+ faraday-net_http (~> 2.0)
18
+ ruby2_keywords (>= 0.0.4)
19
+ faraday-net_http (2.0.3)
20
+ hashdiff (1.0.1)
21
+ launchy (2.5.0)
22
+ addressable (~> 2.7)
23
+ minitest (5.15.0)
24
+ public_suffix (4.0.7)
25
+ rake (13.0.6)
26
+ rexml (3.2.5)
27
+ ruby2_keywords (0.0.5)
28
+ thor (1.2.1)
29
+ webmock (3.14.0)
30
+ addressable (>= 2.8.0)
29
31
  crack (>= 0.3.2)
30
32
  hashdiff (>= 0.4.0, < 2.0.0)
31
33
 
@@ -33,11 +35,11 @@ PLATFORMS
33
35
  ruby
34
36
 
35
37
  DEPENDENCIES
36
- bundler (~> 2.0.2)
37
- minitest (~> 5.13.0)
38
+ bundler (~> 2.3.14)
39
+ minitest (~> 5.15.0)
38
40
  nature_remo!
39
- rake (~> 13.0.1)
40
- webmock (~> 3.7.6)
41
+ rake (~> 13.0.6)
42
+ webmock (~> 3.14.0)
41
43
 
42
44
  BUNDLED WITH
43
- 2.0.2
45
+ 2.3.14
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # NatureRemo
2
2
 
3
- [![Build Status](https://travis-ci.org/ichi-t/nature_remo.svg?branch=master)](https://travis-ci.org/ichi-t/nature_remo)
3
+ [![Ruby](https://github.com/ichi-t/nature_remo/actions/workflows/ruby.yml/badge.svg?branch=master)](https://github.com/ichi-t/nature_remo/actions/workflows/ruby.yml)
4
4
  [![Gem Version](https://badge.fury.io/rb/nature_remo.svg)](https://badge.fury.io/rb/nature_remo)
5
5
 
6
6
  Nature Remo API client
@@ -60,6 +60,10 @@ client.send_signal(<signal id>, interval: 500, times: 10)
60
60
  natureremo temp # Get temperature and humidity
61
61
  natureremo illu # Get illumination
62
62
 
63
+ ### CLI with Docker
64
+
65
+ docker run --rm -e NATURE_TOKEN='<nature_token>' taisukeichimura/natureremo --help
66
+
63
67
  ### Example
64
68
 
65
69
  #### Control appliance
@@ -86,6 +90,12 @@ Send signal
86
90
 
87
91
  $ natureremo aircon [temperature] [mode] [options]
88
92
 
93
+ $ natureremo aircon_off
94
+ $ natureremo aircon_on
95
+
96
+ $ natureremo aircon_change_temperature +1
97
+ $ natureremo aircon_change_temperature -1
98
+
89
99
  <!-- ## Development -->
90
100
 
91
101
  <!-- 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"
@@ -57,8 +75,12 @@ module NatureRemo
57
75
  end
58
76
  end
59
77
 
78
+ def remo
79
+ JSON.parse(devices.body).find { |device| device['firmware_version'].match(/Remo\/\d+\.\d+\.\d+-[a-z0-9]+/) }
80
+ end
81
+
60
82
  def events
61
- JSON.parse(devices.body)[0]['newest_events']
83
+ remo['newest_events']
62
84
  end
63
85
 
64
86
  def get_temp
@@ -1,3 +1,3 @@
1
1
  module NatureRemo
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
data/nature_remo.gemspec CHANGED
@@ -29,11 +29,11 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ['lib']
31
31
 
32
- spec.add_development_dependency 'bundler', '~> 2.0.2'
33
- spec.add_development_dependency 'minitest', '~> 5.13.0'
34
- spec.add_development_dependency 'rake', '~> 13.0.1'
35
- spec.add_development_dependency 'webmock', '~> 3.7.6'
36
- spec.add_runtime_dependency 'faraday', '~> 0.17.0'
37
- spec.add_runtime_dependency 'launchy', '~> 2.4.3'
38
- spec.add_runtime_dependency 'thor', '~> 0.20.3'
32
+ spec.add_development_dependency 'bundler', '~> 2.3.14'
33
+ spec.add_development_dependency 'minitest', '~> 5.15.0'
34
+ spec.add_development_dependency 'rake', '~> 13.0.6'
35
+ spec.add_development_dependency 'webmock', '~> 3.14.0'
36
+ spec.add_runtime_dependency 'faraday', '~> 2.3.0'
37
+ spec.add_runtime_dependency 'launchy', '~> 2.5.0'
38
+ spec.add_runtime_dependency 'thor', '~> 1.2.1'
39
39
  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.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ichi-t
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2022-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,99 +16,99 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.2
19
+ version: 2.3.14
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.2
26
+ version: 2.3.14
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 5.13.0
33
+ version: 5.15.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 5.13.0
40
+ version: 5.15.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 13.0.1
47
+ version: 13.0.6
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 13.0.1
54
+ version: 13.0.6
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: webmock
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.7.6
61
+ version: 3.14.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.7.6
68
+ version: 3.14.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: faraday
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.17.0
75
+ version: 2.3.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.17.0
82
+ version: 2.3.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: launchy
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 2.4.3
89
+ version: 2.5.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 2.4.3
96
+ version: 2.5.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: thor
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.20.3
103
+ version: 1.2.1
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.20.3
111
- description:
110
+ version: 1.2.1
111
+ description:
112
112
  email:
113
113
  - taisuke_ichimura@icloud.com
114
114
  executables:
@@ -117,10 +117,12 @@ extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
119
  - ".github/ISSUE_TEMPLATE/feature_request.md"
120
+ - ".github/workflows/docker-publish.yml"
121
+ - ".github/workflows/ruby.yml"
120
122
  - ".gitignore"
121
- - ".travis.yml"
122
123
  - CHANGELOG.md
123
124
  - CODE_OF_CONDUCT.md
125
+ - Dockerfile
124
126
  - Gemfile
125
127
  - Gemfile.lock
126
128
  - LICENSE.txt
@@ -136,7 +138,7 @@ homepage: https://github.com/ichi-t/nature_remo
136
138
  licenses:
137
139
  - MIT
138
140
  metadata: {}
139
- post_install_message:
141
+ post_install_message:
140
142
  rdoc_options: []
141
143
  require_paths:
142
144
  - lib
@@ -151,8 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
153
  - !ruby/object:Gem::Version
152
154
  version: '0'
153
155
  requirements: []
154
- rubygems_version: 3.0.3
155
- signing_key:
156
+ rubygems_version: 3.3.7
157
+ signing_key:
156
158
  specification_version: 4
157
159
  summary: Nature Remo API client written by Ruby
158
160
  test_files: []
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.5.0
5
- before_install: gem install bundler -v 1.16.1