You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 21, 2024. It is now read-only.
The API depends on environment variables. **Make sure to configure the bold variables, as these have no default**.
12
+
13
+
| Key | Type | Value |
14
+
|--|--|--|
15
+
| PORT | number | Port on which the API will listen (default: 3000) |
16
+
||||
17
+
|**HWL_USERNAME**| string | HomeWizard Lite App Username |
18
+
|**HWL_PASSWORD**| string | HomeWizard Lite App Password |
19
+
||||
20
+
|**SMARTPLUG_ID**| string | ID of the Internet Connected Smartplug. GET this ID from /api/smartplug |
21
+
| MIN_DIMMING_VALUE | number | The API supports dimmers. Some dimmers have a certain minimum threshold. When you request the API to go below the minimum dimming value, it'll instead turn off the light. (default: 1) |
22
+
||||
23
+
| CACHE_TTL | number | Default expiration time for cache objects in seconds. Currently only in use for caching session-tokens from HWL. (default: 1800)
The API should be deployed on a local network, because it has no built-in authentication. It is always possible to protect the API with HTTP Basic Auth and make it accessible over the internet, but take note of the insecurities of HTTP Basic Auth.
22
-
23
-
The API could also be deployed in a docker container
24
-
25
-
## Requests
26
-
|Method | URL | Description |
27
-
| -- | -- | -- |
28
-
| GET | /api/test/session | Returns valid session key (Only necessary for testing)*|
29
-
| GET | /api/test/communication | Returns status 200 when API can connect to Google Test API to verify internet connectivity |
30
-
| -- | -- | -- |
31
-
| GET | /api/plug | Returns all registered plugs |
32
-
| GET | /api/act/smartplug/:smartPlugID/plug/:plugID| Returns `true` or `false` for is_active state of a plug specified by plugID |
33
-
| POST | /api/act/smartplug/:smartPlugID/plug/:plugID | Switches plug when request body contains `"action": "on"` or `"action": "off"`. Returns is_active state.
34
-
28
+
* The API should be deployed on a local network and shouldn't be accessible over the interwebs, because it currently has no built-in authentication. It is always possible to configure [HTTP Basic Authentication](https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/).
29
+
* The API should have access to homewizard.com and its subdomains.
30
+
31
+
Using the included Dockerfile, it is also possible to run this API inside a container.
32
+
33
+
## Endpoints
34
+
| Method | URL | Description | Example Request | Example Response |
35
+
| -- | -- | -- | -- | -- |
36
+
| GET | /api/test/session | Returns valid session key (Only necessary for testing) ||`{ "session": "string"` } |
37
+
| GET | /api/test/communication | Returns status 200 when API can connect to Google to verify internet connectivity |
38
+
||||
39
+
| GET | /api/plug | Returns all registered plugs || * |
40
+
| GET | /api/smartplug | Returns info about your internet connected smartplug. (Tip: Use this to determine the ID of your smartplug. Use the `id` property.) || * |
41
+
| GET | /api/plug/:plugID| Returns `true` or `false` for is_active state of a plug specified by plugID ||`{ "is_active": false }`|
42
+
| POST | /api/plug/:plugID|[DIMMER] Change dimmer state when request body contains `"type": "dimmer"` and `"value": number`. When value is below `MIN_DIMMING_VALUE`, the dimmer will switch off. Returns `is_active state`. |`{ "type": "dimmer", "value": 75 }`|`{ "is_active": true }`|
43
+
|||[SWITCH] Switches plug when request body contains `"type": "switch"` and `"value": "on/off"`. Returns `is_active` state |`{ "type": "switch", "value": "on" }`|`{ "is_active": true }`|
44
+
45
+
`*` Try this yourself. Response contains a bunch of useful info and does not fit needly in this table.
35
46
## Contribution
36
47
This project was started by an IT-student as a small 2 day project to improve home-automation by enabling Home Assistant to control HomeWizard Lite plugs. Development will continue when I need more features. Contribution is appreciated.
0 commit comments