homebridge-yoto 0.0.33 → 0.0.35
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/lib/accessory.js +11 -11
- package/lib/platform.js +13 -11
- package/package.json +1 -1
package/lib/accessory.js
CHANGED
|
@@ -82,7 +82,7 @@ export class YotoPlayerAccessory {
|
|
|
82
82
|
* @returns {Promise<void>}
|
|
83
83
|
*/
|
|
84
84
|
async setup () {
|
|
85
|
-
this.#log.
|
|
85
|
+
this.#log.debug(LOG_PREFIX.ACCESSORY, `Setting up ${this.#device.name}`)
|
|
86
86
|
|
|
87
87
|
// Check if device type is supported
|
|
88
88
|
if (!this.#deviceModel.capabilities.supported) {
|
|
@@ -121,7 +121,7 @@ export class YotoPlayerAccessory {
|
|
|
121
121
|
for (const service of this.#accessory.services) {
|
|
122
122
|
if (service.UUID !== this.#platform.Service.AccessoryInformation.UUID &&
|
|
123
123
|
!this.#currentServices.has(service)) {
|
|
124
|
-
this.#log.
|
|
124
|
+
this.#log.debug(LOG_PREFIX.ACCESSORY, `Removing stale service: ${service.displayName || service.UUID}`)
|
|
125
125
|
this.#accessory.removeService(service)
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -129,7 +129,7 @@ export class YotoPlayerAccessory {
|
|
|
129
129
|
// 2. Setup event listeners for device model updates
|
|
130
130
|
this.setupEventListeners()
|
|
131
131
|
|
|
132
|
-
this.#log.
|
|
132
|
+
this.#log.debug(LOG_PREFIX.ACCESSORY, `✓ ${this.#device.name} ready`)
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/**
|
|
@@ -775,12 +775,12 @@ export class YotoPlayerAccessory {
|
|
|
775
775
|
|
|
776
776
|
// Lifecycle events
|
|
777
777
|
this.#deviceModel.on('online', ({ reason }) => {
|
|
778
|
-
|
|
778
|
+
// Platform logs online/offline events to avoid duplicate output.
|
|
779
779
|
this.updateOnlineStatusCharacteristic(true)
|
|
780
780
|
})
|
|
781
781
|
|
|
782
782
|
this.#deviceModel.on('offline', ({ reason }) => {
|
|
783
|
-
|
|
783
|
+
// Platform logs online/offline events to avoid duplicate output.
|
|
784
784
|
this.updateOnlineStatusCharacteristic(false)
|
|
785
785
|
})
|
|
786
786
|
|
|
@@ -1380,11 +1380,11 @@ export class YotoPlayerAccessory {
|
|
|
1380
1380
|
try {
|
|
1381
1381
|
if (enabled) {
|
|
1382
1382
|
// Turn on sleep timer - default to 30 minutes
|
|
1383
|
-
this.#log.
|
|
1383
|
+
this.#log.debug(LOG_PREFIX.ACCESSORY, 'Activating sleep timer (30 minutes)')
|
|
1384
1384
|
await this.#deviceModel.setSleepTimer(30 * 60)
|
|
1385
1385
|
} else {
|
|
1386
1386
|
// Turn off sleep timer
|
|
1387
|
-
this.#log.
|
|
1387
|
+
this.#log.debug(LOG_PREFIX.ACCESSORY, 'Deactivating sleep timer')
|
|
1388
1388
|
await this.#deviceModel.setSleepTimer(0)
|
|
1389
1389
|
}
|
|
1390
1390
|
} catch (error) {
|
|
@@ -1411,7 +1411,7 @@ export class YotoPlayerAccessory {
|
|
|
1411
1411
|
*/
|
|
1412
1412
|
async setBluetoothState (value) {
|
|
1413
1413
|
const enabled = Boolean(value)
|
|
1414
|
-
this.#log.
|
|
1414
|
+
this.#log.debug(LOG_PREFIX.ACCESSORY, `Setting Bluetooth: ${enabled ? 'ON' : 'OFF'}`)
|
|
1415
1415
|
await this.#deviceModel.updateConfig({ bluetoothEnabled: enabled })
|
|
1416
1416
|
}
|
|
1417
1417
|
|
|
@@ -1439,7 +1439,7 @@ export class YotoPlayerAccessory {
|
|
|
1439
1439
|
}
|
|
1440
1440
|
|
|
1441
1441
|
const limit = Math.max(0, Math.min(Math.round(requested), 16))
|
|
1442
|
-
this.#log.
|
|
1442
|
+
this.#log.debug(LOG_PREFIX.ACCESSORY, `Setting day max volume limit: ${limit}/16`)
|
|
1443
1443
|
await this.#deviceModel.updateConfig({ maxVolumeLimit: limit })
|
|
1444
1444
|
}
|
|
1445
1445
|
|
|
@@ -1465,7 +1465,7 @@ export class YotoPlayerAccessory {
|
|
|
1465
1465
|
}
|
|
1466
1466
|
|
|
1467
1467
|
const limit = Math.max(0, Math.min(Math.round(requested), 16))
|
|
1468
|
-
this.#log.
|
|
1468
|
+
this.#log.debug(LOG_PREFIX.ACCESSORY, `Setting night max volume limit: ${limit}/16`)
|
|
1469
1469
|
await this.#deviceModel.updateConfig({ nightMaxVolumeLimit: limit })
|
|
1470
1470
|
}
|
|
1471
1471
|
|
|
@@ -1855,7 +1855,7 @@ export class YotoPlayerAccessory {
|
|
|
1855
1855
|
* @returns {Promise<void>}
|
|
1856
1856
|
*/
|
|
1857
1857
|
async stop () {
|
|
1858
|
-
this.#log.
|
|
1858
|
+
this.#log.debug(LOG_PREFIX.ACCESSORY, `Stopping ${this.#device.name}`)
|
|
1859
1859
|
|
|
1860
1860
|
// Remove all event listeners from device model
|
|
1861
1861
|
this.#deviceModel.removeAllListeners('statusUpdate')
|
package/lib/platform.js
CHANGED
|
@@ -81,7 +81,7 @@ export class YotoPlatform {
|
|
|
81
81
|
refreshToken,
|
|
82
82
|
accessToken,
|
|
83
83
|
onTokenRefresh: async ({ updatedAccessToken, updatedRefreshToken, updatedExpiresAt, prevAccessToken, prevRefreshToken }) => {
|
|
84
|
-
log.
|
|
84
|
+
log.debug('Access token refreshed, expires at:', new Date(updatedExpiresAt * 1000).toISOString())
|
|
85
85
|
|
|
86
86
|
// Update config file with new tokens (similar to homebridge-ring pattern)
|
|
87
87
|
await updateHomebridgeConfig((configContents) => {
|
|
@@ -142,7 +142,7 @@ export class YotoPlatform {
|
|
|
142
142
|
*/
|
|
143
143
|
configureAccessory (accessory) {
|
|
144
144
|
const { log, accessories } = this
|
|
145
|
-
log.
|
|
145
|
+
log.debug('Loading accessory from cache:', accessory.displayName)
|
|
146
146
|
|
|
147
147
|
// Add to our tracking map (cast to our typed version)
|
|
148
148
|
accessories.set(accessory.UUID, /** @type {PlatformAccessory<YotoAccessoryContext>} */ (accessory))
|
|
@@ -174,7 +174,7 @@ export class YotoPlatform {
|
|
|
174
174
|
})
|
|
175
175
|
|
|
176
176
|
this.yotoAccount.on('deviceRemoved', ({ deviceId }) => {
|
|
177
|
-
this.log.
|
|
177
|
+
this.log.debug(`Device removed: ${deviceId}`)
|
|
178
178
|
this.removeStaleAccessories()
|
|
179
179
|
})
|
|
180
180
|
|
|
@@ -204,13 +204,15 @@ export class YotoPlatform {
|
|
|
204
204
|
})
|
|
205
205
|
|
|
206
206
|
this.yotoAccount.on('mqttConnect', ({ deviceId }) => {
|
|
207
|
-
this.
|
|
207
|
+
const deviceName = this.yotoAccount?.getDevice(deviceId)?.device?.name
|
|
208
|
+
const label = deviceName ? `${deviceName} (${deviceId})` : deviceId
|
|
209
|
+
this.log.debug(`MQTT connected: ${label}`)
|
|
208
210
|
})
|
|
209
211
|
|
|
210
212
|
this.yotoAccount.on('mqttDisconnect', ({ deviceId, metadata }) => {
|
|
211
213
|
const reasonCode = metadata?.packet?.reasonCode
|
|
212
214
|
const reason = typeof reasonCode === 'number' ? ` (code ${reasonCode})` : ''
|
|
213
|
-
this.log.
|
|
215
|
+
this.log.warn(`MQTT disconnected: ${deviceId}${reason}`)
|
|
214
216
|
})
|
|
215
217
|
|
|
216
218
|
this.yotoAccount.on('mqttClose', ({ deviceId, metadata }) => {
|
|
@@ -279,7 +281,7 @@ export class YotoPlatform {
|
|
|
279
281
|
|
|
280
282
|
if (existingAccessory) {
|
|
281
283
|
// Accessory exists - update it
|
|
282
|
-
this.log.
|
|
284
|
+
this.log.debug('Restoring existing accessory from cache:', device.name)
|
|
283
285
|
|
|
284
286
|
// Update display name if it has changed
|
|
285
287
|
if (existingAccessory.displayName !== sanitizedDeviceName) {
|
|
@@ -327,7 +329,7 @@ export class YotoPlatform {
|
|
|
327
329
|
return { success: true }
|
|
328
330
|
} else {
|
|
329
331
|
// Create new accessory
|
|
330
|
-
this.log.
|
|
332
|
+
this.log.debug('Adding new accessory:', device.name)
|
|
331
333
|
|
|
332
334
|
// Create platform accessory
|
|
333
335
|
/** @type {PlatformAccessory<YotoAccessoryContext>} */
|
|
@@ -361,7 +363,7 @@ export class YotoPlatform {
|
|
|
361
363
|
await handler.setup()
|
|
362
364
|
|
|
363
365
|
// Register as a platform accessory (bridged).
|
|
364
|
-
this.log.
|
|
366
|
+
this.log.debug(`Registering new accessory: ${device.name}`)
|
|
365
367
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory])
|
|
366
368
|
|
|
367
369
|
// Add to our tracking map (cast to typed version)
|
|
@@ -385,7 +387,7 @@ export class YotoPlatform {
|
|
|
385
387
|
|
|
386
388
|
for (const [uuid, accessory] of this.accessories) {
|
|
387
389
|
if (!currentUUIDs.includes(uuid)) {
|
|
388
|
-
this.log.
|
|
390
|
+
this.log.debug('Removing existing accessory from cache:', accessory.displayName)
|
|
389
391
|
|
|
390
392
|
// Stop handler if it exists
|
|
391
393
|
const handler = this.accessoryHandlers.get(uuid)
|
|
@@ -409,7 +411,7 @@ export class YotoPlatform {
|
|
|
409
411
|
* Shutdown platform - cleanup all handlers and stop account
|
|
410
412
|
*/
|
|
411
413
|
async shutdown () {
|
|
412
|
-
this.log.
|
|
414
|
+
this.log.debug('Shutting down Yoto platform...')
|
|
413
415
|
|
|
414
416
|
// Stop all accessory handlers
|
|
415
417
|
const stopPromises = []
|
|
@@ -431,7 +433,7 @@ export class YotoPlatform {
|
|
|
431
433
|
this.yotoAccount = null
|
|
432
434
|
}
|
|
433
435
|
|
|
434
|
-
this.log.
|
|
436
|
+
this.log.debug('✓ Yoto platform shutdown complete')
|
|
435
437
|
}
|
|
436
438
|
|
|
437
439
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-yoto",
|
|
3
3
|
"description": "Control your Yoto players through Apple HomeKit with real-time MQTT updates",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.35",
|
|
5
5
|
"author": "Bret Comnes <bcomnes@gmail.com> (https://bret.io)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/bcomnes/homebridge-yoto/issues"
|