homebridge-smartthings-oauth 1.0.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.
Files changed (142) hide show
  1. package/.devcontainer/Dockerfile +16 -0
  2. package/.devcontainer/devcontainer.json +36 -0
  3. package/LICENSE +176 -0
  4. package/README.md +114 -0
  5. package/config.schema.json +134 -0
  6. package/dist/auth/auth.d.ts +23 -0
  7. package/dist/auth/auth.d.ts.map +1 -0
  8. package/dist/auth/auth.js +168 -0
  9. package/dist/auth/auth.js.map +1 -0
  10. package/dist/auth/tokenManager.d.ts +36 -0
  11. package/dist/auth/tokenManager.d.ts.map +1 -0
  12. package/dist/auth/tokenManager.js +180 -0
  13. package/dist/auth/tokenManager.js.map +1 -0
  14. package/dist/basePlatformAccessory.d.ts +49 -0
  15. package/dist/basePlatformAccessory.d.ts.map +1 -0
  16. package/dist/basePlatformAccessory.js +209 -0
  17. package/dist/basePlatformAccessory.js.map +1 -0
  18. package/dist/index.d.ts +7 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +7 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/keyValues.d.ts +4 -0
  23. package/dist/keyValues.d.ts.map +1 -0
  24. package/dist/keyValues.js +12 -0
  25. package/dist/keyValues.js.map +1 -0
  26. package/dist/multiServiceAccessory.d.ts +60 -0
  27. package/dist/multiServiceAccessory.d.ts.map +1 -0
  28. package/dist/multiServiceAccessory.js +398 -0
  29. package/dist/multiServiceAccessory.js.map +1 -0
  30. package/dist/platform.d.ts +42 -0
  31. package/dist/platform.d.ts.map +1 -0
  32. package/dist/platform.js +302 -0
  33. package/dist/platform.js.map +1 -0
  34. package/dist/services/airConditionerService.d.ts +52 -0
  35. package/dist/services/airConditionerService.d.ts.map +1 -0
  36. package/dist/services/airConditionerService.js +438 -0
  37. package/dist/services/airConditionerService.js.map +1 -0
  38. package/dist/services/baseService.d.ts +21 -0
  39. package/dist/services/baseService.d.ts.map +1 -0
  40. package/dist/services/baseService.js +63 -0
  41. package/dist/services/baseService.js.map +1 -0
  42. package/dist/services/batteryService.d.ts +10 -0
  43. package/dist/services/batteryService.d.ts.map +1 -0
  44. package/dist/services/batteryService.js +71 -0
  45. package/dist/services/batteryService.js.map +1 -0
  46. package/dist/services/carbonMonoxideDetector.d.ts +11 -0
  47. package/dist/services/carbonMonoxideDetector.d.ts.map +1 -0
  48. package/dist/services/carbonMonoxideDetector.js +28 -0
  49. package/dist/services/carbonMonoxideDetector.js.map +1 -0
  50. package/dist/services/contactSensorService.d.ts +10 -0
  51. package/dist/services/contactSensorService.d.ts.map +1 -0
  52. package/dist/services/contactSensorService.js +28 -0
  53. package/dist/services/contactSensorService.js.map +1 -0
  54. package/dist/services/doorService.d.ts +16 -0
  55. package/dist/services/doorService.d.ts.map +1 -0
  56. package/dist/services/doorService.js +138 -0
  57. package/dist/services/doorService.js.map +1 -0
  58. package/dist/services/fanSpeedService.d.ts +15 -0
  59. package/dist/services/fanSpeedService.d.ts.map +1 -0
  60. package/dist/services/fanSpeedService.js +153 -0
  61. package/dist/services/fanSpeedService.js.map +1 -0
  62. package/dist/services/fanSwitchLevelService.d.ts +14 -0
  63. package/dist/services/fanSwitchLevelService.d.ts.map +1 -0
  64. package/dist/services/fanSwitchLevelService.js +121 -0
  65. package/dist/services/fanSwitchLevelService.js.map +1 -0
  66. package/dist/services/humidityService.d.ts +10 -0
  67. package/dist/services/humidityService.d.ts.map +1 -0
  68. package/dist/services/humidityService.js +23 -0
  69. package/dist/services/humidityService.js.map +1 -0
  70. package/dist/services/leakDetector.d.ts +10 -0
  71. package/dist/services/leakDetector.d.ts.map +1 -0
  72. package/dist/services/leakDetector.js +27 -0
  73. package/dist/services/leakDetector.js.map +1 -0
  74. package/dist/services/lightSensorService.d.ts +10 -0
  75. package/dist/services/lightSensorService.d.ts.map +1 -0
  76. package/dist/services/lightSensorService.js +24 -0
  77. package/dist/services/lightSensorService.js.map +1 -0
  78. package/dist/services/lightService.d.ts +26 -0
  79. package/dist/services/lightService.d.ts.map +1 -0
  80. package/dist/services/lightService.js +340 -0
  81. package/dist/services/lightService.js.map +1 -0
  82. package/dist/services/lockService.d.ts +16 -0
  83. package/dist/services/lockService.d.ts.map +1 -0
  84. package/dist/services/lockService.js +128 -0
  85. package/dist/services/lockService.js.map +1 -0
  86. package/dist/services/motionService.d.ts +10 -0
  87. package/dist/services/motionService.d.ts.map +1 -0
  88. package/dist/services/motionService.js +23 -0
  89. package/dist/services/motionService.js.map +1 -0
  90. package/dist/services/occupancySensorService.d.ts +10 -0
  91. package/dist/services/occupancySensorService.d.ts.map +1 -0
  92. package/dist/services/occupancySensorService.js +23 -0
  93. package/dist/services/occupancySensorService.js.map +1 -0
  94. package/dist/services/sensorService.d.ts +15 -0
  95. package/dist/services/sensorService.d.ts.map +1 -0
  96. package/dist/services/sensorService.js +69 -0
  97. package/dist/services/sensorService.js.map +1 -0
  98. package/dist/services/smartThingsCommand.d.ts +7 -0
  99. package/dist/services/smartThingsCommand.d.ts.map +1 -0
  100. package/dist/services/smartThingsCommand.js +12 -0
  101. package/dist/services/smartThingsCommand.js.map +1 -0
  102. package/dist/services/smokeDetector.d.ts +10 -0
  103. package/dist/services/smokeDetector.d.ts.map +1 -0
  104. package/dist/services/smokeDetector.js +27 -0
  105. package/dist/services/smokeDetector.js.map +1 -0
  106. package/dist/services/statelessProgrammableSwitchService.d.ts +12 -0
  107. package/dist/services/statelessProgrammableSwitchService.d.ts.map +1 -0
  108. package/dist/services/statelessProgrammableSwitchService.js +94 -0
  109. package/dist/services/statelessProgrammableSwitchService.js.map +1 -0
  110. package/dist/services/switchService.d.ts +12 -0
  111. package/dist/services/switchService.d.ts.map +1 -0
  112. package/dist/services/switchService.js +72 -0
  113. package/dist/services/switchService.js.map +1 -0
  114. package/dist/services/temperatureService.d.ts +11 -0
  115. package/dist/services/temperatureService.d.ts.map +1 -0
  116. package/dist/services/temperatureService.js +32 -0
  117. package/dist/services/temperatureService.js.map +1 -0
  118. package/dist/services/thermostatService.d.ts +22 -0
  119. package/dist/services/thermostatService.d.ts.map +1 -0
  120. package/dist/services/thermostatService.js +273 -0
  121. package/dist/services/thermostatService.js.map +1 -0
  122. package/dist/services/valveService.d.ts +12 -0
  123. package/dist/services/valveService.d.ts.map +1 -0
  124. package/dist/services/valveService.js +59 -0
  125. package/dist/services/valveService.js.map +1 -0
  126. package/dist/services/windowCoveringService.d.ts +36 -0
  127. package/dist/services/windowCoveringService.d.ts.map +1 -0
  128. package/dist/services/windowCoveringService.js +158 -0
  129. package/dist/services/windowCoveringService.js.map +1 -0
  130. package/dist/settings.d.ts +9 -0
  131. package/dist/settings.d.ts.map +1 -0
  132. package/dist/settings.js +12 -0
  133. package/dist/settings.js.map +1 -0
  134. package/dist/webhook/subscriptionHandler.d.ts +32 -0
  135. package/dist/webhook/subscriptionHandler.d.ts.map +1 -0
  136. package/dist/webhook/subscriptionHandler.js +68 -0
  137. package/dist/webhook/subscriptionHandler.js.map +1 -0
  138. package/dist/webhook/webhookServer.d.ts +19 -0
  139. package/dist/webhook/webhookServer.d.ts.map +1 -0
  140. package/dist/webhook/webhookServer.js +125 -0
  141. package/dist/webhook/webhookServer.js.map +1 -0
  142. package/package.json +57 -0
@@ -0,0 +1,16 @@
1
+ # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.224.2/containers/typescript-node/.devcontainer/base.Dockerfile
2
+
3
+ # [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 16, 14, 12, 16-bullseye, 14-bullseye, 12-bullseye, 16-buster, 14-buster, 12-buster
4
+ ARG VARIANT="16-bullseye"
5
+ FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}
6
+
7
+ # [Optional] Uncomment this section to install additional OS packages.
8
+ # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
9
+ # && apt-get -y install --no-install-recommends <your-package-list-here>
10
+
11
+ # [Optional] Uncomment if you want to install an additional version of node using nvm
12
+ # ARG EXTRA_NODE_VERSION=10
13
+ # RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
14
+
15
+ # [Optional] Uncomment if you want to install more global node packages
16
+ # RUN su node -c "npm install -g <your-package-list -here>"
@@ -0,0 +1,36 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2
+ // https://github.com/microsoft/vscode-dev-containers/tree/v0.224.2/containers/typescript-node
3
+ {
4
+ "name": "Node.js & TypeScript",
5
+ "build": {
6
+ "dockerfile": "Dockerfile",
7
+ // Update 'VARIANT' to pick a Node version: 16, 14, 12.
8
+ // Append -bullseye or -buster to pin to an OS version.
9
+ // Use -bullseye variants on local on arm64/Apple Silicon.
10
+ "args": {
11
+ "VARIANT": "16-bullseye"
12
+ }
13
+ },
14
+
15
+ // Set *default* container specific settings.json values on container create.
16
+ "settings": {},
17
+
18
+
19
+ // Add the IDs of extensions you want installed when the container is created.
20
+ "extensions": [
21
+ "dbaeumer.vscode-eslint"
22
+ ],
23
+
24
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
25
+ // "forwardPorts": [],
26
+
27
+ // Use 'postCreateCommand' to run commands after the container is created.
28
+ // "postCreateCommand": "yarn install",
29
+
30
+ // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
31
+ "remoteUser": "node",
32
+ "features": {
33
+ "git": "os-provided",
34
+ "sshd": "latest"
35
+ }
36
+ }
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+
2
+ <p align="center">
3
+
4
+ <img src="https://raw.githubusercontent.com/homebridge/branding/latest/logos/homebridge-color-round-stylized.png" width="150">
5
+
6
+ </p>
7
+
8
+ # Smartthings Homebridge Plugin
9
+
10
+ This is a smartthings plugin for Homebridge. This requires no access to the legacy smartthings app, and doesn't
11
+ require a lot of work to install. It will discover devices automatically as well as unregister devices that are removed
12
+ from your smarttthings network. This is currently under development.
13
+
14
+ This is a fork for the homebridge-smartthings plugin created by [@iklein99](https://github.com/iklein99/), which adds oauth support and access token refresh.
15
+
16
+ # Getting Started
17
+ - The [SmartThings CLI](https://github.com/SmartThingsCommunity/smartthings-cli#readme) installed
18
+ - [ngrok](https://ngrok.com/) or similar tool to create a secure tunnel to a publicly available URL
19
+
20
+ ## Instructions
21
+
22
+ ### 1. Set up your server
23
+
24
+ Start ngrok or similar tool to create a secure tunnel to your local server. Note that the free version of ngrok will
25
+ change the subdomain part of the URL every time you restart it.
26
+ Alternately, you can use the paid version which supports reserved subdomains, or any other tool such as cloudflare zero trust tunnels which has a free tier:
27
+ ```
28
+ ngrok http 3000
29
+ ```
30
+ ### 2. Register your SmartThings app
31
+
32
+ Look at the log output of your local server, You should see something like this:
33
+ ```
34
+ Target URL -- Copy this value into the targetUrl field of you app creation request:
35
+ https://315e5367357f.ngrok.app
36
+
37
+ Redirect URI -- Copy this value into redirectUris field of your app creation request:
38
+ https://315e5367357f.ngrok.app/oauth/callback
39
+
40
+ Website URL -- Visit this URL in your browser to log into SmartThings and connect your account:
41
+ https://315e5367357f.ngrok.app
42
+ ```
43
+
44
+ After Installaing the SmartThings CLI, Run the `smartthings apps:create` command to create a new smartthingsAPI app. You will be prompted for the required
45
+ information. The following is an example of the output from the command:
46
+
47
+ ```bash
48
+ ~ % smartthings apps:create
49
+ ? What kind of app do you want to create? (Currently, only OAuth-In apps are supported.) OAuth-In App
50
+
51
+ More information on writing SmartApps can be found at
52
+ https://developer.smartthings.com/docs/connected-services/smartapp-basics
53
+
54
+ ? Display Name My API Subscription App
55
+ ? Description Allows control of SmartThings devices
56
+ ? Icon Image URL (optional)
57
+ ? Target URL (optional) https://315e5367357f.ngrok.app
58
+
59
+ More information on OAuth 2 Scopes can be found at:
60
+ https://www.oauth.com/oauth2-servers/scope/
61
+
62
+ To determine which scopes you need for the application, see documentation for the individual endpoints you will use in your app:
63
+ https://developer.smartthings.com/docs/api/public/
64
+
65
+ ? Select Scopes. r:devices:*, x:devices:*, r:locations:*
66
+ ? Add or edit Redirect URIs. Add Redirect URI.
67
+ ? Redirect URI (? for help) https://315e5367357f.ngrok.app/oauth/callback
68
+ ? Add or edit Redirect URIs. Finish editing Redirect URIs.
69
+ ? Choose an action. Finish and create OAuth-In SmartApp.
70
+ Basic App Data:
71
+ ─────────────────────────────────────────────────────────────────────────────
72
+ Display Name My API Subscription App
73
+ App Id 3275eef3-xxxx-xxxx-xxxx-xxxxxxxxxxxx
74
+ App Name amyapisubscriptionapp-aaea18b1-xxxx-xxxx-xxxx-xxxxxxxxxxxx
75
+ Description Allows control of SmartThings devices
76
+ Single Instance true
77
+ Classifications CONNECTED_SERVICE
78
+ App Type API_ONLY
79
+ Target URL https://315e5367357f.ngrok.app
80
+ Target Status PENDING
81
+ ─────────────────────────────────────────────────────────────────────────────
82
+
83
+
84
+ OAuth Info (you will not be able to see the OAuth info again so please save it now!):
85
+ ───────────────────────────────────────────────────────────
86
+ OAuth Client Id 7a850484-xxxx-xxxx-xxxx-xxxxxxxxxxxx
87
+ OAuth Client Secret 3581f317-xxxx-xxxx-xxxx-xxxxxxxxxxxx
88
+ ───────────────────────────────────────────────────────────
89
+ ```
90
+
91
+ Save the output of the create command for later use. It contains the client ID and secret of your app. You
92
+ won't be able to see those values again.
93
+
94
+ ### 3. install the plugin
95
+
96
+ Download the plugin files in your homebridge machine, once downloaded Use your favorite terminal to install the plugin, you need to be inside the project folder and run the following command, Starting by installing the plugin:
97
+ ```
98
+ npm install -g
99
+ ```
100
+ once installed, you can build the plugin:
101
+ ```
102
+ npm run build
103
+ ```
104
+ after building, link the plugin to homebridge:
105
+ ```
106
+ npm link homebridge-smartthings@1.5.22
107
+ ```
108
+
109
+ ### 4. Configure the plugin
110
+ After installing the plugin, you can configure the plugin from homebridge ui, you need the target url from step 1, and you need to add the client id and secret from the app you created in step 2.
111
+
112
+ ### 5. Authorize the plugin
113
+ Once you have configured the plugin, you can authorize the plugin by clicking the authorize link found in the plugin log, after authorization proceed to restart homebridge.
114
+
@@ -0,0 +1,134 @@
1
+ {
2
+ "pluginAlias": "HomeBridgeSmartThings",
3
+ "pluginType": "platform",
4
+ "singular": true,
5
+ "schema": {
6
+ "type": "object",
7
+ "properties": {
8
+ "name": {
9
+ "title": "Name",
10
+ "type": "string",
11
+ "required": true,
12
+ "default": "Smartthings Plug (IK)"
13
+ },
14
+ "BaseURL": {
15
+ "title": "Base URL",
16
+ "type": "string",
17
+ "required": true,
18
+ "default": "https://api.smartthings.com/v1/"
19
+ },
20
+ "client_id": {
21
+ "title": "Client ID",
22
+ "type": "string",
23
+ "required": true,
24
+ "description": "OAuth2 Client ID from SmartThings"
25
+ },
26
+ "client_secret": {
27
+ "title": "Client Secret",
28
+ "type": "string",
29
+ "required": true,
30
+ "format": "password",
31
+ "description": "OAuth2 Client Secret from SmartThings"
32
+ },
33
+ "server_url": {
34
+ "title": "Server URL",
35
+ "type": "string",
36
+ "required": true,
37
+ "description": "The public URL of your server (e.g., https://your-domain.com)"
38
+ },
39
+ "webhook_port": {
40
+ "title": "Webhook Port",
41
+ "type": "integer",
42
+ "required": true,
43
+ "default": 3000,
44
+ "description": "Port for webhook server and OAuth callback"
45
+ },
46
+ "AccessToken": {
47
+ "title": "Access Token",
48
+ "type": "string",
49
+ "required": false,
50
+ "default": "",
51
+ "description": "Will be automatically populated during OAuth2 flow"
52
+ },
53
+ "WebhookToken": {
54
+ "title": "Webhook Token",
55
+ "type": "string",
56
+ "required": false,
57
+ "default": ""
58
+ },
59
+
60
+ "GarageDoorMaxPoll": {
61
+ "title": "Garage Door Max Poll",
62
+ "type": "integer",
63
+ "required": true,
64
+ "default": 40
65
+ },
66
+ "PollLocksSeconds": {
67
+ "title": "Poll Locks (zero = don't poll)",
68
+ "type": "integer",
69
+ "required": false,
70
+ "default": 10
71
+ },
72
+ "PollDoorsSeconds": {
73
+ "title": "Poll Garage Doors (zero = don't poll)",
74
+ "type": "integer",
75
+ "required": false,
76
+ "default": 10
77
+ },
78
+ "PollSensorsSeconds": {
79
+ "title": "Poll Sensors (zero = don't poll)",
80
+ "type": "integer",
81
+ "required": false,
82
+ "default": 5
83
+ },
84
+ "PollSwitchesAndLightsSeconds": {
85
+ "title": "Poll Switches and Lights (zero = don't poll)",
86
+ "type": "integer",
87
+ "required": false,
88
+ "default": 10
89
+ },
90
+ "PollWindowShadesSeconds": {
91
+ "title": "Poll Window Shades (zero = don't poll)",
92
+ "type": "integer",
93
+ "required": false,
94
+ "default": 20
95
+ },
96
+ "ExposeHumiditySensorForAirConditioners": {
97
+ "title": "Expose humidity Sensor for air Conditioners if available.",
98
+ "type": "boolean",
99
+ "required": false,
100
+ "default": false
101
+ },
102
+ "OptionalModeForAirConditioners": {
103
+ "title": "Select what optional mode to use as additional switch in air conditioners.",
104
+ "type": "string",
105
+ "required": false,
106
+ "enum": [
107
+ "Sleep",
108
+ "Speed",
109
+ "WindFree",
110
+ "WindFreeSleep"
111
+ ],
112
+ "default": "None"
113
+ },
114
+ "IgnoreLocations": {
115
+ "title": "Locations to Ignore",
116
+ "type": "array",
117
+ "items": {
118
+ "title": "Location Name",
119
+ "type": "string"
120
+ }
121
+ },
122
+ "IgnoreDevices": {
123
+ "title": "Devices to Ignore",
124
+ "type": "array",
125
+ "items": {
126
+ "title": "Device Name",
127
+ "type": "string"
128
+ }
129
+ }
130
+ }
131
+ },
132
+ "form": null,
133
+ "display": null
134
+ }
@@ -0,0 +1,23 @@
1
+ /// <reference types="node" />
2
+ import { Logger } from 'homebridge';
3
+ import * as http from 'http';
4
+ import { IKHomeBridgeHomebridgePlatform } from '../platform';
5
+ import { TokenManager, TokenData } from './tokenManager';
6
+ import { WebhookServer } from '../webhook/webhookServer';
7
+ export declare class SmartThingsAuth {
8
+ private readonly clientId;
9
+ private readonly clientSecret;
10
+ private readonly log;
11
+ private readonly platform;
12
+ private readonly webhookServer;
13
+ tokenManager: TokenManager;
14
+ private state;
15
+ constructor(clientId: string, clientSecret: string, log: Logger, platform: IKHomeBridgeHomebridgePlatform, storagePath: string, webhookServer: WebhookServer);
16
+ handleOAuthCallback(query: any, res: http.ServerResponse): Promise<void>;
17
+ private exchangeCodeForTokens;
18
+ refreshTokens(refreshToken: string): Promise<Partial<TokenData>>;
19
+ startAuthFlow(): void;
20
+ initialize(): Promise<boolean>;
21
+ getAccessToken(): string | null;
22
+ }
23
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/auth/auth.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,qBAAa,eAAe;IAKxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAEzB,OAAO,CAAC,QAAQ,CAAC,aAAa;IATzB,YAAY,EAAE,YAAY,CAAC;IAClC,OAAO,CAAC,KAAK,CAAuB;gBAGjB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,8BAA8B,EACzD,WAAW,EAAE,MAAM,EACF,aAAa,EAAE,aAAa;IAWlC,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;YAwBvE,qBAAqB;IA2BtB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IA+BtE,aAAa,IAAI,IAAI;IA0Bf,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IA4BpC,cAAc,IAAI,MAAM,GAAG,IAAI;CAGvC"}