switchbot 0.3.0 → 0.4.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: '0691e839ba483c5d26060124779d375adc936d6f9cf6cc9b179ae15ee3868066'
4
- data.tar.gz: a8374cc63158ae9a1e9c1bf7baeb2712bae01a7e41e0bdc502e44b36d28a6379
3
+ metadata.gz: 4fcabea3a356f50c00679284d145c836a4d1e7733bc0bafd3e7670a09c5fdaf4
4
+ data.tar.gz: 2e9b2dc531a3ec7a4cdc4b0449097e5924fe9384b7a6d5f0a1486eb710269843
5
5
  SHA512:
6
- metadata.gz: 4d4a971bfa546ec047ae64d69e399d0b4e56a9e047d7a479c3680753677d8e5d0488955195159110155483b2f730bc56cba108baba84d9d763ca9df1a221c4e9
7
- data.tar.gz: 631a9bc224e3cd0ce794a11735b86c41c4a09fae0ce7c532665eb19d60a3ed91d6f7afa5816f7e1289c1e0e78041a03ee2e8bb9a37f862ffef6776a8a5a4e149
6
+ metadata.gz: 6381fc08df2212f1e64f63d7729a7680d85024704f7c99d258f2b69e0bcad6580795f2ae81cc9bfaba6bd115f751936858bc70df393abfa6517170a81ffad502
7
+ data.tar.gz: fed51bbc4bfa4bcfdeb3b28bf5bcc9756a788f5ba71c959b360c500cfb861f2a576516426e82d1c00ac940d2823570bf1ea049e6558f4d0dea92cd32cd16f8ea
@@ -5,12 +5,16 @@ on: [push,pull_request]
5
5
  jobs:
6
6
  build:
7
7
  runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby: [2.5, 2.6, 2.7]
11
+ name: Ruby ${{ matrix.ruby }}
8
12
  steps:
9
13
  - uses: actions/checkout@v2
10
14
  - name: Set up Ruby
11
15
  uses: ruby/setup-ruby@v1
12
16
  with:
13
- ruby-version: 2.5.7
17
+ ruby-version: ${{ matrix.ruby }}
14
18
  - name: Run the default task
15
19
  run: |
16
20
  gem install bundler -v 2.2.4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## Unreleased
2
- [full changelog](http://github.com/ytkg/switchbot/compare/v0.3.0...main)
2
+ [full changelog](http://github.com/ytkg/switchbot/compare/v0.4.0...main)
3
+
4
+ ## v0.4.0
5
+ [full changelog](http://github.com/ytkg/switchbot/compare/v0.3.0...v0.4.0)
6
+
7
+ * Add Humidifier
8
+ * https://github.com/ytkg/switchbot/pull/7
9
+ * Add Light
10
+ * https://github.com/ytkg/switchbot/pull/6
11
+ * Add Device#on? and Device#off?
12
+ * https://github.com/ytkg/switchbot/pull/5
3
13
 
4
14
  ## v0.3.0
5
15
  [full changelog](http://github.com/ytkg/switchbot/compare/v0.2.0...v0.3.0)
data/lib/switchbot.rb CHANGED
@@ -8,6 +8,8 @@ require_relative 'switchbot/version'
8
8
  require_relative 'switchbot/client'
9
9
  require_relative 'switchbot/device'
10
10
  require_relative 'switchbot/scene'
11
+ require_relative 'switchbot/light'
12
+ require_relative 'switchbot/humidifier'
11
13
 
12
14
  module Switchbot
13
15
  class Error < StandardError; end
@@ -56,6 +56,14 @@ module Switchbot
56
56
  )
57
57
  end
58
58
 
59
+ def light(device_id)
60
+ Light.new(client: self, device_id: device_id)
61
+ end
62
+
63
+ def humidifier(device_id)
64
+ Humidifier.new(client: self, device_id: device_id)
65
+ end
66
+
59
67
  private
60
68
 
61
69
  def headers
@@ -24,5 +24,13 @@ module Switchbot
24
24
  def off
25
25
  client.commands(device_id: device_id, command: 'turnOff')
26
26
  end
27
+
28
+ def on?
29
+ status[:body][:power] == 'on'
30
+ end
31
+
32
+ def off?
33
+ !on?
34
+ end
27
35
  end
28
36
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Switchbot
4
+ class Humidifier < Device
5
+ def mode(value)
6
+ commands(command: 'setMode', parameter: value.to_s)
7
+ end
8
+
9
+ def auto
10
+ mode(:auto)
11
+ end
12
+
13
+ def low
14
+ mode(101)
15
+ end
16
+
17
+ def medium
18
+ mode(102)
19
+ end
20
+
21
+ def high
22
+ mode(103)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Switchbot
4
+ class Light < Device
5
+ def brightness_up
6
+ commands(command: 'brightnessUp')
7
+ end
8
+
9
+ def brightness_down
10
+ commands(command: 'brightnessDown')
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchbot
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshiki Takagi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-06 00:00:00.000000000 Z
11
+ date: 2021-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -144,6 +144,8 @@ files:
144
144
  - lib/switchbot.rb
145
145
  - lib/switchbot/client.rb
146
146
  - lib/switchbot/device.rb
147
+ - lib/switchbot/humidifier.rb
148
+ - lib/switchbot/light.rb
147
149
  - lib/switchbot/scene.rb
148
150
  - lib/switchbot/version.rb
149
151
  - switchbot.gemspec