homebridge-yoto 0.0.1 → 0.0.3
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/AGENTS.md +253 -0
- package/PLAN.md +609 -0
- package/README.md +315 -6
- package/config.schema.json +222 -0
- package/index.js +15 -2
- package/index.test.js +4 -4
- package/lib/auth.js +220 -0
- package/lib/constants.js +157 -0
- package/lib/platform.js +269 -0
- package/lib/playerAccessory.js +1452 -0
- package/lib/types.js +233 -0
- package/lib/yotoApi.js +260 -0
- package/lib/yotoMqtt.js +521 -0
- package/package.json +14 -7
- package/lib/.keep +0 -0
package/README.md
CHANGED
|
@@ -1,24 +1,333 @@
|
|
|
1
1
|
# homebridge-yoto
|
|
2
|
+
|
|
2
3
|
[](https://www.npmjs.com/package/homebridge-yoto)
|
|
3
4
|
[](https://github.com/bcomnes/homebridge-yoto/actions)
|
|
4
|
-
|
|
5
5
|
[](https://npmtrends.com/homebridge-yoto)
|
|
6
6
|

|
|
7
7
|
[](https://github.com/neostandard/neostandard)
|
|
8
8
|
[](https://socket.dev/npm/package/homebridge-yoto)
|
|
9
9
|
|
|
10
|
-
WIP
|
|
10
|
+
THIS PLUGIN IS A WIP. DO NOT USE YET.
|
|
11
|
+
|
|
12
|
+
> Control your Yoto players through Apple HomeKit
|
|
13
|
+
|
|
14
|
+
A Homebridge plugin that integrates Yoto audio players with Apple HomeKit, providing real-time control over playback, volume, and device status through MQTT.
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- 🎵 **Playback Control** - Play, pause, and stop content from the Home app
|
|
19
|
+
- 🔊 **Volume Control** - Adjust volume with HomeKit sliders or Siri
|
|
20
|
+
- 🔋 **Battery Status** - Monitor battery level and charging state
|
|
21
|
+
- 🌡️ **Temperature Monitoring** - Track device temperature
|
|
22
|
+
- 📡 **Connection Status** - Know when devices are online/offline
|
|
23
|
+
- 🎴 **Card Detection** - Detect when cards are inserted
|
|
24
|
+
- 💡 **Display Brightness** - Control screen brightness like a lightbulb
|
|
25
|
+
- ⏱️ **Sleep Timer** - Set auto-shutoff timer (0-120 minutes)
|
|
26
|
+
- 🔊 **Volume Limits** - Set separate day/night maximum volume levels (0-16)
|
|
27
|
+
- 🎨 **Ambient Light** - Full RGB color control for ambient LEDs
|
|
28
|
+
- 📝 **Active Content** - Track and display what's currently playing
|
|
29
|
+
- ⚙️ **Advanced Controls** - Bluetooth, Repeat, and more via switches
|
|
30
|
+
- ⚡ **Real-Time Updates** - Instant status updates via MQTT (no polling!)
|
|
31
|
+
- 🔐 **Secure OAuth2** - Device authorization flow for authentication
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
### Via Homebridge UI (Recommended)
|
|
36
|
+
|
|
37
|
+
1. Search for "Yoto" in the Homebridge Config UI X plugin search
|
|
38
|
+
2. Click **Install**
|
|
39
|
+
3. Follow the OAuth setup instructions in the Homebridge logs
|
|
40
|
+
4. Restart Homebridge
|
|
41
|
+
|
|
42
|
+
### Via Command Line
|
|
11
43
|
|
|
44
|
+
```bash
|
|
45
|
+
npm install -g homebridge-yoto
|
|
12
46
|
```
|
|
47
|
+
|
|
48
|
+
Or add to your Homebridge `package.json`:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
13
51
|
npm install homebridge-yoto
|
|
14
52
|
```
|
|
15
53
|
|
|
16
|
-
##
|
|
54
|
+
## Configuration
|
|
55
|
+
|
|
56
|
+
### Initial Setup
|
|
57
|
+
|
|
58
|
+
1. **Install the plugin** using one of the methods above
|
|
59
|
+
2. **Start Homebridge** - the plugin will automatically initiate OAuth flow (uses default OAuth client ID)
|
|
60
|
+
3. **Check the logs** for authentication instructions:
|
|
61
|
+
```
|
|
62
|
+
[Yoto] ============================================================
|
|
63
|
+
[Yoto] YOTO AUTHENTICATION REQUIRED
|
|
64
|
+
[Yoto] ============================================================
|
|
65
|
+
[Yoto]
|
|
66
|
+
[Yoto] 1. Visit: https://api.yotoplay.com/device/auth
|
|
67
|
+
[Yoto] 2. Enter code: ABC-DEF-GHI
|
|
68
|
+
[Yoto]
|
|
69
|
+
[Yoto] Or visit: https://api.yotoplay.com/device/auth?code=ABC-DEF-GHI
|
|
70
|
+
[Yoto]
|
|
71
|
+
[Yoto] Code expires in 5 minutes
|
|
72
|
+
[Yoto] ============================================================
|
|
73
|
+
```
|
|
74
|
+
4. **Visit the URL** and enter the code to authorize
|
|
75
|
+
5. **Wait for confirmation** - tokens will be saved automatically
|
|
76
|
+
6. **Restart Homebridge** to complete setup
|
|
77
|
+
|
|
78
|
+
### Configuration Options
|
|
79
|
+
|
|
80
|
+
The plugin can be configured through the Homebridge Config UI or by editing `config.json`:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"platform": "Yoto",
|
|
85
|
+
"name": "Yoto",
|
|
86
|
+
"clientId": "Y4HJ8BFqRQ24GQoLzgOzZ2KSqWmFG8LI",
|
|
87
|
+
"mqttBroker": "mqtt://mqtt.yotoplay.com:1883",
|
|
88
|
+
"statusTimeoutSeconds": 120,
|
|
89
|
+
"exposeTemperature": true,
|
|
90
|
+
"exposeBattery": true,
|
|
91
|
+
"exposeConnectionStatus": true,
|
|
92
|
+
"exposeCardDetection": false,
|
|
93
|
+
"exposeDisplayBrightness": true,
|
|
94
|
+
"exposeSleepTimer": false,
|
|
95
|
+
"exposeVolumeLimits": false,
|
|
96
|
+
"exposeAmbientLight": false,
|
|
97
|
+
"exposeActiveContent": true,
|
|
98
|
+
"updateAccessoryName": false,
|
|
99
|
+
"exposeAdvancedControls": false,
|
|
100
|
+
"volumeControlType": "speaker",
|
|
101
|
+
"debug": false
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### Configuration Fields
|
|
106
|
+
|
|
107
|
+
| Field | Type | Default | Description |
|
|
108
|
+
|-------|------|---------|-------------|
|
|
109
|
+
| `platform` | string | `"Yoto"` | **Required** - Must be "Yoto" |
|
|
110
|
+
| `name` | string | `"Yoto"` | Platform name in Homebridge logs |
|
|
111
|
+
| `clientId` | string | `Y4HJ8BFqRQ24GQoLzgOzZ2KSqWmFG8LI` | OAuth client ID (default works for most users) |
|
|
112
|
+
| `accessToken` | string | - | OAuth access token (managed automatically) |
|
|
113
|
+
| `refreshToken` | string | - | OAuth refresh token (managed automatically) |
|
|
114
|
+
| `tokenExpiresAt` | number | - | Token expiration timestamp (managed automatically) |
|
|
115
|
+
| `mqttBroker` | string | `mqtt://mqtt.yotoplay.com:1883` | MQTT broker URL |
|
|
116
|
+
| `statusTimeoutSeconds` | number | `120` | Seconds without updates before marking offline |
|
|
117
|
+
| `exposeTemperature` | boolean | `true` | Add temperature sensor service |
|
|
118
|
+
| `exposeBattery` | boolean | `true` | Add battery service |
|
|
119
|
+
| `exposeConnectionStatus` | boolean | `true` | Add online/offline status sensor |
|
|
120
|
+
| `exposeCardDetection` | boolean | `false` | Add card insertion detection sensor |
|
|
121
|
+
| `exposeDisplayBrightness` | boolean | `true` | Add lightbulb service for display brightness |
|
|
122
|
+
| `exposeSleepTimer` | boolean | `false` | Add fan service for sleep timer control |
|
|
123
|
+
| `exposeVolumeLimits` | boolean | `false` | Add lightbulb services for day/night volume limits |
|
|
124
|
+
| `exposeAmbientLight` | boolean | `false` | Add lightbulb service with RGB color control |
|
|
125
|
+
| `exposeActiveContent` | boolean | `true` | Track and log currently playing content |
|
|
126
|
+
| `updateAccessoryName` | boolean | `false` | Update accessory name with current content title |
|
|
127
|
+
| `exposeAdvancedControls` | boolean | `false` | Add switches for Bluetooth, Repeat, etc. |
|
|
128
|
+
| `volumeControlType` | string | `"speaker"` | Service type for volume (`"speaker"`, `"fan"`, or `"lightbulb"`) |
|
|
129
|
+
| `debug` | boolean | `false` | Enable verbose debug logging |
|
|
130
|
+
|
|
131
|
+
**Note on Client ID:** The default client ID (`Y4HJ8BFqRQ24GQoLzgOzZ2KSqWmFG8LI`) is a public OAuth application that works for all users. You only need to change this if:
|
|
132
|
+
- You want to use your own OAuth application
|
|
133
|
+
- You're experiencing rate limiting issues
|
|
134
|
+
- You need custom OAuth settings
|
|
135
|
+
|
|
136
|
+
To create your own OAuth app, visit [yoto.dev](https://yoto.dev).
|
|
137
|
+
|
|
138
|
+
## HomeKit Services
|
|
139
|
+
|
|
140
|
+
Each Yoto player is exposed as a HomeKit accessory with the following services:
|
|
141
|
+
|
|
142
|
+
### Smart Speaker (Primary)
|
|
143
|
+
- **Current Media State** - Shows if content is playing, paused, or stopped
|
|
144
|
+
- **Target Media State** - Control playback (play/pause/stop)
|
|
145
|
+
- **Volume** - Adjust volume (0-100)
|
|
146
|
+
- **Mute** - Mute/unmute audio
|
|
147
|
+
|
|
148
|
+
### Battery (Optional)
|
|
149
|
+
- **Battery Level** - Current battery percentage
|
|
150
|
+
- **Charging State** - Whether device is charging
|
|
151
|
+
- **Low Battery** - Alert when battery is below 20%
|
|
152
|
+
|
|
153
|
+
### Temperature Sensor (Optional)
|
|
154
|
+
- **Current Temperature** - Device temperature in Celsius
|
|
155
|
+
|
|
156
|
+
### Occupancy Sensor (Optional)
|
|
157
|
+
- **Occupancy Detected** - Indicates if device is online
|
|
158
|
+
- **Status Active** - Shows connection status
|
|
159
|
+
|
|
160
|
+
### Contact Sensor (Optional)
|
|
161
|
+
- **Contact Sensor State** - Detects when a card is inserted
|
|
162
|
+
|
|
163
|
+
### Lightbulb (Display Brightness, Optional)
|
|
164
|
+
- **On/Off** - Turn display on or off
|
|
165
|
+
- **Brightness** - Adjust display brightness (0-100)
|
|
166
|
+
|
|
167
|
+
### Fan (Sleep Timer, Optional)
|
|
168
|
+
- **Active** - Enable/disable sleep timer
|
|
169
|
+
- **Rotation Speed** - Timer duration (0-100 = 0-120 minutes)
|
|
170
|
+
|
|
171
|
+
### Switches (Advanced Controls, Optional)
|
|
172
|
+
- **Bluetooth Switch** - Enable/disable Bluetooth
|
|
173
|
+
- **Repeat Switch** - Enable/disable repeat all
|
|
174
|
+
- **BT Headphones Switch** - Enable/disable Bluetooth headphones
|
|
175
|
+
|
|
176
|
+
### Lightbulb (Volume Limits, Optional)
|
|
177
|
+
- **Day Volume Limit** - Maximum volume during day mode (0-16 = 0-100%)
|
|
178
|
+
- **Night Volume Limit** - Maximum volume during night mode (0-16 = 0-100%)
|
|
179
|
+
|
|
180
|
+
### Lightbulb (Ambient Light, Optional)
|
|
181
|
+
- **On/Off** - Enable/disable ambient light
|
|
182
|
+
- **Hue** - Color hue (0-360)
|
|
183
|
+
- **Saturation** - Color saturation (0-100%)
|
|
184
|
+
- **Brightness** - Light intensity (0-100%)
|
|
185
|
+
|
|
186
|
+
### Active Content Information (Optional)
|
|
187
|
+
- Automatically tracks and logs currently playing content
|
|
188
|
+
- Displays card title, author, and category in logs
|
|
189
|
+
- Optionally updates accessory name with current content
|
|
190
|
+
|
|
191
|
+
## Usage Examples
|
|
192
|
+
|
|
193
|
+
### Siri Commands
|
|
194
|
+
|
|
195
|
+
- "Hey Siri, play Bedroom Player"
|
|
196
|
+
- "Hey Siri, pause Kitchen Player"
|
|
197
|
+
- "Hey Siri, set Bedroom Player volume to 50%"
|
|
198
|
+
- "Hey Siri, turn on Bedroom Player Display"
|
|
199
|
+
- "Hey Siri, set Bedroom Player Display to 30%"
|
|
200
|
+
- "Hey Siri, turn on Bedroom Player Sleep Timer"
|
|
201
|
+
- "Hey Siri, set Bedroom Player Day Volume Limit to 75%"
|
|
202
|
+
- "Hey Siri, set Bedroom Player Ambient Light to red"
|
|
203
|
+
- "Hey Siri, what's the battery level of my Yoto Player?"
|
|
204
|
+
|
|
205
|
+
### Automation Ideas
|
|
206
|
+
|
|
207
|
+
- **Bedtime Routine** - Automatically pause all players at bedtime
|
|
208
|
+
- **Good Morning** - Start playing daily content when you wake up
|
|
209
|
+
- **Low Battery Alert** - Get notified when battery drops below 20%
|
|
210
|
+
- **Card Inserted** - Trigger lights or scenes when a card is inserted
|
|
211
|
+
- **Device Online** - Get notified when a player comes online
|
|
212
|
+
- **Dim Display at Night** - Automatically dim display brightness at bedtime
|
|
213
|
+
- **Sleep Timer** - Auto-stop playback after a set time
|
|
214
|
+
- **Night Mode Volume** - Automatically lower max volume at bedtime
|
|
215
|
+
- **Ambient Light Scenes** - Change LED colors based on time of day or mood
|
|
216
|
+
- **Content-Based Automations** - Trigger actions when specific content starts playing
|
|
217
|
+
|
|
218
|
+
## Troubleshooting
|
|
219
|
+
|
|
220
|
+
### Authentication Issues
|
|
221
|
+
|
|
222
|
+
**Problem:** OAuth flow not completing
|
|
223
|
+
|
|
224
|
+
**Solution:**
|
|
225
|
+
1. Check that you're visiting the correct URL from the logs
|
|
226
|
+
2. Ensure the code hasn't expired (5 minute timeout)
|
|
227
|
+
3. Try restarting Homebridge to generate a new code
|
|
228
|
+
4. Check your internet connection
|
|
229
|
+
5. Verify the client ID is correct (default: `Y4HJ8BFqRQ24GQoLzgOzZ2KSqWmFG8LI`)
|
|
230
|
+
|
|
231
|
+
**Problem:** "Invalid client" or "Client not found" errors
|
|
232
|
+
|
|
233
|
+
**Solution:**
|
|
234
|
+
1. Ensure you haven't changed the `clientId` field in config
|
|
235
|
+
2. If using a custom client ID, verify it's correct at yoto.dev
|
|
236
|
+
3. Try removing the `clientId` field to use the default
|
|
237
|
+
|
|
238
|
+
### MQTT Connection Issues
|
|
239
|
+
|
|
240
|
+
**Problem:** No real-time updates, devices show "No Response"
|
|
241
|
+
|
|
242
|
+
**Solution:**
|
|
243
|
+
1. Check `statusTimeoutSeconds` setting - increase if needed
|
|
244
|
+
2. Verify MQTT broker URL is correct
|
|
245
|
+
3. Check Homebridge logs for MQTT connection errors
|
|
246
|
+
4. Ensure your network allows MQTT connections (port 1883)
|
|
247
|
+
|
|
248
|
+
### Device Not Appearing
|
|
249
|
+
|
|
250
|
+
**Problem:** Yoto player doesn't show up in Home app
|
|
251
|
+
|
|
252
|
+
**Solution:**
|
|
253
|
+
1. Verify device appears in Yoto app
|
|
254
|
+
2. Check Homebridge logs for discovery messages
|
|
255
|
+
3. Try restarting Homebridge
|
|
256
|
+
4. Remove cached accessories and restart
|
|
257
|
+
|
|
258
|
+
### Token Refresh Issues
|
|
259
|
+
|
|
260
|
+
**Problem:** "Token refresh failed" errors
|
|
261
|
+
|
|
262
|
+
**Solution:**
|
|
263
|
+
1. Clear tokens from config and restart to re-authenticate
|
|
264
|
+
2. Check system time is correct (affects token validation)
|
|
265
|
+
3. Verify you have internet connectivity
|
|
266
|
+
|
|
267
|
+
## Development
|
|
268
|
+
|
|
269
|
+
This plugin uses TypeScript-in-JavaScript with JSDoc for type safety.
|
|
270
|
+
|
|
271
|
+
### Setup
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
git clone https://github.com/bcomnes/homebridge-yoto.git
|
|
275
|
+
cd homebridge-yoto
|
|
276
|
+
npm install
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Running Tests
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
npm test
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Code Style
|
|
17
286
|
|
|
18
|
-
```
|
|
19
|
-
|
|
287
|
+
```bash
|
|
288
|
+
npm run test:lint
|
|
20
289
|
```
|
|
21
290
|
|
|
291
|
+
### Type Checking
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
npm run test:tsc
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Architecture
|
|
298
|
+
|
|
299
|
+
- **OAuth2 Device Flow** - Secure authentication without client secrets
|
|
300
|
+
- **MQTT Real-Time Updates** - Instant status updates via `/device/{id}/data/status` and `/device/{id}/data/events` topics
|
|
301
|
+
- **Dynamic Platform** - Automatically discovers and registers devices
|
|
302
|
+
- **REST API** - Used for device discovery and configuration updates
|
|
303
|
+
- **Platform Accessories** - Each Yoto player is a cached platform accessory
|
|
304
|
+
|
|
305
|
+
## API Documentation
|
|
306
|
+
|
|
307
|
+
- [Yoto Developer API](https://yoto.dev/api/)
|
|
308
|
+
- [Yoto MQTT Documentation](https://yoto.dev/players-mqtt/mqtt-docs/)
|
|
309
|
+
|
|
310
|
+
## Contributing
|
|
311
|
+
|
|
312
|
+
Contributions are welcome! Please:
|
|
313
|
+
|
|
314
|
+
1. Fork the repository
|
|
315
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
316
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
317
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
318
|
+
5. Open a Pull Request
|
|
319
|
+
|
|
22
320
|
## License
|
|
23
321
|
|
|
24
|
-
MIT
|
|
322
|
+
MIT © [Bret Comnes](https://bret.io)
|
|
323
|
+
|
|
324
|
+
## Acknowledgments
|
|
325
|
+
|
|
326
|
+
- Thanks to [Yoto](https://yoto.io) for their excellent API and MQTT documentation
|
|
327
|
+
- Built with [Homebridge](https://homebridge.io)
|
|
328
|
+
|
|
329
|
+
## Support
|
|
330
|
+
|
|
331
|
+
- 🐛 [Report a Bug](https://github.com/bcomnes/homebridge-yoto/issues)
|
|
332
|
+
- 💡 [Request a Feature](https://github.com/bcomnes/homebridge-yoto/issues)
|
|
333
|
+
- 📖 [Documentation](https://github.com/bcomnes/homebridge-yoto#readme)
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginAlias": "Yoto",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": true,
|
|
5
|
+
"headerDisplay": "**Homebridge Yoto Plugin** - Control your Yoto players through HomeKit",
|
|
6
|
+
"footerDisplay": "For help and documentation, visit the [GitHub repository](https://github.com/bcomnes/homebridge-yoto)",
|
|
7
|
+
"schema": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"name": {
|
|
11
|
+
"title": "Platform Name",
|
|
12
|
+
"type": "string",
|
|
13
|
+
"default": "Yoto",
|
|
14
|
+
"required": true,
|
|
15
|
+
"description": "The name of the platform as it appears in Homebridge logs"
|
|
16
|
+
},
|
|
17
|
+
"clientId": {
|
|
18
|
+
"title": "OAuth Client ID",
|
|
19
|
+
"type": "string",
|
|
20
|
+
"default": "Y4HJ8BFqRQ24GQoLzgOzZ2KSqWmFG8LI",
|
|
21
|
+
"required": false,
|
|
22
|
+
"description": "OAuth client ID for Yoto API authentication. Default works for most users. Create your own OAuth app at yoto.dev if needed."
|
|
23
|
+
},
|
|
24
|
+
"accessToken": {
|
|
25
|
+
"title": "Access Token",
|
|
26
|
+
"type": "string",
|
|
27
|
+
"required": false,
|
|
28
|
+
"description": "Stored access token (managed automatically after OAuth)"
|
|
29
|
+
},
|
|
30
|
+
"refreshToken": {
|
|
31
|
+
"title": "Refresh Token",
|
|
32
|
+
"type": "string",
|
|
33
|
+
"required": false,
|
|
34
|
+
"description": "Stored refresh token (managed automatically after OAuth)"
|
|
35
|
+
},
|
|
36
|
+
"tokenExpiresAt": {
|
|
37
|
+
"title": "Token Expiration",
|
|
38
|
+
"type": "number",
|
|
39
|
+
"required": false,
|
|
40
|
+
"description": "Token expiration timestamp (managed automatically)"
|
|
41
|
+
},
|
|
42
|
+
"mqttBroker": {
|
|
43
|
+
"title": "MQTT Broker URL",
|
|
44
|
+
"type": "string",
|
|
45
|
+
"default": "mqtt://mqtt.yotoplay.com:1883",
|
|
46
|
+
"required": false,
|
|
47
|
+
"description": "MQTT broker URL for real-time device communication"
|
|
48
|
+
},
|
|
49
|
+
"statusTimeoutSeconds": {
|
|
50
|
+
"title": "Status Timeout (seconds)",
|
|
51
|
+
"type": "number",
|
|
52
|
+
"default": 120,
|
|
53
|
+
"minimum": 60,
|
|
54
|
+
"maximum": 300,
|
|
55
|
+
"required": false,
|
|
56
|
+
"description": "Seconds without MQTT updates before marking device offline"
|
|
57
|
+
},
|
|
58
|
+
"exposeTemperature": {
|
|
59
|
+
"title": "Expose Temperature Sensor",
|
|
60
|
+
"type": "boolean",
|
|
61
|
+
"default": true,
|
|
62
|
+
"required": false,
|
|
63
|
+
"description": "Add temperature sensor service to each device"
|
|
64
|
+
},
|
|
65
|
+
"exposeBattery": {
|
|
66
|
+
"title": "Expose Battery Service",
|
|
67
|
+
"type": "boolean",
|
|
68
|
+
"default": true,
|
|
69
|
+
"required": false,
|
|
70
|
+
"description": "Add battery service to each device"
|
|
71
|
+
},
|
|
72
|
+
"exposeConnectionStatus": {
|
|
73
|
+
"title": "Expose Connection Status",
|
|
74
|
+
"type": "boolean",
|
|
75
|
+
"default": true,
|
|
76
|
+
"required": false,
|
|
77
|
+
"description": "Add occupancy sensor to track device online/offline status"
|
|
78
|
+
},
|
|
79
|
+
"exposeCardDetection": {
|
|
80
|
+
"title": "Expose Card Detection",
|
|
81
|
+
"type": "boolean",
|
|
82
|
+
"default": false,
|
|
83
|
+
"required": false,
|
|
84
|
+
"description": "Add contact sensor to detect when a card is inserted"
|
|
85
|
+
},
|
|
86
|
+
"exposeVolumeLimits": {
|
|
87
|
+
"title": "Expose Volume Limits",
|
|
88
|
+
"type": "boolean",
|
|
89
|
+
"default": false,
|
|
90
|
+
"required": false,
|
|
91
|
+
"description": "Add lightbulb services to control day and night volume limits (0-16)"
|
|
92
|
+
},
|
|
93
|
+
"exposeAmbientLight": {
|
|
94
|
+
"title": "Expose Ambient Light",
|
|
95
|
+
"type": "boolean",
|
|
96
|
+
"default": false,
|
|
97
|
+
"required": false,
|
|
98
|
+
"description": "Add lightbulb service with RGB color control for ambient light"
|
|
99
|
+
},
|
|
100
|
+
"exposeActiveContent": {
|
|
101
|
+
"title": "Expose Active Content",
|
|
102
|
+
"type": "boolean",
|
|
103
|
+
"default": true,
|
|
104
|
+
"required": false,
|
|
105
|
+
"description": "Track and log active content information when playing"
|
|
106
|
+
},
|
|
107
|
+
"updateAccessoryName": {
|
|
108
|
+
"title": "Update Accessory Name with Content",
|
|
109
|
+
"type": "boolean",
|
|
110
|
+
"default": false,
|
|
111
|
+
"required": false,
|
|
112
|
+
"description": "Update accessory display name to show currently playing content"
|
|
113
|
+
},
|
|
114
|
+
"exposeDisplayBrightness": {
|
|
115
|
+
"title": "Expose Display Brightness",
|
|
116
|
+
"type": "boolean",
|
|
117
|
+
"default": true,
|
|
118
|
+
"required": false,
|
|
119
|
+
"description": "Add lightbulb service to control display brightness"
|
|
120
|
+
},
|
|
121
|
+
"exposeSleepTimer": {
|
|
122
|
+
"title": "Expose Sleep Timer",
|
|
123
|
+
"type": "boolean",
|
|
124
|
+
"default": false,
|
|
125
|
+
"required": false,
|
|
126
|
+
"description": "Add fan service to control sleep timer (rotation speed = minutes)"
|
|
127
|
+
},
|
|
128
|
+
"exposeAdvancedControls": {
|
|
129
|
+
"title": "Expose Advanced Controls",
|
|
130
|
+
"type": "boolean",
|
|
131
|
+
"default": false,
|
|
132
|
+
"required": false,
|
|
133
|
+
"description": "Add switches for advanced settings (Bluetooth, Repeat, BT Headphones)"
|
|
134
|
+
},
|
|
135
|
+
"volumeControlType": {
|
|
136
|
+
"title": "Volume Control Type",
|
|
137
|
+
"type": "string",
|
|
138
|
+
"default": "speaker",
|
|
139
|
+
"required": false,
|
|
140
|
+
"oneOf": [
|
|
141
|
+
{
|
|
142
|
+
"title": "Smart Speaker",
|
|
143
|
+
"enum": ["speaker"]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"title": "Fan (Alternate)",
|
|
147
|
+
"enum": ["fan"]
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"title": "Lightbulb (Alternate)",
|
|
151
|
+
"enum": ["lightbulb"]
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
"description": "Service type to use for volume control"
|
|
155
|
+
},
|
|
156
|
+
"debug": {
|
|
157
|
+
"title": "Debug Logging",
|
|
158
|
+
"type": "boolean",
|
|
159
|
+
"default": false,
|
|
160
|
+
"required": false,
|
|
161
|
+
"description": "Enable verbose debug logging"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"layout": [
|
|
166
|
+
{
|
|
167
|
+
"type": "section",
|
|
168
|
+
"title": "Platform Configuration",
|
|
169
|
+
"expandable": false,
|
|
170
|
+
"items": ["name"]
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"type": "section",
|
|
174
|
+
"title": "Authentication",
|
|
175
|
+
"expandable": true,
|
|
176
|
+
"expanded": false,
|
|
177
|
+
"items": [
|
|
178
|
+
{
|
|
179
|
+
"type": "help",
|
|
180
|
+
"helpvalue": "<p><strong>OAuth Setup Instructions:</strong></p><ol><li>Start Homebridge - the plugin will initiate OAuth flow automatically if no tokens are present</li><li>Check Homebridge logs for the verification URL and user code</li><li>Visit the URL and enter the code to authorize the plugin</li><li>After authorization, the tokens will be saved automatically</li><li>Restart Homebridge to apply the changes</li></ol><p><strong>Client ID:</strong> The default client ID works for most users. Only change if you've created your own OAuth app at yoto.dev or experiencing rate limiting.</p><p><em>Note: Token fields are managed automatically and should not be edited manually unless troubleshooting.</em></p>"
|
|
181
|
+
},
|
|
182
|
+
"clientId",
|
|
183
|
+
"accessToken",
|
|
184
|
+
"refreshToken",
|
|
185
|
+
"tokenExpiresAt"
|
|
186
|
+
]
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"type": "section",
|
|
190
|
+
"title": "MQTT Configuration",
|
|
191
|
+
"expandable": true,
|
|
192
|
+
"expanded": false,
|
|
193
|
+
"items": ["mqttBroker", "statusTimeoutSeconds"]
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"type": "section",
|
|
197
|
+
"title": "Feature Toggles",
|
|
198
|
+
"expandable": true,
|
|
199
|
+
"expanded": true,
|
|
200
|
+
"items": [
|
|
201
|
+
"exposeBattery",
|
|
202
|
+
"exposeTemperature",
|
|
203
|
+
"exposeConnectionStatus",
|
|
204
|
+
"exposeCardDetection",
|
|
205
|
+
"exposeDisplayBrightness",
|
|
206
|
+
"exposeSleepTimer",
|
|
207
|
+
"exposeVolumeLimits",
|
|
208
|
+
"exposeAmbientLight",
|
|
209
|
+
"exposeAdvancedControls",
|
|
210
|
+
"exposeActiveContent",
|
|
211
|
+
"updateAccessoryName"
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"type": "section",
|
|
216
|
+
"title": "Advanced Settings",
|
|
217
|
+
"expandable": true,
|
|
218
|
+
"expanded": false,
|
|
219
|
+
"items": ["volumeControlType", "debug"]
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
}
|
package/index.js
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Homebridge Yoto Plugin Entry Point
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** @import { API } from 'homebridge' */
|
|
6
|
+
|
|
7
|
+
import { YotoPlatform } from './lib/platform.js'
|
|
8
|
+
import { PLATFORM_NAME } from './lib/constants.js'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Register the Yoto platform with Homebridge
|
|
12
|
+
* @param {API} api - Homebridge API
|
|
13
|
+
*/
|
|
14
|
+
export default function (api) {
|
|
15
|
+
api.registerPlatform(PLATFORM_NAME, YotoPlatform)
|
|
3
16
|
}
|
package/index.test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import test from 'node:test'
|
|
1
|
+
import { test } from 'node:test'
|
|
2
2
|
import assert from 'node:assert'
|
|
3
|
-
import
|
|
3
|
+
import homebridgeYoto from './index.js'
|
|
4
4
|
|
|
5
|
-
test('
|
|
6
|
-
assert.strictEqual(
|
|
5
|
+
test('exports default function', () => {
|
|
6
|
+
assert.strictEqual(typeof homebridgeYoto, 'function')
|
|
7
7
|
})
|