|
1 | 1 |
|
2 | 2 | <p align="center"> |
3 | 3 |
|
4 | | -<img src="https://github.com/homebridge/branding/raw/master/logos/homebridge-wordmark-logo-vertical.png" width="150"> |
| 4 | +<img src="https://github.com/homebridge/branding/raw/master/logos/homebridge-wordmark-logo-vertical.png" height="150"> |
5 | 5 |
|
6 | 6 | </p> |
7 | 7 |
|
8 | 8 |
|
9 | | -# Homebridge Platform Plugin Template |
| 9 | +# Homebridge Hubspace plugin |
| 10 | +Hubspace is a platform for range of devices sold at HomeDepot. This plugin tries to integrate as many of these devices so that you can control them from HomeKit. |
10 | 11 |
|
11 | | -This is a template Homebridge platform plugin and can be used as a base to help you get started developing your own plugin. |
| 12 | +# Disclaimer |
| 13 | +I do not own any rights to Hubspace. Any work published here is solely for my own convenience. I am not making any guarantees about the code or products referenced here. |
12 | 14 |
|
13 | | -This template should be used in conjunction with the [developer documentation](https://developers.homebridge.io/). A full list of all supported service types, and their characteristics is available on this site. |
| 15 | +# Tested products |
| 16 | +Below you can find a table of products that have been tested with this plugin. Some products share similarities among one another (e.g. lights), however, that does not guarantee that they will all work. |
14 | 17 |
|
15 | | -## Clone As Template |
| 18 | +Not all features for all products are implemented. Please see the functions below of what is implemented. If you need a feature that is not implemented create an issue for it. |
16 | 19 |
|
17 | | -Click the link below to create a new GitHub Repository using this template, or click the *Use This Template* button above. |
| 20 | +| Product | Functions supported | |
| 21 | +| --- | --- | |
| 22 | +| [Universal Smart Wi-Fi 4-Speed Ceiling Fan](https://www.homedepot.com/p/Hampton-Bay-Universal-Smart-Wi-Fi-4-Speed-Ceiling-Fan-White-Remote-Control-For-Use-Only-With-AC-Motor-Fans-Powered-by-Hubspace-76278/315169181?) | <ul><li>Light on/off</li><li>Fan on/off</li><li>Light brightness</li><li>Fan speed</li></ul> | |
18 | 23 |
|
19 | | -<span align="center"> |
| 24 | +# Development |
| 25 | +There is no official documentation for Hubspace products. Under the hood they use Afero cloud as the mechanism that controls the products. Any functionality here is gained by experimenting with various functions of the devices. Afero provides simple explanation of [their APIs](https://developer.afero.io/API-DeviceEndpoints), however, this is in no way comprehensive. |
20 | 26 |
|
21 | | -### [Create New Repository From Template](https://github.com/homebridge/homebridge-plugin-template/generate) |
| 27 | +If you find that a product does not work as intended, or you want to request a new product, please create a ticket for it in the issues section. You are always more than welcome to create a PR with any fixes or additions to the plugin. |
22 | 28 |
|
23 | | -</span> |
24 | | - |
25 | | -## Setup Development Environment |
26 | | - |
27 | | -To develop Homebridge plugins you must have Node.js 12 or later installed, and a modern code editor such as [VS Code](https://code.visualstudio.com/). This plugin template uses [TypeScript](https://www.typescriptlang.org/) to make development easier and comes with pre-configured settings for [VS Code](https://code.visualstudio.com/) and ESLint. If you are using VS Code install these extensions: |
28 | | - |
29 | | -* [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) |
30 | | - |
31 | | -## Install Development Dependencies |
32 | | - |
33 | | -Using a terminal, navigate to the project folder and run this command to install the development dependencies: |
34 | | - |
35 | | -``` |
36 | | -npm install |
37 | | -``` |
38 | | - |
39 | | -## Update package.json |
40 | | - |
41 | | -Open the [`package.json`](./package.json) and change the following attributes: |
42 | | - |
43 | | -* `name` - this should be prefixed with `homebridge-` or `@username/homebridge-` and contain no spaces or special characters apart from a dashes |
44 | | -* `displayName` - this is the "nice" name displayed in the Homebridge UI |
45 | | -* `repository.url` - Link to your GitHub repo |
46 | | -* `bugs.url` - Link to your GitHub repo issues page |
47 | | - |
48 | | -When you are ready to publish the plugin you should set `private` to false, or remove the attribute entirely. |
49 | | - |
50 | | -## Update Plugin Defaults |
51 | | - |
52 | | -Open the [`src/settings.ts`](./src/settings.ts) file and change the default values: |
53 | | - |
54 | | -* `PLATFORM_NAME` - Set this to be the name of your platform. This is the name of the platform that users will use to register the plugin in the Homebridge `config.json`. |
55 | | -* `PLUGIN_NAME` - Set this to be the same name you set in the [`package.json`](./package.json) file. |
56 | | - |
57 | | -Open the [`config.schema.json`](./config.schema.json) file and change the following attribute: |
58 | | - |
59 | | -* `pluginAlias` - set this to match the `PLATFORM_NAME` you defined in the previous step. |
60 | | - |
61 | | -## Build Plugin |
62 | | - |
63 | | -TypeScript needs to be compiled into JavaScript before it can run. The following command will compile the contents of your [`src`](./src) directory and put the resulting code into the `dist` folder. |
64 | | - |
65 | | -``` |
66 | | -npm run build |
67 | | -``` |
68 | | - |
69 | | -## Link To Homebridge |
70 | | - |
71 | | -Run this command so your global install of Homebridge can discover the plugin in your development environment: |
72 | | - |
73 | | -``` |
74 | | -npm link |
75 | | -``` |
76 | | - |
77 | | -You can now start Homebridge, use the `-D` flag so you can see debug log messages in your plugin: |
78 | | - |
79 | | -``` |
80 | | -homebridge -D |
81 | | -``` |
82 | | - |
83 | | -## Watch For Changes and Build Automatically |
84 | | - |
85 | | -If you want to have your code compile automatically as you make changes, and restart Homebridge automatically between changes, you first need to add your plugin as a platform in `~/.homebridge/config.json`: |
86 | | -``` |
87 | | -{ |
88 | | -... |
89 | | - "platforms": [ |
90 | | - { |
91 | | - "name": "Config", |
92 | | - "port": 8581, |
93 | | - "platform": "config" |
94 | | - }, |
95 | | - { |
96 | | - "name": "<PLUGIN_NAME>", |
97 | | - //... any other options, as listed in config.schema.json ... |
98 | | - "platform": "<PLATFORM_NAME>" |
99 | | - } |
100 | | - ] |
101 | | -} |
102 | | -``` |
103 | | - |
104 | | -and then you can run: |
| 29 | +## Development authentication |
| 30 | +Hubspace platform uses [Keycloak](https://www.keycloak.org) for authentication. To develop new features you will need to request JWT from Keycloak to authenticate your requests against the platform. |
105 | 31 |
|
| 32 | +To get the token send HTTP request with `x-www-form-urlencoded` body to the URL below. |
106 | 33 | ``` |
107 | | -npm run watch |
| 34 | +POST https://accounts.hubspaceconnect.com/auth/realms/thd/protocol/openid-connect/token |
108 | 35 | ``` |
109 | 36 |
|
110 | | -This will launch an instance of Homebridge in debug mode which will restart every time you make a change to the source code. It will load the config stored in the default location under `~/.homebridge`. You may need to stop other running instances of Homebridge while using this command to prevent conflicts. You can adjust the Homebridge startup command in the [`nodemon.json`](./nodemon.json) file. |
111 | | - |
112 | | -## Customise Plugin |
113 | | - |
114 | | -You can now start customising the plugin template to suit your requirements. |
115 | | - |
116 | | -* [`src/platform.ts`](./src/platform.ts) - this is where your device setup and discovery should go. |
117 | | -* [`src/platformAccessory.ts`](./src/platformAccessory.ts) - this is where your accessory control logic should go, you can rename or create multiple instances of this file for each accessory type you need to implement as part of your platform plugin. You can refer to the [developer documentation](https://developers.homebridge.io/) to see what characteristics you need to implement for each service type. |
118 | | -* [`config.schema.json`](./config.schema.json) - update the config schema to match the config you expect from the user. See the [Plugin Config Schema Documentation](https://developers.homebridge.io/#/config-schema). |
119 | | - |
120 | | -## Versioning Your Plugin |
121 | | - |
122 | | -Given a version number `MAJOR`.`MINOR`.`PATCH`, such as `1.4.3`, increment the: |
123 | | - |
124 | | -1. **MAJOR** version when you make breaking changes to your plugin, |
125 | | -2. **MINOR** version when you add functionality in a backwards compatible manner, and |
126 | | -3. **PATCH** version when you make backwards compatible bug fixes. |
127 | | - |
128 | | -You can use the `npm version` command to help you with this: |
129 | | - |
130 | | -```bash |
131 | | -# major update / breaking changes |
132 | | -npm version major |
133 | | - |
134 | | -# minor update / new features |
135 | | -npm version update |
136 | | - |
137 | | -# patch / bugfixes |
138 | | -npm version patch |
139 | | -``` |
140 | | - |
141 | | -## Publish Package |
142 | | - |
143 | | -When you are ready to publish your plugin to [npm](https://www.npmjs.com/), make sure you have removed the `private` attribute from the [`package.json`](./package.json) file then run: |
144 | | - |
145 | | -``` |
146 | | -npm publish |
147 | | -``` |
148 | | - |
149 | | -If you are publishing a scoped plugin, i.e. `@username/homebridge-xxx` you will need to add `--access=public` to command the first time you publish. |
150 | | - |
151 | | -#### Publishing Beta Versions |
152 | | - |
153 | | -You can publish *beta* versions of your plugin for other users to test before you release it to everyone. |
154 | | - |
155 | | -```bash |
156 | | -# create a new pre-release version (eg. 2.1.0-beta.1) |
157 | | -npm version prepatch --preid beta |
158 | | - |
159 | | -# publish to @beta |
160 | | -npm publish --tag=beta |
161 | | -``` |
162 | | - |
163 | | -Users can then install the *beta* version by appending `@beta` to the install command, for example: |
164 | | - |
165 | | -``` |
166 | | -sudo npm install -g homebridge-example-plugin@beta |
167 | | -``` |
| 37 | +Your payload should include the following fields. |
168 | 38 |
|
| 39 | +| Key | Value | |
| 40 | +| --- | --- | |
| 41 | +| grant_type | password | |
| 42 | +| client_id | hubspace_android | |
| 43 | +| username | YOUR_USERNAME | |
| 44 | +| password | YOUR_PASSWORD | |
169 | 45 |
|
| 46 | +Once you receive the token you can make request to Afero with it to investigate the devices and commands. |
0 commit comments