homebridge-tuya-pool-heater 1.0.1
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 +21 -0
- package/README.md +328 -0
- package/config.schema.json +247 -0
- package/dist/heaterCoolerAccessory.d.ts +31 -0
- package/dist/heaterCoolerAccessory.js +223 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/platform.d.ts +26 -0
- package/dist/platform.js +161 -0
- package/dist/settings.d.ts +81 -0
- package/dist/settings.js +66 -0
- package/dist/settings.test.d.ts +1 -0
- package/dist/settings.test.js +152 -0
- package/dist/thermostatAccessory.d.ts +27 -0
- package/dist/thermostatAccessory.js +238 -0
- package/dist/tuyaApi.d.ts +19 -0
- package/dist/tuyaApi.js +233 -0
- package/dist/tuyaApi.test.d.ts +1 -0
- package/dist/tuyaApi.test.js +294 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Brandon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
# homebridge-tuya-pool-heater
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/homebridge-tuya-pool-heater)
|
|
4
|
+
[](https://github.com/bstillitano/homebridge-tuya-pool-heater/releases)
|
|
5
|
+
[](https://www.npmjs.com/package/homebridge-tuya-pool-heater)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
Control your Tuya-based pool heat pump with Apple HomeKit using Homebridge.
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
- [Features](#features)
|
|
13
|
+
- [Supported Devices](#supported-devices)
|
|
14
|
+
- [Installation](#installation)
|
|
15
|
+
- [Tuya IoT Platform Setup](#tuya-iot-platform-setup)
|
|
16
|
+
- [Configuration](#configuration)
|
|
17
|
+
- [Accessory Types](#accessory-types)
|
|
18
|
+
- [Temperature Ranges](#temperature-ranges)
|
|
19
|
+
- [Troubleshooting](#troubleshooting)
|
|
20
|
+
- [Contributing](#contributing)
|
|
21
|
+
- [License](#license)
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- **Thermostat or HeaterCooler mode** - Choose how the device appears in HomeKit
|
|
26
|
+
- **Proper temperature handling** - Correctly handles Tuya's temperature scaling (×10)
|
|
27
|
+
- **Full mode support** - Maps heat pump modes (Heating, Cooling, Auto) to HomeKit
|
|
28
|
+
- **Multiple devices** - Support for multiple heat pumps
|
|
29
|
+
- **Configurable temperature ranges** - Set custom min/max temperatures per mode
|
|
30
|
+
- **Automatic reconnection** - Recovers gracefully from network issues
|
|
31
|
+
- **Homebridge UI** - Easy configuration through the Homebridge Config UI X
|
|
32
|
+
|
|
33
|
+
## Supported Devices
|
|
34
|
+
|
|
35
|
+
This plugin is designed for Tuya-based pool heat pumps that use the following DP (Data Point) codes:
|
|
36
|
+
|
|
37
|
+
| DP Code | Description | Type |
|
|
38
|
+
|---------|-------------|------|
|
|
39
|
+
| `switch` | Power on/off | Boolean |
|
|
40
|
+
| `mode` | Operating mode | Enum |
|
|
41
|
+
| `temp_current` | Current water temperature | Integer (×10) |
|
|
42
|
+
| `set_heating_temp` | Heating target temperature | Integer (×10) |
|
|
43
|
+
| `set_cold_temp` | Cooling target temperature | Integer (×10) |
|
|
44
|
+
| `set_auto_temp` | Auto mode target temperature | Integer (×10) |
|
|
45
|
+
|
|
46
|
+
### Supported Modes
|
|
47
|
+
|
|
48
|
+
| Mode Value | Description |
|
|
49
|
+
|------------|-------------|
|
|
50
|
+
| `Auto` | Automatic heating/cooling |
|
|
51
|
+
| `Heating_Smart` | Smart heating mode |
|
|
52
|
+
| `Heating_Powerful` | Powerful heating mode |
|
|
53
|
+
| `Heating_Silent` | Silent heating mode |
|
|
54
|
+
| `Cooling_Smart` | Smart cooling mode |
|
|
55
|
+
| `Cooling_Powerful` | Powerful cooling mode |
|
|
56
|
+
| `Cooling_Silent` | Silent cooling mode |
|
|
57
|
+
|
|
58
|
+
> **Note:** Your device may not support all modes. The plugin will use the `_Smart` variants when setting modes from HomeKit.
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
### Via Homebridge UI (Recommended)
|
|
63
|
+
|
|
64
|
+
1. Open the Homebridge Config UI X
|
|
65
|
+
2. Navigate to the Plugins tab
|
|
66
|
+
3. Search for `homebridge-tuya-pool-heater`
|
|
67
|
+
4. Click **Install**
|
|
68
|
+
5. Configure the plugin through the settings UI
|
|
69
|
+
|
|
70
|
+
### Via npm
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npm install -g homebridge-tuya-pool-heater
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Then configure the plugin in your `config.json` file.
|
|
77
|
+
|
|
78
|
+
## Tuya IoT Platform Setup
|
|
79
|
+
|
|
80
|
+
Before using this plugin, you need to set up a Tuya IoT Platform project:
|
|
81
|
+
|
|
82
|
+
### Step 1: Create a Tuya Developer Account
|
|
83
|
+
|
|
84
|
+
1. Go to [Tuya IoT Platform](https://platform.tuya.com)
|
|
85
|
+
2. Create an account or sign in
|
|
86
|
+
|
|
87
|
+
### Step 2: Create a Cloud Project
|
|
88
|
+
|
|
89
|
+
1. Navigate to **Cloud** → **Development** → **Create Cloud Project**
|
|
90
|
+
2. Fill in the project details:
|
|
91
|
+
- **Project Name:** Any name (e.g., "Homebridge")
|
|
92
|
+
- **Industry:** Smart Home
|
|
93
|
+
- **Development Method:** Smart Home
|
|
94
|
+
- **Data Center:** Select your region (must match your app region)
|
|
95
|
+
|
|
96
|
+
### Step 3: Get Your Credentials
|
|
97
|
+
|
|
98
|
+
1. In your project, go to **Overview**
|
|
99
|
+
2. Note your **Access ID** (also called Client ID)
|
|
100
|
+
3. Note your **Access Secret** (also called Client Secret)
|
|
101
|
+
|
|
102
|
+
### Step 4: Link Your Tuya App Account
|
|
103
|
+
|
|
104
|
+
1. In your project, go to **Devices** → **Link Tuya App Account**
|
|
105
|
+
2. Click **Add App Account**
|
|
106
|
+
3. Open your Tuya/Smart Life app on your phone
|
|
107
|
+
4. Go to **Profile** → **Settings** (gear icon) → **Scan QR Code**
|
|
108
|
+
5. Scan the QR code displayed on the Tuya IoT Platform
|
|
109
|
+
|
|
110
|
+
### Step 5: Find Your Device ID
|
|
111
|
+
|
|
112
|
+
1. After linking, your devices will appear in the **Devices** tab
|
|
113
|
+
2. Find your pool heat pump and note the **Device ID**
|
|
114
|
+
|
|
115
|
+
### API Endpoints by Region
|
|
116
|
+
|
|
117
|
+
| Region | Endpoint |
|
|
118
|
+
|--------|----------|
|
|
119
|
+
| Americas | `https://openapi.tuyaus.com` |
|
|
120
|
+
| Europe | `https://openapi.tuyaeu.com` |
|
|
121
|
+
| China | `https://openapi.tuyacn.com` |
|
|
122
|
+
| India | `https://openapi.tuyain.com` |
|
|
123
|
+
|
|
124
|
+
> **Important:** Use the endpoint that matches the data center you selected when creating your cloud project.
|
|
125
|
+
|
|
126
|
+
## Configuration
|
|
127
|
+
|
|
128
|
+
### Via Homebridge UI
|
|
129
|
+
|
|
130
|
+
The easiest way to configure the plugin is through the Homebridge Config UI X. After installation, click the **Settings** button on the plugin card to open the configuration form.
|
|
131
|
+
|
|
132
|
+
### Manual Configuration
|
|
133
|
+
|
|
134
|
+
Add the following to your Homebridge `config.json`:
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"platforms": [
|
|
139
|
+
{
|
|
140
|
+
"platform": "TuyaPoolHeatPump",
|
|
141
|
+
"name": "Pool Heat Pump",
|
|
142
|
+
"options": {
|
|
143
|
+
"accessId": "YOUR_ACCESS_ID",
|
|
144
|
+
"accessKey": "YOUR_ACCESS_SECRET",
|
|
145
|
+
"endpoint": "https://openapi.tuyaus.com",
|
|
146
|
+
"username": "your-email@example.com",
|
|
147
|
+
"password": "your-tuya-app-password",
|
|
148
|
+
"countryCode": 1,
|
|
149
|
+
"pollInterval": 30000
|
|
150
|
+
},
|
|
151
|
+
"devices": [
|
|
152
|
+
{
|
|
153
|
+
"id": "YOUR_DEVICE_ID",
|
|
154
|
+
"name": "Pool Heat Pump",
|
|
155
|
+
"accessoryType": "thermostat",
|
|
156
|
+
"heatingRange": {
|
|
157
|
+
"min": 20,
|
|
158
|
+
"max": 40
|
|
159
|
+
},
|
|
160
|
+
"coolingRange": {
|
|
161
|
+
"min": 15,
|
|
162
|
+
"max": 30
|
|
163
|
+
},
|
|
164
|
+
"autoRange": {
|
|
165
|
+
"min": 18,
|
|
166
|
+
"max": 35
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Platform Options
|
|
176
|
+
|
|
177
|
+
| Option | Required | Default | Description |
|
|
178
|
+
|--------|----------|---------|-------------|
|
|
179
|
+
| `platform` | Yes | - | Must be `TuyaPoolHeatPump` |
|
|
180
|
+
| `name` | Yes | - | Display name for the platform |
|
|
181
|
+
| `options.accessId` | Yes | - | Your Tuya IoT Platform Access ID |
|
|
182
|
+
| `options.accessKey` | Yes | - | Your Tuya IoT Platform Access Secret |
|
|
183
|
+
| `options.endpoint` | Yes | - | API endpoint for your region |
|
|
184
|
+
| `options.username` | Yes | - | Your Tuya/Smart Life app username (email) |
|
|
185
|
+
| `options.password` | Yes | - | Your Tuya/Smart Life app password |
|
|
186
|
+
| `options.countryCode` | Yes | - | Your country calling code (e.g., 1 for US, 44 for UK, 61 for AU) |
|
|
187
|
+
| `options.pollInterval` | No | 30000 | How often to poll for status updates (in milliseconds) |
|
|
188
|
+
|
|
189
|
+
### Device Options
|
|
190
|
+
|
|
191
|
+
| Option | Required | Default | Description |
|
|
192
|
+
|--------|----------|---------|-------------|
|
|
193
|
+
| `id` | Yes | - | Tuya device ID |
|
|
194
|
+
| `name` | Yes | - | Display name in HomeKit |
|
|
195
|
+
| `accessoryType` | Yes | `thermostat` | `thermostat` or `heatercooler` |
|
|
196
|
+
| `heatingRange.min` | No | 5 | Minimum heating temperature (°C) |
|
|
197
|
+
| `heatingRange.max` | No | 55 | Maximum heating temperature (°C) |
|
|
198
|
+
| `coolingRange.min` | No | 5 | Minimum cooling temperature (°C) |
|
|
199
|
+
| `coolingRange.max` | No | 35 | Maximum cooling temperature (°C) |
|
|
200
|
+
| `autoRange.min` | No | 5 | Minimum auto mode temperature (°C) |
|
|
201
|
+
| `autoRange.max` | No | 40 | Maximum auto mode temperature (°C) |
|
|
202
|
+
|
|
203
|
+
## Accessory Types
|
|
204
|
+
|
|
205
|
+
### Thermostat
|
|
206
|
+
|
|
207
|
+
The **Thermostat** accessory type provides a familiar thermostat interface in HomeKit:
|
|
208
|
+
|
|
209
|
+
- **Current Temperature** - Real-time water temperature
|
|
210
|
+
- **Target Temperature** - Desired temperature setpoint
|
|
211
|
+
- **Current State** - Shows if currently heating, cooling, or idle
|
|
212
|
+
- **Target State** - Off, Heat, Cool, or Auto mode
|
|
213
|
+
|
|
214
|
+
This is the recommended option for most users as it provides a simple, intuitive interface.
|
|
215
|
+
|
|
216
|
+
### HeaterCooler
|
|
217
|
+
|
|
218
|
+
The **HeaterCooler** accessory type provides separate heating and cooling threshold controls:
|
|
219
|
+
|
|
220
|
+
- **Active** - Power on/off
|
|
221
|
+
- **Current Temperature** - Real-time water temperature
|
|
222
|
+
- **Heating Threshold** - Temperature at which heating activates
|
|
223
|
+
- **Cooling Threshold** - Temperature at which cooling activates
|
|
224
|
+
- **Current State** - Idle, Heating, or Cooling
|
|
225
|
+
- **Target State** - Heat, Cool, or Auto mode
|
|
226
|
+
|
|
227
|
+
Choose this option if you want independent control over heating and cooling thresholds.
|
|
228
|
+
|
|
229
|
+
## Temperature Ranges
|
|
230
|
+
|
|
231
|
+
Temperature ranges can be customized per device to match your heat pump's capabilities. The ranges are mode-specific:
|
|
232
|
+
|
|
233
|
+
- **Heating Range** - Applied when in any heating mode
|
|
234
|
+
- **Cooling Range** - Applied when in any cooling mode
|
|
235
|
+
- **Auto Range** - Applied when in auto mode
|
|
236
|
+
|
|
237
|
+
When you change modes in HomeKit, the temperature slider will adjust to show the appropriate range. Note that the Home app caches these values, so you may need to close and reopen the accessory detail view to see updated ranges after changing modes.
|
|
238
|
+
|
|
239
|
+
## Troubleshooting
|
|
240
|
+
|
|
241
|
+
### Device not showing up
|
|
242
|
+
|
|
243
|
+
1. Verify your Tuya credentials are correct
|
|
244
|
+
2. Check that the device ID is correct (find it in the Tuya IoT Platform)
|
|
245
|
+
3. Ensure your Tuya app account is linked in the IoT Platform
|
|
246
|
+
4. Check Homebridge logs for error messages
|
|
247
|
+
|
|
248
|
+
### Authentication errors ("sign invalid")
|
|
249
|
+
|
|
250
|
+
1. Verify your Access ID and Access Secret are correct
|
|
251
|
+
2. Ensure you're using the correct API endpoint for your region
|
|
252
|
+
3. Check that your username and password match your Tuya/Smart Life app
|
|
253
|
+
4. Verify the country code is correct
|
|
254
|
+
|
|
255
|
+
### Temperature showing wrong values
|
|
256
|
+
|
|
257
|
+
This plugin handles Tuya's temperature scaling (values stored as temp × 10). If temperatures appear incorrect, please [open an issue](https://github.com/bstillitano/homebridge-tuya-pool-heater/issues).
|
|
258
|
+
|
|
259
|
+
### Commands not working
|
|
260
|
+
|
|
261
|
+
1. Check that your device is online in the Tuya/Smart Life app
|
|
262
|
+
2. Verify the device supports the mode you're trying to set
|
|
263
|
+
3. Check Homebridge logs for API error messages
|
|
264
|
+
|
|
265
|
+
### Frequent disconnections
|
|
266
|
+
|
|
267
|
+
The plugin includes automatic reconnection logic with retry attempts. If you experience frequent disconnections:
|
|
268
|
+
|
|
269
|
+
1. Check your network stability
|
|
270
|
+
2. Increase the `pollInterval` to reduce API calls
|
|
271
|
+
3. Verify your Tuya IoT Platform project hasn't exceeded API limits
|
|
272
|
+
|
|
273
|
+
### HomeKit shows stale data after commands
|
|
274
|
+
|
|
275
|
+
The plugin includes a 10-second debounce after sending commands to prevent poll responses from overwriting your changes. If you still see issues, try increasing the `pollInterval`.
|
|
276
|
+
|
|
277
|
+
## Error Codes
|
|
278
|
+
|
|
279
|
+
| Error | Meaning | Solution |
|
|
280
|
+
|-------|---------|----------|
|
|
281
|
+
| `sign invalid` | HMAC signature mismatch | Check Access ID and Access Secret |
|
|
282
|
+
| `token invalid` | Authentication token expired | Plugin will auto-refresh; restart if persistent |
|
|
283
|
+
| `permission deny` | API permission issue | Ensure device is linked in Tuya IoT Platform |
|
|
284
|
+
| `device offline` | Device not connected | Check device's WiFi connection |
|
|
285
|
+
|
|
286
|
+
## Contributing
|
|
287
|
+
|
|
288
|
+
Contributions are welcome! Please follow these steps:
|
|
289
|
+
|
|
290
|
+
1. Fork the repository
|
|
291
|
+
2. Create a new branch for your feature or bug fix
|
|
292
|
+
3. Make your changes and add tests if applicable
|
|
293
|
+
4. Run `npm test` to ensure all tests pass
|
|
294
|
+
5. Commit your changes with a clear commit message
|
|
295
|
+
6. Push to your fork and submit a pull request
|
|
296
|
+
|
|
297
|
+
### Development Setup
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# Clone the repository
|
|
301
|
+
git clone https://github.com/bstillitano/homebridge-tuya-pool-heater.git
|
|
302
|
+
cd homebridge-tuya-pool-heater
|
|
303
|
+
|
|
304
|
+
# Install dependencies
|
|
305
|
+
npm install
|
|
306
|
+
|
|
307
|
+
# Build the plugin
|
|
308
|
+
npm run build
|
|
309
|
+
|
|
310
|
+
# Run tests
|
|
311
|
+
npm test
|
|
312
|
+
|
|
313
|
+
# Watch mode for development
|
|
314
|
+
npm run watch
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## License
|
|
318
|
+
|
|
319
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
320
|
+
|
|
321
|
+
## Support
|
|
322
|
+
|
|
323
|
+
If you encounter any issues or have feature requests, please [open an issue](https://github.com/bstillitano/homebridge-tuya-pool-heater/issues) on GitHub.
|
|
324
|
+
|
|
325
|
+
## Acknowledgments
|
|
326
|
+
|
|
327
|
+
- [Homebridge](https://homebridge.io/) - HomeKit support for the impatient
|
|
328
|
+
- [Tuya IoT Platform](https://platform.tuya.com) - Cloud API access
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginAlias": "TuyaPoolHeatPump",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": true,
|
|
5
|
+
"headerDisplay": "Homebridge plugin for Tuya-based pool heat pumps",
|
|
6
|
+
"footerDisplay": "For help, see the [GitHub repository](https://github.com/bstillitano/homebridge-tuya-pool-heater)",
|
|
7
|
+
"schema": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"name": {
|
|
11
|
+
"title": "Platform Name",
|
|
12
|
+
"type": "string",
|
|
13
|
+
"default": "Tuya Pool Heat Pump",
|
|
14
|
+
"required": true
|
|
15
|
+
},
|
|
16
|
+
"options": {
|
|
17
|
+
"title": "Tuya API Options",
|
|
18
|
+
"type": "object",
|
|
19
|
+
"properties": {
|
|
20
|
+
"accessId": {
|
|
21
|
+
"title": "Access ID",
|
|
22
|
+
"type": "string",
|
|
23
|
+
"required": true,
|
|
24
|
+
"description": "Your Tuya IoT Platform Access ID"
|
|
25
|
+
},
|
|
26
|
+
"accessKey": {
|
|
27
|
+
"title": "Access Key",
|
|
28
|
+
"type": "string",
|
|
29
|
+
"required": true,
|
|
30
|
+
"description": "Your Tuya IoT Platform Access Secret"
|
|
31
|
+
},
|
|
32
|
+
"endpoint": {
|
|
33
|
+
"title": "API Endpoint",
|
|
34
|
+
"type": "string",
|
|
35
|
+
"required": true,
|
|
36
|
+
"default": "https://openapi.tuyaus.com",
|
|
37
|
+
"oneOf": [
|
|
38
|
+
{ "title": "US - West", "enum": ["https://openapi.tuyaus.com"] },
|
|
39
|
+
{ "title": "EU - Central", "enum": ["https://openapi.tuyaeu.com"] },
|
|
40
|
+
{ "title": "China", "enum": ["https://openapi.tuyacn.com"] },
|
|
41
|
+
{ "title": "India", "enum": ["https://openapi.tuyain.com"] }
|
|
42
|
+
],
|
|
43
|
+
"description": "Select the Tuya API endpoint for your region"
|
|
44
|
+
},
|
|
45
|
+
"username": {
|
|
46
|
+
"title": "Username",
|
|
47
|
+
"type": "string",
|
|
48
|
+
"required": true,
|
|
49
|
+
"description": "Your Tuya/Smart Life app username (email)"
|
|
50
|
+
},
|
|
51
|
+
"password": {
|
|
52
|
+
"title": "Password",
|
|
53
|
+
"type": "string",
|
|
54
|
+
"required": true,
|
|
55
|
+
"description": "Your Tuya/Smart Life app password"
|
|
56
|
+
},
|
|
57
|
+
"countryCode": {
|
|
58
|
+
"title": "Country Code",
|
|
59
|
+
"type": "integer",
|
|
60
|
+
"required": true,
|
|
61
|
+
"default": 1,
|
|
62
|
+
"description": "Your country calling code (e.g., 1 for US, 44 for UK, 61 for Australia)"
|
|
63
|
+
},
|
|
64
|
+
"pollInterval": {
|
|
65
|
+
"title": "Poll Interval (ms)",
|
|
66
|
+
"type": "integer",
|
|
67
|
+
"default": 30000,
|
|
68
|
+
"minimum": 5000,
|
|
69
|
+
"maximum": 300000,
|
|
70
|
+
"description": "How often to poll for device status updates (in milliseconds)"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"devices": {
|
|
75
|
+
"title": "Devices",
|
|
76
|
+
"type": "array",
|
|
77
|
+
"items": {
|
|
78
|
+
"type": "object",
|
|
79
|
+
"properties": {
|
|
80
|
+
"id": {
|
|
81
|
+
"title": "Device ID",
|
|
82
|
+
"type": "string",
|
|
83
|
+
"required": true,
|
|
84
|
+
"description": "The Tuya device ID (found in Tuya IoT Platform or app logs)"
|
|
85
|
+
},
|
|
86
|
+
"name": {
|
|
87
|
+
"title": "Device Name",
|
|
88
|
+
"type": "string",
|
|
89
|
+
"required": true,
|
|
90
|
+
"default": "Pool Heat Pump",
|
|
91
|
+
"description": "The name to display in HomeKit"
|
|
92
|
+
},
|
|
93
|
+
"accessoryType": {
|
|
94
|
+
"title": "Accessory Type",
|
|
95
|
+
"type": "string",
|
|
96
|
+
"required": true,
|
|
97
|
+
"default": "thermostat",
|
|
98
|
+
"oneOf": [
|
|
99
|
+
{ "title": "Thermostat", "enum": ["thermostat"] },
|
|
100
|
+
{ "title": "Heater/Cooler", "enum": ["heatercooler"] }
|
|
101
|
+
],
|
|
102
|
+
"description": "How the device should appear in HomeKit"
|
|
103
|
+
},
|
|
104
|
+
"heatingRange": {
|
|
105
|
+
"title": "Heating Temperature Range",
|
|
106
|
+
"type": "object",
|
|
107
|
+
"properties": {
|
|
108
|
+
"min": {
|
|
109
|
+
"title": "Min (°C)",
|
|
110
|
+
"type": "integer",
|
|
111
|
+
"default": 5,
|
|
112
|
+
"minimum": 0,
|
|
113
|
+
"maximum": 60
|
|
114
|
+
},
|
|
115
|
+
"max": {
|
|
116
|
+
"title": "Max (°C)",
|
|
117
|
+
"type": "integer",
|
|
118
|
+
"default": 55,
|
|
119
|
+
"minimum": 0,
|
|
120
|
+
"maximum": 60
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"coolingRange": {
|
|
125
|
+
"title": "Cooling Temperature Range",
|
|
126
|
+
"type": "object",
|
|
127
|
+
"properties": {
|
|
128
|
+
"min": {
|
|
129
|
+
"title": "Min (°C)",
|
|
130
|
+
"type": "integer",
|
|
131
|
+
"default": 5,
|
|
132
|
+
"minimum": 0,
|
|
133
|
+
"maximum": 60
|
|
134
|
+
},
|
|
135
|
+
"max": {
|
|
136
|
+
"title": "Max (°C)",
|
|
137
|
+
"type": "integer",
|
|
138
|
+
"default": 35,
|
|
139
|
+
"minimum": 0,
|
|
140
|
+
"maximum": 60
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"autoRange": {
|
|
145
|
+
"title": "Auto Temperature Range",
|
|
146
|
+
"type": "object",
|
|
147
|
+
"properties": {
|
|
148
|
+
"min": {
|
|
149
|
+
"title": "Min (°C)",
|
|
150
|
+
"type": "integer",
|
|
151
|
+
"default": 5,
|
|
152
|
+
"minimum": 0,
|
|
153
|
+
"maximum": 60
|
|
154
|
+
},
|
|
155
|
+
"max": {
|
|
156
|
+
"title": "Max (°C)",
|
|
157
|
+
"type": "integer",
|
|
158
|
+
"default": 40,
|
|
159
|
+
"minimum": 0,
|
|
160
|
+
"maximum": 60
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
"layout": [
|
|
170
|
+
{
|
|
171
|
+
"type": "fieldset",
|
|
172
|
+
"title": "Tuya API Configuration",
|
|
173
|
+
"expandable": false,
|
|
174
|
+
"items": [
|
|
175
|
+
"options.accessId",
|
|
176
|
+
"options.accessKey",
|
|
177
|
+
"options.endpoint",
|
|
178
|
+
"options.username",
|
|
179
|
+
"options.password",
|
|
180
|
+
"options.countryCode",
|
|
181
|
+
{ "key": "options.pollInterval", "type": "number" }
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"type": "fieldset",
|
|
186
|
+
"title": "Devices",
|
|
187
|
+
"expandable": true,
|
|
188
|
+
"expanded": true,
|
|
189
|
+
"items": [
|
|
190
|
+
{
|
|
191
|
+
"key": "devices",
|
|
192
|
+
"type": "array",
|
|
193
|
+
"buttonText": "Add Device",
|
|
194
|
+
"items": [
|
|
195
|
+
"devices[].id",
|
|
196
|
+
"devices[].name",
|
|
197
|
+
"devices[].accessoryType",
|
|
198
|
+
{
|
|
199
|
+
"type": "fieldset",
|
|
200
|
+
"title": "Temperature Ranges (Optional)",
|
|
201
|
+
"expandable": true,
|
|
202
|
+
"expanded": false,
|
|
203
|
+
"items": [
|
|
204
|
+
{
|
|
205
|
+
"type": "help",
|
|
206
|
+
"helpvalue": "<strong>Heating Mode</strong>"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"type": "flex",
|
|
210
|
+
"flex-flow": "row wrap",
|
|
211
|
+
"items": [
|
|
212
|
+
{ "key": "devices[].heatingRange.min", "type": "number" },
|
|
213
|
+
{ "key": "devices[].heatingRange.max", "type": "number" }
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"type": "help",
|
|
218
|
+
"helpvalue": "<strong>Cooling Mode</strong>"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"type": "flex",
|
|
222
|
+
"flex-flow": "row wrap",
|
|
223
|
+
"items": [
|
|
224
|
+
{ "key": "devices[].coolingRange.min", "type": "number" },
|
|
225
|
+
{ "key": "devices[].coolingRange.max", "type": "number" }
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"type": "help",
|
|
230
|
+
"helpvalue": "<strong>Auto Mode</strong>"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"type": "flex",
|
|
234
|
+
"flex-flow": "row wrap",
|
|
235
|
+
"items": [
|
|
236
|
+
{ "key": "devices[].autoRange.min", "type": "number" },
|
|
237
|
+
{ "key": "devices[].autoRange.max", "type": "number" }
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
]
|
|
247
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
2
|
+
import { TuyaPoolHeatPumpPlatform } from './platform';
|
|
3
|
+
import { DeviceConfig } from './settings';
|
|
4
|
+
export declare class HeaterCoolerAccessory {
|
|
5
|
+
private service;
|
|
6
|
+
private readonly platform;
|
|
7
|
+
private readonly accessory;
|
|
8
|
+
private readonly deviceConfig;
|
|
9
|
+
private active;
|
|
10
|
+
private currentTemperature;
|
|
11
|
+
private heatingThresholdTemperature;
|
|
12
|
+
private coolingThresholdTemperature;
|
|
13
|
+
private currentHeaterCoolerState;
|
|
14
|
+
private targetHeaterCoolerState;
|
|
15
|
+
private lastCommandTime;
|
|
16
|
+
private readonly commandDebounceMs;
|
|
17
|
+
constructor(platform: TuyaPoolHeatPumpPlatform, accessory: PlatformAccessory, deviceConfig: DeviceConfig);
|
|
18
|
+
private fetchInitialStatus;
|
|
19
|
+
private updateState;
|
|
20
|
+
private updateModeFromTuya;
|
|
21
|
+
getActive(): Promise<CharacteristicValue>;
|
|
22
|
+
setActive(value: CharacteristicValue): Promise<void>;
|
|
23
|
+
getCurrentTemperature(): Promise<CharacteristicValue>;
|
|
24
|
+
getCurrentHeaterCoolerState(): Promise<CharacteristicValue>;
|
|
25
|
+
getTargetHeaterCoolerState(): Promise<CharacteristicValue>;
|
|
26
|
+
setTargetHeaterCoolerState(value: CharacteristicValue): Promise<void>;
|
|
27
|
+
getHeatingThresholdTemperature(): Promise<CharacteristicValue>;
|
|
28
|
+
setHeatingThresholdTemperature(value: CharacteristicValue): Promise<void>;
|
|
29
|
+
getCoolingThresholdTemperature(): Promise<CharacteristicValue>;
|
|
30
|
+
setCoolingThresholdTemperature(value: CharacteristicValue): Promise<void>;
|
|
31
|
+
}
|