switchbot 0.2.0 → 0.3.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: 990f1f755928da1c7b552986461ef23fe759e174fa3bfac50e71c302a1602769
4
- data.tar.gz: cf07e66ff95980862c53a24cda08c930d0e5b51f4c3b08bf17b663198294a5af
3
+ metadata.gz: '0691e839ba483c5d26060124779d375adc936d6f9cf6cc9b179ae15ee3868066'
4
+ data.tar.gz: a8374cc63158ae9a1e9c1bf7baeb2712bae01a7e41e0bdc502e44b36d28a6379
5
5
  SHA512:
6
- metadata.gz: c1aadb12d0af5102103b9304aeae71300ca75e7828552bb43ed778a91c39e6b38999a00717e1e090cc7f388dd7ce024f7ca5b6bb0aa3af562be05b1598c6cf04
7
- data.tar.gz: 774fbf9e8bb38df81d15af448c29aa0b0b1b10a1523f24b545e1181736f2b6692dc0d44a4d34f82e2e3c452aeab34218a63564e3423a1c020384cdf10c83774f
6
+ metadata.gz: 4d4a971bfa546ec047ae64d69e399d0b4e56a9e047d7a479c3680753677d8e5d0488955195159110155483b2f730bc56cba108baba84d9d763ca9df1a221c4e9
7
+ data.tar.gz: 631a9bc224e3cd0ce794a11735b86c41c4a09fae0ce7c532665eb19d60a3ed91d6f7afa5816f7e1289c1e0e78041a03ee2e8bb9a37f862ffef6776a8a5a4e149
data/.rubocop.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  AllCops:
2
+ TargetRubyVersion: 2.5
2
3
  NewCops: enable
3
4
 
4
5
  Style/Documentation:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## Unreleased
2
- [full changelog](http://github.com/ytkg/switchbot/compare/v0.2.0...main)
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
- # Get device list
29
- # GET https://api.switch-bot.com/v1.0/devices
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
- # Get device status
47
- # GET https://api.switch-bot.com/v1.0/devices/C271111EC0AB/status
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
- # Send device control commands
61
- # POST https://api.switch-bot.com/v1.0/devices/210/commands
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
- # Get scene list
68
- # GET https://api.switch-bot.com/v1.0/scenes
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
- # Execute manual scenes
85
- # POST https://api.switch-bot.com/v1.0/scenes/T02-202009221414-48924101/execute
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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchbot
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.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.2.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-04 00:00:00.000000000 Z
11
+ date: 2021-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport