homebridge-deco 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.
- package/LICENSE +176 -0
- package/README.md +290 -0
- package/config.schema.json +89 -0
- package/dist/decoAPI.d.ts +85 -0
- package/dist/decoAPI.js +288 -0
- package/dist/decoAPI.js.map +1 -0
- package/dist/decoDeviceAccessory.d.ts +21 -0
- package/dist/decoDeviceAccessory.js +73 -0
- package/dist/decoDeviceAccessory.js.map +1 -0
- package/dist/decoDeviceTrackerAccessory.d.ts +22 -0
- package/dist/decoDeviceTrackerAccessory.js +65 -0
- package/dist/decoDeviceTrackerAccessory.js.map +1 -0
- package/dist/decoGuestNetworkAccessory.d.ts +25 -0
- package/dist/decoGuestNetworkAccessory.js +79 -0
- package/dist/decoGuestNetworkAccessory.js.map +1 -0
- package/dist/decoNetworkAccessory.d.ts +21 -0
- package/dist/decoNetworkAccessory.js +63 -0
- package/dist/decoNetworkAccessory.js.map +1 -0
- package/dist/decoRouterAccessory.d.ts +25 -0
- package/dist/decoRouterAccessory.js +65 -0
- package/dist/decoRouterAccessory.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/platform.d.ts +55 -0
- package/dist/platform.js +264 -0
- package/dist/platform.js.map +1 -0
- package/dist/settings.d.ts +8 -0
- package/dist/settings.js +9 -0
- package/dist/settings.js.map +1 -0
- package/package.json +50 -0
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,290 @@
|
|
|
1
|
+
# homebridge-deco
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/homebridge-deco)
|
|
4
|
+
|
|
5
|
+
**Homebridge plugin for TP-Link Deco mesh network system**
|
|
6
|
+
|
|
7
|
+
This plugin exposes your TP-Link Deco mesh network to Apple HomeKit, allowing you to:
|
|
8
|
+
- Monitor internet connectivity status
|
|
9
|
+
- Control guest network on/off
|
|
10
|
+
- Track individual Deco unit status (online/offline)
|
|
11
|
+
- Monitor specific devices on your network (presence detection)
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
### Router Accessory (Default)
|
|
16
|
+
- **Native HomeKit Router**: Your Deco appears as a proper Router in the Home app
|
|
17
|
+
- Shows network status and information
|
|
18
|
+
- Clean, native HomeKit integration
|
|
19
|
+
|
|
20
|
+
### Optional Advanced Features (Off by Default)
|
|
21
|
+
|
|
22
|
+
#### Network Status Sensor
|
|
23
|
+
- Contact sensor showing internet connectivity
|
|
24
|
+
- Alternative to the router accessory if you prefer sensor-based monitoring
|
|
25
|
+
|
|
26
|
+
#### Guest Network Control
|
|
27
|
+
- Switch to toggle guest network on/off
|
|
28
|
+
- Useful for automations (e.g., turn off guest network at night)
|
|
29
|
+
|
|
30
|
+
#### Individual Deco Unit Monitoring
|
|
31
|
+
- Each mesh unit as a contact sensor (online/offline status)
|
|
32
|
+
- Monitor mesh health and get offline notifications
|
|
33
|
+
|
|
34
|
+
#### Device Presence Tracking
|
|
35
|
+
- Track specific devices by MAC address
|
|
36
|
+
- Appears as occupancy sensors
|
|
37
|
+
- Perfect for "someone is home" automations
|
|
38
|
+
|
|
39
|
+
## Requirements
|
|
40
|
+
|
|
41
|
+
- **Node.js**: v20.18.0 or higher (v22.10.0+ or v24.0.0+ recommended)
|
|
42
|
+
- **Homebridge**: v1.8.0 or higher (v2.0.0+ supported)
|
|
43
|
+
- **TP-Link Account**: Your TP-Link cloud account credentials (same as Deco app)
|
|
44
|
+
- **TP-Link Deco**: Tested with Deco PX50, should work with all Deco models
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
### Via Homebridge Config UI X (Recommended)
|
|
49
|
+
|
|
50
|
+
1. Search for "homebridge-deco" in the Plugins tab
|
|
51
|
+
2. Click Install
|
|
52
|
+
3. Configure your TP-Link account credentials
|
|
53
|
+
4. Restart Homebridge
|
|
54
|
+
|
|
55
|
+
### Via npm
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm install -g homebridge-deco
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Configuration
|
|
62
|
+
|
|
63
|
+
### Basic Configuration
|
|
64
|
+
|
|
65
|
+
Add this to your Homebridge `config.json`:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"platforms": [
|
|
70
|
+
{
|
|
71
|
+
"name": "TP-Link Deco",
|
|
72
|
+
"platform": "TPLinkDeco",
|
|
73
|
+
"username": "your-tplink-email@example.com",
|
|
74
|
+
"password": "your-tplink-password",
|
|
75
|
+
"pollingInterval": 30
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
This will expose your Deco as a native Router in HomeKit. To enable advanced features:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"platforms": [
|
|
86
|
+
{
|
|
87
|
+
"name": "TP-Link Deco",
|
|
88
|
+
"platform": "TPLinkDeco",
|
|
89
|
+
"username": "your-tplink-email@example.com",
|
|
90
|
+
"password": "your-tplink-password",
|
|
91
|
+
"pollingInterval": 30,
|
|
92
|
+
"exposeGuestNetwork": true,
|
|
93
|
+
"exposeDecoUnits": true
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Configuration Options
|
|
100
|
+
|
|
101
|
+
| Option | Required | Default | Description |
|
|
102
|
+
|--------|----------|---------|-------------|
|
|
103
|
+
| `name` | Yes | - | Name of the platform |
|
|
104
|
+
| `platform` | Yes | - | Must be "TPLinkDeco" |
|
|
105
|
+
| `username` | Yes | - | Your TP-Link cloud account email |
|
|
106
|
+
| `password` | Yes | - | Your TP-Link cloud account password |
|
|
107
|
+
| `pollingInterval` | No | 30 | How often to check status (10-300 seconds) |
|
|
108
|
+
| `exposeAsRouter` | No | true | Expose as native HomeKit Router (recommended) |
|
|
109
|
+
| `exposeNetworkSensor` | No | false | Show network status as contact sensor |
|
|
110
|
+
| `exposeGuestNetwork` | No | false | Show guest network control switch |
|
|
111
|
+
| `exposeDecoUnits` | No | false | Show individual Deco units as sensors |
|
|
112
|
+
| `exposeDeviceTrackers` | No | false | Enable device presence tracking |
|
|
113
|
+
| `trackedDevices` | No | [] | List of devices to track (see below) |
|
|
114
|
+
|
|
115
|
+
### Device Tracking Configuration
|
|
116
|
+
|
|
117
|
+
To track specific devices on your network (requires `exposeDeviceTrackers: true`):
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"platforms": [
|
|
122
|
+
{
|
|
123
|
+
"name": "TP-Link Deco",
|
|
124
|
+
"platform": "TPLinkDeco",
|
|
125
|
+
"username": "your-tplink-email@example.com",
|
|
126
|
+
"password": "your-tplink-password",
|
|
127
|
+
"exposeDeviceTrackers": true,
|
|
128
|
+
"trackedDevices": [
|
|
129
|
+
{
|
|
130
|
+
"name": "John's iPhone",
|
|
131
|
+
"mac": "AA:BB:CC:DD:EE:FF"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"name": "Jane's iPad",
|
|
135
|
+
"mac": "11:22:33:44:55:66"
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Finding MAC Addresses**: Open the Deco app → Clients → Select device → MAC address is displayed
|
|
144
|
+
|
|
145
|
+
## Usage Examples
|
|
146
|
+
|
|
147
|
+
### Automation Ideas
|
|
148
|
+
|
|
149
|
+
1. **Internet Outage Notifications**
|
|
150
|
+
- Trigger: Network Status contact sensor becomes "Not Detected"
|
|
151
|
+
- Action: Send notification to your phone
|
|
152
|
+
|
|
153
|
+
2. **Automatic Guest Network Schedule**
|
|
154
|
+
- Trigger: Time-based (e.g., 11 PM)
|
|
155
|
+
- Action: Turn off Guest Network switch
|
|
156
|
+
|
|
157
|
+
3. **Someone Is Home**
|
|
158
|
+
- Trigger: Device Tracker (phone) shows "Occupied"
|
|
159
|
+
- Action: Turn on lights, adjust thermostat
|
|
160
|
+
|
|
161
|
+
4. **Mesh Health Monitoring**
|
|
162
|
+
- Trigger: Any Deco unit contact sensor becomes "Not Detected"
|
|
163
|
+
- Action: Send alert notification
|
|
164
|
+
|
|
165
|
+
## Exposed Accessories
|
|
166
|
+
|
|
167
|
+
### Default Setup
|
|
168
|
+
|
|
169
|
+
With default settings, you get:
|
|
170
|
+
|
|
171
|
+
1. **Deco Router** (Router) - Native HomeKit router accessory
|
|
172
|
+
- Shows network information in the Home app
|
|
173
|
+
- Clean, integrated experience
|
|
174
|
+
|
|
175
|
+
### Optional Accessories (when enabled)
|
|
176
|
+
|
|
177
|
+
2. **Network Status** (Contact Sensor) - When `exposeNetworkSensor: true`
|
|
178
|
+
- Detected = Internet is online
|
|
179
|
+
- Not Detected = Internet is offline
|
|
180
|
+
|
|
181
|
+
3. **Guest Network** (Switch) - When `exposeGuestNetwork: true`
|
|
182
|
+
- On = Guest network enabled
|
|
183
|
+
- Off = Guest network disabled
|
|
184
|
+
|
|
185
|
+
4. **Deco [Unit Name]** (Contact Sensor) - When `exposeDecoUnits: true`
|
|
186
|
+
- One per mesh unit
|
|
187
|
+
- Detected = Unit is online, Not Detected = Unit is offline
|
|
188
|
+
|
|
189
|
+
5. **[Device Name]** (Occupancy Sensor) - When `exposeDeviceTrackers: true`
|
|
190
|
+
- Per tracked device in config
|
|
191
|
+
- Occupied = Device is connected, Not Occupied = Device is not connected
|
|
192
|
+
|
|
193
|
+
## Troubleshooting
|
|
194
|
+
|
|
195
|
+
### Authentication Failures
|
|
196
|
+
|
|
197
|
+
**Error**: "Failed to authenticate with TP-Link cloud"
|
|
198
|
+
|
|
199
|
+
- Verify your email and password are correct
|
|
200
|
+
- Make sure you can log into the Deco mobile app
|
|
201
|
+
- Check if your TP-Link account requires 2FA (not currently supported)
|
|
202
|
+
|
|
203
|
+
### No Devices Discovered
|
|
204
|
+
|
|
205
|
+
**Error**: "Successfully discovered 0 Deco devices"
|
|
206
|
+
|
|
207
|
+
- Ensure your Deco system is set up and online in the Deco app
|
|
208
|
+
- Check that your Homebridge server has internet access
|
|
209
|
+
- Try increasing the polling interval to 60+ seconds
|
|
210
|
+
- Check Homebridge logs for detailed error messages
|
|
211
|
+
|
|
212
|
+
### Accessories Not Updating
|
|
213
|
+
|
|
214
|
+
- Check your polling interval isn't too long
|
|
215
|
+
- Restart Homebridge to force a fresh discovery
|
|
216
|
+
- Check network connectivity between Homebridge and internet
|
|
217
|
+
|
|
218
|
+
### Debug Logging
|
|
219
|
+
|
|
220
|
+
Enable debug mode in Homebridge to see detailed API communication:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
homebridge -D
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Technical Details
|
|
227
|
+
|
|
228
|
+
### API Communication
|
|
229
|
+
|
|
230
|
+
This plugin uses the TP-Link cloud API (same as the mobile app) to communicate with your Deco network:
|
|
231
|
+
- Authenticates using your TP-Link account credentials
|
|
232
|
+
- Maintains a session token (refreshed every hour)
|
|
233
|
+
- Polls for status updates at your configured interval
|
|
234
|
+
- Supports both reading status and controlling settings
|
|
235
|
+
|
|
236
|
+
### Reliability Features
|
|
237
|
+
|
|
238
|
+
- **Automatic token refresh**: Handles session expiration transparently
|
|
239
|
+
- **Error retry logic**: Recovers from temporary network issues
|
|
240
|
+
- **Cached accessory state**: Preserves settings across Homebridge restarts
|
|
241
|
+
- **Efficient polling**: Only fetches data at configured intervals
|
|
242
|
+
|
|
243
|
+
## Known Limitations
|
|
244
|
+
|
|
245
|
+
- Requires internet connection (uses TP-Link cloud API)
|
|
246
|
+
- Cannot control individual Deco unit settings beyond what's exposed
|
|
247
|
+
- Guest network control may not work on all Deco models
|
|
248
|
+
- 2FA accounts are not currently supported
|
|
249
|
+
|
|
250
|
+
## Development
|
|
251
|
+
|
|
252
|
+
### Setup Development Environment
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# Clone the repository
|
|
256
|
+
git clone https://github.com/fabianoley/homebridge-deco.git
|
|
257
|
+
cd homebridge-deco
|
|
258
|
+
|
|
259
|
+
# Install dependencies
|
|
260
|
+
npm install
|
|
261
|
+
|
|
262
|
+
# Build the plugin
|
|
263
|
+
npm run build
|
|
264
|
+
|
|
265
|
+
# Link to Homebridge
|
|
266
|
+
npm link
|
|
267
|
+
|
|
268
|
+
# Watch for changes (auto-compile and restart)
|
|
269
|
+
npm run watch
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Configuration for Development
|
|
273
|
+
|
|
274
|
+
Edit `test/hbConfig/config.json` with your TP-Link credentials, then run:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
npm run watch
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Contributing
|
|
281
|
+
|
|
282
|
+
Found a bug or want a feature? Please open an issue on GitHub!
|
|
283
|
+
|
|
284
|
+
## License
|
|
285
|
+
|
|
286
|
+
Apache-2.0
|
|
287
|
+
|
|
288
|
+
## Credits
|
|
289
|
+
|
|
290
|
+
Created by Fabian Oley
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginAlias": "TPLinkDeco",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": true,
|
|
5
|
+
"strictValidation": false,
|
|
6
|
+
"schema": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"required": ["name", "username", "password"],
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {
|
|
11
|
+
"name": {
|
|
12
|
+
"title": "Name",
|
|
13
|
+
"type": "string",
|
|
14
|
+
"default": "TP-Link Deco"
|
|
15
|
+
},
|
|
16
|
+
"username": {
|
|
17
|
+
"title": "TP-Link Account Email",
|
|
18
|
+
"type": "string",
|
|
19
|
+
"required": true,
|
|
20
|
+
"description": "Your TP-Link cloud account email address"
|
|
21
|
+
},
|
|
22
|
+
"password": {
|
|
23
|
+
"title": "TP-Link Account Password",
|
|
24
|
+
"type": "string",
|
|
25
|
+
"required": true,
|
|
26
|
+
"description": "Your TP-Link cloud account password"
|
|
27
|
+
},
|
|
28
|
+
"pollingInterval": {
|
|
29
|
+
"title": "Polling Interval (seconds)",
|
|
30
|
+
"type": "integer",
|
|
31
|
+
"default": 30,
|
|
32
|
+
"minimum": 10,
|
|
33
|
+
"maximum": 300,
|
|
34
|
+
"description": "How often to check device status (10-300 seconds)"
|
|
35
|
+
},
|
|
36
|
+
"exposeAsRouter": {
|
|
37
|
+
"title": "Expose as Router (Recommended)",
|
|
38
|
+
"type": "boolean",
|
|
39
|
+
"default": true,
|
|
40
|
+
"description": "Expose Deco as a native HomeKit Router accessory"
|
|
41
|
+
},
|
|
42
|
+
"exposeNetworkSensor": {
|
|
43
|
+
"title": "Expose Network Status Sensor",
|
|
44
|
+
"type": "boolean",
|
|
45
|
+
"default": false,
|
|
46
|
+
"description": "Add a contact sensor for internet connectivity (alternative to router)"
|
|
47
|
+
},
|
|
48
|
+
"exposeGuestNetwork": {
|
|
49
|
+
"title": "Expose Guest Network Control",
|
|
50
|
+
"type": "boolean",
|
|
51
|
+
"default": false,
|
|
52
|
+
"description": "Add a switch to control guest network on/off"
|
|
53
|
+
},
|
|
54
|
+
"exposeDecoUnits": {
|
|
55
|
+
"title": "Expose Individual Deco Units",
|
|
56
|
+
"type": "boolean",
|
|
57
|
+
"default": false,
|
|
58
|
+
"description": "Add contact sensors for each Deco mesh unit status"
|
|
59
|
+
},
|
|
60
|
+
"exposeDeviceTrackers": {
|
|
61
|
+
"title": "Expose Connected Devices as Occupancy Sensors",
|
|
62
|
+
"type": "boolean",
|
|
63
|
+
"default": false,
|
|
64
|
+
"description": "Create occupancy sensors for tracking specific devices"
|
|
65
|
+
},
|
|
66
|
+
"trackedDevices": {
|
|
67
|
+
"title": "Tracked Device MAC Addresses",
|
|
68
|
+
"type": "array",
|
|
69
|
+
"items": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"properties": {
|
|
72
|
+
"name": {
|
|
73
|
+
"title": "Device Name",
|
|
74
|
+
"type": "string"
|
|
75
|
+
},
|
|
76
|
+
"mac": {
|
|
77
|
+
"title": "MAC Address",
|
|
78
|
+
"type": "string",
|
|
79
|
+
"pattern": "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"condition": {
|
|
84
|
+
"functionBody": "return model.exposeDeviceTrackers === true;"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Logging } from 'homebridge';
|
|
2
|
+
interface DecoConfig {
|
|
3
|
+
username: string;
|
|
4
|
+
password: string;
|
|
5
|
+
log: Logging;
|
|
6
|
+
}
|
|
7
|
+
interface DecoDevice {
|
|
8
|
+
deviceId: string;
|
|
9
|
+
deviceName: string;
|
|
10
|
+
deviceModel: string;
|
|
11
|
+
deviceType: string;
|
|
12
|
+
role: string;
|
|
13
|
+
mac: string;
|
|
14
|
+
ip: string;
|
|
15
|
+
status: number;
|
|
16
|
+
ledOn: boolean;
|
|
17
|
+
signalLevel?: number;
|
|
18
|
+
}
|
|
19
|
+
interface ConnectedClient {
|
|
20
|
+
mac: string;
|
|
21
|
+
name: string;
|
|
22
|
+
ip: string;
|
|
23
|
+
online: boolean;
|
|
24
|
+
downSpeed: number;
|
|
25
|
+
upSpeed: number;
|
|
26
|
+
connectedNode: string;
|
|
27
|
+
}
|
|
28
|
+
interface NetworkStatus {
|
|
29
|
+
internetOnline: boolean;
|
|
30
|
+
guestNetworkEnabled: boolean;
|
|
31
|
+
devices: DecoDevice[];
|
|
32
|
+
clients: ConnectedClient[];
|
|
33
|
+
}
|
|
34
|
+
export declare class DecoAPI {
|
|
35
|
+
private readonly log;
|
|
36
|
+
private readonly username;
|
|
37
|
+
private readonly password;
|
|
38
|
+
private token;
|
|
39
|
+
private readonly baseUrl;
|
|
40
|
+
private termid;
|
|
41
|
+
private lastAuthTime;
|
|
42
|
+
private readonly authValidityMs;
|
|
43
|
+
constructor(config: DecoConfig);
|
|
44
|
+
/**
|
|
45
|
+
* Authenticate with TP-Link cloud service
|
|
46
|
+
*/
|
|
47
|
+
authenticate(): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Get list of Deco devices in the network
|
|
50
|
+
*/
|
|
51
|
+
getDeviceList(): Promise<DecoDevice[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Get network status including internet connectivity and guest network
|
|
54
|
+
*/
|
|
55
|
+
getNetworkStatus(): Promise<NetworkStatus>;
|
|
56
|
+
/**
|
|
57
|
+
* Get list of connected clients
|
|
58
|
+
*/
|
|
59
|
+
getClientList(): Promise<ConnectedClient[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Get guest network status
|
|
62
|
+
*/
|
|
63
|
+
getGuestNetworkStatus(): Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* Toggle guest network on/off
|
|
66
|
+
*/
|
|
67
|
+
setGuestNetwork(enabled: boolean): Promise<boolean>;
|
|
68
|
+
/**
|
|
69
|
+
* Check if a specific device (by MAC) is connected
|
|
70
|
+
*/
|
|
71
|
+
isDeviceConnected(mac: string): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Reboot a specific Deco device
|
|
74
|
+
*/
|
|
75
|
+
rebootDevice(deviceId: string): Promise<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* Make HTTP request to TP-Link API
|
|
78
|
+
*/
|
|
79
|
+
private makeRequest;
|
|
80
|
+
/**
|
|
81
|
+
* Ensure we have a valid authentication token
|
|
82
|
+
*/
|
|
83
|
+
private ensureAuthenticated;
|
|
84
|
+
}
|
|
85
|
+
export {};
|