switchbot 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +9 -1
- data/README.md +25 -11
- data/lib/switchbot/device.rb +12 -0
- data/lib/switchbot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0691e839ba483c5d26060124779d375adc936d6f9cf6cc9b179ae15ee3868066'
|
4
|
+
data.tar.gz: a8374cc63158ae9a1e9c1bf7baeb2712bae01a7e41e0bdc502e44b36d28a6379
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d4a971bfa546ec047ae64d69e399d0b4e56a9e047d7a479c3680753677d8e5d0488955195159110155483b2f730bc56cba108baba84d9d763ca9df1a221c4e9
|
7
|
+
data.tar.gz: 631a9bc224e3cd0ce794a11735b86c41c4a09fae0ce7c532665eb19d60a3ed91d6f7afa5816f7e1289c1e0e78041a03ee2e8bb9a37f862ffef6776a8a5a4e149
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## Unreleased
|
2
|
-
[full changelog](http://github.com/ytkg/switchbot/compare/v0.
|
2
|
+
[full changelog](http://github.com/ytkg/switchbot/compare/v0.3.0...main)
|
3
|
+
|
4
|
+
## v0.3.0
|
5
|
+
[full changelog](http://github.com/ytkg/switchbot/compare/v0.2.0...v0.3.0)
|
6
|
+
|
7
|
+
* Add `Device#on` and `Device#off`
|
8
|
+
* https://github.com/ytkg/switchbot/pull/4
|
9
|
+
* Add Device#commands
|
10
|
+
* https://github.com/ytkg/switchbot/pull/3
|
3
11
|
|
4
12
|
## v0.2.0
|
5
13
|
[full changelog](http://github.com/ytkg/switchbot/compare/v0.1.0...v0.2.0)
|
data/README.md
CHANGED
@@ -20,13 +20,15 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
```
|
23
|
+
```ruby
|
24
24
|
require 'switchbot'
|
25
25
|
|
26
26
|
client = Switchbot::Client.new('YOUR_TOKEN')
|
27
|
+
```
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
### Get device list
|
30
|
+
GET https://api.switch-bot.com/v1.0/devices
|
31
|
+
```ruby
|
30
32
|
client.devices
|
31
33
|
#=> {:status_code=>100,
|
32
34
|
# :body=>
|
@@ -42,9 +44,11 @@ client.devices
|
|
42
44
|
# :remote_type=>"TV",
|
43
45
|
# :hub_device_id=>"FA7310762361"}]},
|
44
46
|
# :message=>"success"}
|
47
|
+
```
|
45
48
|
|
46
|
-
|
47
|
-
|
49
|
+
### Get device status
|
50
|
+
GET https://api.switch-bot.com/v1.0/devices/C271111EC0AB/status
|
51
|
+
```ruby
|
48
52
|
client.status(device_id: 'C271111EC0AB')
|
49
53
|
# or
|
50
54
|
client.device('C271111EC0AB').status
|
@@ -56,16 +60,24 @@ client.device('C271111EC0AB').status
|
|
56
60
|
# :humidity=>52,
|
57
61
|
# :temperature=>26.1},
|
58
62
|
# :message=>"success"}
|
63
|
+
```
|
59
64
|
|
60
|
-
|
61
|
-
|
65
|
+
### Send device control commands
|
66
|
+
POST https://api.switch-bot.com/v1.0/devices/210/commands
|
67
|
+
```ruby
|
62
68
|
client.commands(device_id: '210', command: 'turnOn')
|
69
|
+
# or
|
70
|
+
client.device('C271111EC0AB').commands(command: 'turnOn')
|
71
|
+
# or
|
72
|
+
client.device('C271111EC0AB').on
|
63
73
|
#=> {:status_code=>100,
|
64
74
|
# :body=>{},
|
65
75
|
# :message=>"success"}
|
76
|
+
```
|
66
77
|
|
67
|
-
|
68
|
-
|
78
|
+
### Get scene list
|
79
|
+
GET https://api.switch-bot.com/v1.0/scenes
|
80
|
+
```ruby
|
69
81
|
client.scenes
|
70
82
|
#=> {:status_code=>100,
|
71
83
|
# :body=>
|
@@ -80,9 +92,11 @@ client.scenes
|
|
80
92
|
# {:scene_id=>"T02-202011062059-26364981",
|
81
93
|
# :scene_name=>"Set Bedroom to 26 degree"}],
|
82
94
|
# :message=>"success"}
|
95
|
+
```
|
83
96
|
|
84
|
-
|
85
|
-
|
97
|
+
### Execute manual scenes
|
98
|
+
POST https://api.switch-bot.com/v1.0/scenes/T02-202009221414-48924101/execute
|
99
|
+
```ruby
|
86
100
|
client.execute(scene_id: 'T02-202009221414-48924101')
|
87
101
|
# or
|
88
102
|
client.scene('T02-202009221414-48924101').execute
|
data/lib/switchbot/device.rb
CHANGED
@@ -12,5 +12,17 @@ module Switchbot
|
|
12
12
|
def status
|
13
13
|
client.status(device_id: device_id)
|
14
14
|
end
|
15
|
+
|
16
|
+
def commands(command:, parameter: 'default', command_type: 'command')
|
17
|
+
client.commands(device_id: device_id, command: command, parameter: parameter, command_type: command_type)
|
18
|
+
end
|
19
|
+
|
20
|
+
def on
|
21
|
+
client.commands(device_id: device_id, command: 'turnOn')
|
22
|
+
end
|
23
|
+
|
24
|
+
def off
|
25
|
+
client.commands(device_id: device_id, command: 'turnOff')
|
26
|
+
end
|
15
27
|
end
|
16
28
|
end
|
data/lib/switchbot/version.rb
CHANGED
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.3.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-
|
11
|
+
date: 2021-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|