homebridge-yoto 0.0.33 → 0.0.34
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 +11 -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,13 @@ export class YotoPlatform {
|
|
|
204
204
|
})
|
|
205
205
|
|
|
206
206
|
this.yotoAccount.on('mqttConnect', ({ deviceId }) => {
|
|
207
|
-
this.log.info(`
|
|
207
|
+
this.log.info(`Device connected: ${deviceId}`)
|
|
208
208
|
})
|
|
209
209
|
|
|
210
210
|
this.yotoAccount.on('mqttDisconnect', ({ deviceId, metadata }) => {
|
|
211
211
|
const reasonCode = metadata?.packet?.reasonCode
|
|
212
212
|
const reason = typeof reasonCode === 'number' ? ` (code ${reasonCode})` : ''
|
|
213
|
-
this.log.
|
|
213
|
+
this.log.warn(`MQTT disconnected: ${deviceId}${reason}`)
|
|
214
214
|
})
|
|
215
215
|
|
|
216
216
|
this.yotoAccount.on('mqttClose', ({ deviceId, metadata }) => {
|
|
@@ -279,7 +279,7 @@ export class YotoPlatform {
|
|
|
279
279
|
|
|
280
280
|
if (existingAccessory) {
|
|
281
281
|
// Accessory exists - update it
|
|
282
|
-
this.log.
|
|
282
|
+
this.log.debug('Restoring existing accessory from cache:', device.name)
|
|
283
283
|
|
|
284
284
|
// Update display name if it has changed
|
|
285
285
|
if (existingAccessory.displayName !== sanitizedDeviceName) {
|
|
@@ -327,7 +327,7 @@ export class YotoPlatform {
|
|
|
327
327
|
return { success: true }
|
|
328
328
|
} else {
|
|
329
329
|
// Create new accessory
|
|
330
|
-
this.log.
|
|
330
|
+
this.log.debug('Adding new accessory:', device.name)
|
|
331
331
|
|
|
332
332
|
// Create platform accessory
|
|
333
333
|
/** @type {PlatformAccessory<YotoAccessoryContext>} */
|
|
@@ -361,7 +361,7 @@ export class YotoPlatform {
|
|
|
361
361
|
await handler.setup()
|
|
362
362
|
|
|
363
363
|
// Register as a platform accessory (bridged).
|
|
364
|
-
this.log.
|
|
364
|
+
this.log.debug(`Registering new accessory: ${device.name}`)
|
|
365
365
|
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory])
|
|
366
366
|
|
|
367
367
|
// Add to our tracking map (cast to typed version)
|
|
@@ -385,7 +385,7 @@ export class YotoPlatform {
|
|
|
385
385
|
|
|
386
386
|
for (const [uuid, accessory] of this.accessories) {
|
|
387
387
|
if (!currentUUIDs.includes(uuid)) {
|
|
388
|
-
this.log.
|
|
388
|
+
this.log.debug('Removing existing accessory from cache:', accessory.displayName)
|
|
389
389
|
|
|
390
390
|
// Stop handler if it exists
|
|
391
391
|
const handler = this.accessoryHandlers.get(uuid)
|
|
@@ -409,7 +409,7 @@ export class YotoPlatform {
|
|
|
409
409
|
* Shutdown platform - cleanup all handlers and stop account
|
|
410
410
|
*/
|
|
411
411
|
async shutdown () {
|
|
412
|
-
this.log.
|
|
412
|
+
this.log.debug('Shutting down Yoto platform...')
|
|
413
413
|
|
|
414
414
|
// Stop all accessory handlers
|
|
415
415
|
const stopPromises = []
|
|
@@ -431,7 +431,7 @@ export class YotoPlatform {
|
|
|
431
431
|
this.yotoAccount = null
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
-
this.log.
|
|
434
|
+
this.log.debug('✓ Yoto platform shutdown complete')
|
|
435
435
|
}
|
|
436
436
|
|
|
437
437
|
/**
|
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.34",
|
|
5
5
|
"author": "Bret Comnes <bcomnes@gmail.com> (https://bret.io)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/bcomnes/homebridge-yoto/issues"
|