switchbot 0.4.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +2 -1
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +21 -1
- data/lib/switchbot/bot.rb +9 -0
- data/lib/switchbot/client.rb +10 -1
- data/lib/switchbot/color_bulb.rb +21 -0
- data/lib/switchbot/version.rb +1 -1
- data/lib/switchbot.rb +2 -2
- data/switchbot.gemspec +4 -4
- metadata +13 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63cae60c41beb637fe0fea73a634a4ef3e4f4d32354fe3691d16e0e88a24f9fd
|
4
|
+
data.tar.gz: 9a2aa83c764d5595142d2c07e31c5fd8404ab6ceb4e2f9481801498eeb135f3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90501fd6d95b927e0c2d4fb741c384777947765b305ce0e8672f2da72aa62158dc98179cb01f1924af71725cc0d5d2bcf3292e7990f293d543535ba38b16f3f5
|
7
|
+
data.tar.gz: faaf06892d72c0eaf1df45ad1091fcf05e30390d12bac1c3264932216742e2980606fb2b5f050978716b0eb40a0430f5af2f1d2f16c7905ac3b393902603c834
|
data/.github/workflows/main.yml
CHANGED
@@ -7,7 +7,8 @@ jobs:
|
|
7
7
|
runs-on: ubuntu-latest
|
8
8
|
strategy:
|
9
9
|
matrix:
|
10
|
-
|
10
|
+
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
11
|
+
ruby: [2.6, 2.7, '3.0', 3.1]
|
11
12
|
name: Ruby ${{ matrix.ruby }}
|
12
13
|
steps:
|
13
14
|
- uses: actions/checkout@v2
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
## Unreleased
|
2
|
-
[full changelog](http://github.com/ytkg/switchbot/compare/v0.
|
2
|
+
[full changelog](http://github.com/ytkg/switchbot/compare/v0.6.0...main)
|
3
|
+
|
4
|
+
## v0.6.0
|
5
|
+
[full changelog](http://github.com/ytkg/switchbot/compare/v0.5.1...v0.6.0)
|
6
|
+
|
7
|
+
* Add ColorBulb
|
8
|
+
* https://github.com/ytkg/switchbot/pull/14
|
9
|
+
* :bomb: **[BREAKING CHANGE]** Update faraday v2 and Drop support ruby 2.5
|
10
|
+
* https://github.com/ytkg/switchbot/pull/12
|
11
|
+
|
12
|
+
## v0.5.1
|
13
|
+
[full changelog](http://github.com/ytkg/switchbot/compare/v0.5.0...v0.5.1)
|
14
|
+
|
15
|
+
* Enable MFA requirement for gem releasing
|
16
|
+
* https://github.com/ytkg/switchbot/pull/11
|
17
|
+
|
18
|
+
## v0.5.0
|
19
|
+
[full changelog](http://github.com/ytkg/switchbot/compare/v0.4.0...v0.5.0)
|
20
|
+
|
21
|
+
* Add Bot
|
22
|
+
* https://github.com/ytkg/switchbot/pull/9
|
3
23
|
|
4
24
|
## v0.4.0
|
5
25
|
[full changelog](http://github.com/ytkg/switchbot/compare/v0.3.0...v0.4.0)
|
data/lib/switchbot/client.rb
CHANGED
@@ -56,6 +56,10 @@ module Switchbot
|
|
56
56
|
)
|
57
57
|
end
|
58
58
|
|
59
|
+
def bot(device_id)
|
60
|
+
Bot.new(client: self, device_id: device_id)
|
61
|
+
end
|
62
|
+
|
59
63
|
def light(device_id)
|
60
64
|
Light.new(client: self, device_id: device_id)
|
61
65
|
end
|
@@ -64,6 +68,10 @@ module Switchbot
|
|
64
68
|
Humidifier.new(client: self, device_id: device_id)
|
65
69
|
end
|
66
70
|
|
71
|
+
def color_bulb(device_id)
|
72
|
+
ColorBulb.new(client: self, device_id: device_id)
|
73
|
+
end
|
74
|
+
|
67
75
|
private
|
68
76
|
|
69
77
|
def headers
|
@@ -76,12 +84,13 @@ module Switchbot
|
|
76
84
|
def connection
|
77
85
|
Faraday.new(url: API_ENDPOINT, headers: headers) do |conn|
|
78
86
|
conn.request :json
|
87
|
+
conn.response :json
|
79
88
|
end
|
80
89
|
end
|
81
90
|
|
82
91
|
def request(http_method:, endpoint:, params: {})
|
83
92
|
response = connection.public_send(http_method, endpoint, params)
|
84
|
-
|
93
|
+
response.body.deep_transform_keys(&:underscore).deep_symbolize_keys
|
85
94
|
end
|
86
95
|
end
|
87
96
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Switchbot
|
4
|
+
class ColorBulb < Device
|
5
|
+
def toggle
|
6
|
+
commands(command: 'toggle')
|
7
|
+
end
|
8
|
+
|
9
|
+
def brightness(value)
|
10
|
+
commands(command: 'setBrightness', parameter: value)
|
11
|
+
end
|
12
|
+
|
13
|
+
def color(value)
|
14
|
+
commands(command: 'setColor', parameter: value)
|
15
|
+
end
|
16
|
+
|
17
|
+
def color_temperature(value)
|
18
|
+
commands(command: 'setColorTemperature', parameter: value)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/switchbot/version.rb
CHANGED
data/lib/switchbot.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'faraday'
|
4
|
-
require 'faraday_middleware'
|
5
|
-
require 'json'
|
6
4
|
require 'active_support/all'
|
7
5
|
require_relative 'switchbot/version'
|
8
6
|
require_relative 'switchbot/client'
|
9
7
|
require_relative 'switchbot/device'
|
10
8
|
require_relative 'switchbot/scene'
|
9
|
+
require_relative 'switchbot/bot'
|
11
10
|
require_relative 'switchbot/light'
|
12
11
|
require_relative 'switchbot/humidifier'
|
12
|
+
require_relative 'switchbot/color_bulb'
|
13
13
|
|
14
14
|
module Switchbot
|
15
15
|
class Error < StandardError; end
|
data/switchbot.gemspec
CHANGED
@@ -12,13 +12,14 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = 'SwitchBot API client for Ruby'
|
13
13
|
spec.homepage = 'https://github.com/ytkg/switchbot'
|
14
14
|
spec.license = 'MIT'
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
|
16
16
|
|
17
17
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
18
|
|
19
19
|
spec.metadata['homepage_uri'] = spec.homepage
|
20
20
|
spec.metadata['source_code_uri'] = 'https://github.com/ytkg/switchbot'
|
21
21
|
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
22
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
22
23
|
|
23
24
|
# Specify which files should be added to the gem when it is released.
|
24
25
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -31,13 +32,12 @@ Gem::Specification.new do |spec|
|
|
31
32
|
|
32
33
|
# Uncomment to register a new dependency of your gem
|
33
34
|
spec.add_dependency 'activesupport'
|
34
|
-
spec.add_dependency 'faraday', '
|
35
|
-
spec.add_dependency 'faraday_middleware'
|
35
|
+
spec.add_dependency 'faraday', '>= 2.0.0'
|
36
36
|
|
37
37
|
spec.add_development_dependency 'rake', '~> 13.0'
|
38
38
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
39
39
|
spec.add_development_dependency 'rspec-its'
|
40
|
-
spec.add_development_dependency 'rubocop', '
|
40
|
+
spec.add_development_dependency 'rubocop', '>= 1.24.1'
|
41
41
|
spec.add_development_dependency 'webmock'
|
42
42
|
|
43
43
|
# For more information and examples about making a new gem, checkout our
|
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.
|
4
|
+
version: 0.6.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:
|
11
|
+
date: 2022-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -26,32 +26,18 @@ dependencies:
|
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.3.0
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.3.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: faraday_middleware
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
33
|
+
version: 2.0.0
|
48
34
|
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
38
|
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
40
|
+
version: 2.0.0
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rake
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,16 +84,16 @@ dependencies:
|
|
98
84
|
name: rubocop
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
|
-
- - "
|
87
|
+
- - ">="
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
89
|
+
version: 1.24.1
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
|
-
- - "
|
94
|
+
- - ">="
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
96
|
+
version: 1.24.1
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: webmock
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,7 +128,9 @@ files:
|
|
142
128
|
- bin/console
|
143
129
|
- bin/setup
|
144
130
|
- lib/switchbot.rb
|
131
|
+
- lib/switchbot/bot.rb
|
145
132
|
- lib/switchbot/client.rb
|
133
|
+
- lib/switchbot/color_bulb.rb
|
146
134
|
- lib/switchbot/device.rb
|
147
135
|
- lib/switchbot/humidifier.rb
|
148
136
|
- lib/switchbot/light.rb
|
@@ -156,6 +144,7 @@ metadata:
|
|
156
144
|
homepage_uri: https://github.com/ytkg/switchbot
|
157
145
|
source_code_uri: https://github.com/ytkg/switchbot
|
158
146
|
changelog_uri: https://github.com/ytkg/switchbot/blob/main/CHANGELOG.md
|
147
|
+
rubygems_mfa_required: 'true'
|
159
148
|
post_install_message:
|
160
149
|
rdoc_options: []
|
161
150
|
require_paths:
|
@@ -164,14 +153,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
164
153
|
requirements:
|
165
154
|
- - ">="
|
166
155
|
- !ruby/object:Gem::Version
|
167
|
-
version: 2.
|
156
|
+
version: 2.6.0
|
168
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
158
|
requirements:
|
170
159
|
- - ">="
|
171
160
|
- !ruby/object:Gem::Version
|
172
161
|
version: '0'
|
173
162
|
requirements: []
|
174
|
-
rubygems_version: 3.
|
163
|
+
rubygems_version: 3.1.6
|
175
164
|
signing_key:
|
176
165
|
specification_version: 4
|
177
166
|
summary: SwitchBot API client for Ruby
|