homebridge-yoto 0.0.22 → 0.0.24

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.
Files changed (2) hide show
  1. package/lib/playerAccessory.js +106 -106
  2. package/package.json +1 -1
@@ -48,7 +48,7 @@ export class YotoPlayerAccessory {
48
48
  this.statusPollInterval = null
49
49
  this.mqttConnected = false
50
50
 
51
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Initializing accessory`)
51
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Initializing accessory`)
52
52
 
53
53
  // Set up services
54
54
  this.setupAccessoryInformation()
@@ -116,9 +116,9 @@ export class YotoPlayerAccessory {
116
116
  // Fetch device config for cached access
117
117
  try {
118
118
  this.deviceConfig = await this.platform.yotoApi.getDeviceConfig(this.device.deviceId)
119
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Device config loaded`)
119
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Device config loaded`)
120
120
  } catch (error) {
121
- this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to load device config:`, error)
121
+ this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to load device config:`, error)
122
122
  // Continue without config - getters will return defaults
123
123
  }
124
124
 
@@ -138,10 +138,10 @@ export class YotoPlayerAccessory {
138
138
 
139
139
  // Handle state changes
140
140
  if (!wasOnline && isNowOnline) {
141
- this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Device came online, connecting MQTT...`)
141
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Device came online, connecting MQTT...`)
142
142
  await this.connectMqtt()
143
143
  } else if (wasOnline && !isNowOnline) {
144
- this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Device went offline`)
144
+ this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Device went offline`)
145
145
  await this.disconnectMqtt()
146
146
  }
147
147
  }
@@ -155,9 +155,9 @@ export class YotoPlayerAccessory {
155
155
  try {
156
156
  await this.mqtt.disconnect()
157
157
  this.mqttConnected = false
158
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] MQTT disconnected`)
158
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] MQTT disconnected`)
159
159
  } catch (error) {
160
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to disconnect MQTT:`, error)
160
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to disconnect MQTT:`, error)
161
161
  }
162
162
  }
163
163
  }
@@ -185,7 +185,7 @@ export class YotoPlayerAccessory {
185
185
  this.accessory.getService(this.platform.Service.SmartSpeaker) ||
186
186
  this.accessory.addService(this.platform.Service.SmartSpeaker)
187
187
 
188
- this.speakerService.setCharacteristic(this.platform.Characteristic.Name, this.device.name)
188
+ this.speakerService.setCharacteristic(this.platform.Characteristic.Name, this.accessory.displayName)
189
189
 
190
190
  // Current Media State (read-only)
191
191
  this.speakerService
@@ -219,7 +219,7 @@ export class YotoPlayerAccessory {
219
219
  this.accessory.getService(this.platform.Service.Battery) ||
220
220
  this.accessory.addService(this.platform.Service.Battery)
221
221
 
222
- this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Battery`)
222
+ this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${this.accessory.displayName} Battery`)
223
223
 
224
224
  // Battery Level
225
225
  this.batteryService
@@ -245,7 +245,7 @@ export class YotoPlayerAccessory {
245
245
  this.accessory.getService(this.platform.Service.TemperatureSensor) ||
246
246
  this.accessory.addService(this.platform.Service.TemperatureSensor)
247
247
 
248
- this.temperatureService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Temperature`)
248
+ this.temperatureService.setCharacteristic(this.platform.Characteristic.Name, `${this.accessory.displayName} Temperature`)
249
249
 
250
250
  this.temperatureService
251
251
  .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
@@ -260,7 +260,7 @@ export class YotoPlayerAccessory {
260
260
  this.accessory.getService(this.platform.Service.OccupancySensor) ||
261
261
  this.accessory.addService(this.platform.Service.OccupancySensor)
262
262
 
263
- this.connectionService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Connection`)
263
+ this.connectionService.setCharacteristic(this.platform.Characteristic.Name, `${this.accessory.displayName} Connection`)
264
264
 
265
265
  this.connectionService
266
266
  .getCharacteristic(this.platform.Characteristic.OccupancyDetected)
@@ -279,7 +279,7 @@ export class YotoPlayerAccessory {
279
279
  this.accessory.getService(this.platform.Service.ContactSensor) ||
280
280
  this.accessory.addService(this.platform.Service.ContactSensor)
281
281
 
282
- this.cardDetectionService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Card`)
282
+ this.cardDetectionService.setCharacteristic(this.platform.Characteristic.Name, `${this.accessory.displayName} Card`)
283
283
 
284
284
  this.cardDetectionService
285
285
  .getCharacteristic(this.platform.Characteristic.ContactSensorState)
@@ -294,7 +294,7 @@ export class YotoPlayerAccessory {
294
294
  this.accessory.getService(this.platform.Service.Lightbulb) ||
295
295
  this.accessory.addService(this.platform.Service.Lightbulb)
296
296
 
297
- this.displayService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Display`)
297
+ this.displayService.setCharacteristic(this.platform.Characteristic.Name, `${this.accessory.displayName} Display`)
298
298
 
299
299
  // On/Off state
300
300
  this.displayService
@@ -315,10 +315,10 @@ export class YotoPlayerAccessory {
315
315
  setupAdvancedControlSwitches () {
316
316
  // Bluetooth enabled switch
317
317
  this.bluetoothSwitch =
318
- this.accessory.getService(`${this.device.name} Bluetooth`) ||
319
- this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Bluetooth`, 'bluetooth')
318
+ this.accessory.getServiceById(this.platform.Service.Switch, 'bluetooth') ||
319
+ this.accessory.addService(this.platform.Service.Switch, `${this.accessory.displayName} Bluetooth`, 'bluetooth')
320
320
 
321
- this.bluetoothSwitch.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Bluetooth`)
321
+ this.bluetoothSwitch.setCharacteristic(this.platform.Characteristic.Name, `${this.accessory.displayName} Bluetooth`)
322
322
 
323
323
  this.bluetoothSwitch
324
324
  .getCharacteristic(this.platform.Characteristic.On)
@@ -327,10 +327,10 @@ export class YotoPlayerAccessory {
327
327
 
328
328
  // Repeat all switch
329
329
  this.repeatSwitch =
330
- this.accessory.getService(`${this.device.name} Repeat`) ||
331
- this.accessory.addService(this.platform.Service.Switch, `${this.device.name} Repeat`, 'repeat')
330
+ this.accessory.getServiceById(this.platform.Service.Switch, 'repeat') ||
331
+ this.accessory.addService(this.platform.Service.Switch, `${this.accessory.displayName} Repeat`, 'repeat')
332
332
 
333
- this.repeatSwitch.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Repeat`)
333
+ this.repeatSwitch.setCharacteristic(this.platform.Characteristic.Name, `${this.accessory.displayName} Repeat`)
334
334
 
335
335
  this.repeatSwitch
336
336
  .getCharacteristic(this.platform.Characteristic.On)
@@ -339,10 +339,10 @@ export class YotoPlayerAccessory {
339
339
 
340
340
  // Bluetooth headphones switch
341
341
  this.btHeadphonesSwitch =
342
- this.accessory.getService(`${this.device.name} BT Headphones`) ||
343
- this.accessory.addService(this.platform.Service.Switch, `${this.device.name} BT Headphones`, 'bt-headphones')
342
+ this.accessory.getServiceById(this.platform.Service.Switch, 'bt-headphones') ||
343
+ this.accessory.addService(this.platform.Service.Switch, `${this.accessory.displayName} BT Headphones`, 'bt-headphones')
344
344
 
345
- this.btHeadphonesSwitch.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} BT Headphones`)
345
+ this.btHeadphonesSwitch.setCharacteristic(this.platform.Characteristic.Name, `${this.accessory.displayName} BT Headphones`)
346
346
 
347
347
  this.btHeadphonesSwitch
348
348
  .getCharacteristic(this.platform.Characteristic.On)
@@ -358,7 +358,7 @@ export class YotoPlayerAccessory {
358
358
  this.accessory.getService(this.platform.Service.Fanv2) ||
359
359
  this.accessory.addService(this.platform.Service.Fanv2)
360
360
 
361
- this.sleepTimerService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Sleep Timer`)
361
+ this.sleepTimerService.setCharacteristic(this.platform.Characteristic.Name, `${this.accessory.displayName} Sleep Timer`)
362
362
 
363
363
  // Active state (timer on/off)
364
364
  this.sleepTimerService
@@ -380,10 +380,10 @@ export class YotoPlayerAccessory {
380
380
  setupVolumeLimitsServices () {
381
381
  // Day volume limit
382
382
  this.dayVolumeLimitService =
383
- this.accessory.getService(`${this.device.name} Day Volume Limit`) ||
384
- this.accessory.addService(this.platform.Service.Lightbulb, `${this.device.name} Day Volume Limit`, 'day-volume-limit')
383
+ this.accessory.getServiceById(this.platform.Service.Lightbulb, 'day-volume-limit') ||
384
+ this.accessory.addService(this.platform.Service.Lightbulb, `${this.accessory.displayName} Day Volume Limit`, 'day-volume-limit')
385
385
 
386
- this.dayVolumeLimitService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Day Volume Limit`)
386
+ this.dayVolumeLimitService.setCharacteristic(this.platform.Characteristic.Name, `${this.accessory.displayName} Day Volume Limit`)
387
387
 
388
388
  this.dayVolumeLimitService
389
389
  .getCharacteristic(this.platform.Characteristic.On)
@@ -398,10 +398,10 @@ export class YotoPlayerAccessory {
398
398
 
399
399
  // Night volume limit
400
400
  this.nightVolumeLimitService =
401
- this.accessory.getService(`${this.device.name} Night Volume Limit`) ||
402
- this.accessory.addService(this.platform.Service.Lightbulb, `${this.device.name} Night Volume Limit`, 'night-volume-limit')
401
+ this.accessory.getServiceById(this.platform.Service.Lightbulb, 'night-volume-limit') ||
402
+ this.accessory.addService(this.platform.Service.Lightbulb, `${this.accessory.displayName} Night Volume Limit`, 'night-volume-limit')
403
403
 
404
- this.nightVolumeLimitService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Night Volume Limit`)
404
+ this.nightVolumeLimitService.setCharacteristic(this.platform.Characteristic.Name, `${this.accessory.displayName} Night Volume Limit`)
405
405
 
406
406
  this.nightVolumeLimitService
407
407
  .getCharacteristic(this.platform.Characteristic.On)
@@ -420,10 +420,10 @@ export class YotoPlayerAccessory {
420
420
  */
421
421
  setupAmbientLightService () {
422
422
  this.ambientLightService =
423
- this.accessory.getService(`${this.device.name} Ambient Light`) ||
424
- this.accessory.addService(this.platform.Service.Lightbulb, `${this.device.name} Ambient Light`, 'ambient-light')
423
+ this.accessory.getServiceById(this.platform.Service.Lightbulb, 'ambient-light') ||
424
+ this.accessory.addService(this.platform.Service.Lightbulb, `${this.accessory.displayName} Ambient Light`, 'ambient-light')
425
425
 
426
- this.ambientLightService.setCharacteristic(this.platform.Characteristic.Name, `${this.device.name} Ambient Light`)
426
+ this.ambientLightService.setCharacteristic(this.platform.Characteristic.Name, `${this.accessory.displayName} Ambient Light`)
427
427
 
428
428
  // On/Off state
429
429
  this.ambientLightService
@@ -454,7 +454,7 @@ export class YotoPlayerAccessory {
454
454
  * Cleanup and destroy the accessory
455
455
  */
456
456
  async destroy () {
457
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Destroying accessory`)
457
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Destroying accessory`)
458
458
 
459
459
  // Disconnect MQTT
460
460
  await this.disconnectMqtt()
@@ -467,17 +467,17 @@ export class YotoPlayerAccessory {
467
467
  try {
468
468
  // Check if device is online first
469
469
  if (!this.device.online) {
470
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Device is offline, skipping MQTT connection`)
470
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Device is offline, skipping MQTT connection`)
471
471
  return
472
472
  }
473
473
 
474
474
  // Ensure we have an access token
475
475
  if (!this.platform.config.accessToken) {
476
- this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.device.name}] No access token available for MQTT connection`)
476
+ this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] No access token available for MQTT connection`)
477
477
  return
478
478
  }
479
479
 
480
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Connecting to MQTT (device online: ${this.device.online})`)
480
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Connecting to MQTT (device online: ${this.device.online})`)
481
481
 
482
482
  // Connect MQTT with device ID and access token
483
483
  await this.mqtt.connect(
@@ -493,26 +493,26 @@ export class YotoPlayerAccessory {
493
493
  })
494
494
 
495
495
  this.mqttConnected = true
496
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] MQTT connected and subscribed`)
496
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] MQTT connected and subscribed`)
497
497
 
498
498
  // Set up MQTT event listeners
499
499
  this.mqtt.on('disconnected', () => {
500
500
  this.mqttConnected = false
501
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] MQTT disconnected`)
501
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] MQTT disconnected`)
502
502
  })
503
503
 
504
504
  this.mqtt.on('offline', () => {
505
505
  this.mqttConnected = false
506
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] MQTT offline`)
506
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] MQTT offline`)
507
507
  })
508
508
 
509
509
  this.mqtt.on('connected', () => {
510
510
  this.mqttConnected = true
511
- this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] MQTT reconnected`)
511
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] MQTT reconnected`)
512
512
  })
513
513
  } catch (error) {
514
514
  this.mqttConnected = false
515
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to connect MQTT:`, error)
515
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to connect MQTT:`, error)
516
516
  }
517
517
  }
518
518
 
@@ -521,14 +521,14 @@ export class YotoPlayerAccessory {
521
521
  * @param {YotoDeviceStatus | {status: YotoDeviceStatus}} statusMessage - Status data or wrapped status
522
522
  */
523
523
  handleStatusUpdate (statusMessage) {
524
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Raw MQTT status message:`, JSON.stringify(statusMessage, null, 2))
524
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Raw MQTT status message:`, JSON.stringify(statusMessage, null, 2))
525
525
 
526
526
  // Unwrap status if it's nested under a 'status' property
527
527
  const status = /** @type {YotoDeviceStatus} */ ('status' in statusMessage ? statusMessage.status : statusMessage)
528
528
 
529
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Unwrapped status - batteryLevel:`, status.batteryLevel)
530
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Unwrapped status - userVolume:`, status.userVolume)
531
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Unwrapped status - volume:`, status.volume)
529
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Unwrapped status - batteryLevel:`, status.batteryLevel)
530
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Unwrapped status - userVolume:`, status.userVolume)
531
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Unwrapped status - volume:`, status.volume)
532
532
 
533
533
  this.currentStatus = status
534
534
  this.lastUpdateTime = Date.now()
@@ -543,12 +543,12 @@ export class YotoPlayerAccessory {
543
543
  * @param {YotoPlaybackEvents | {events: YotoPlaybackEvents}} eventsMessage - Playback events or wrapped events
544
544
  */
545
545
  handleEventsUpdate (eventsMessage) {
546
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Raw MQTT events message:`, JSON.stringify(eventsMessage, null, 2))
546
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Raw MQTT events message:`, JSON.stringify(eventsMessage, null, 2))
547
547
 
548
548
  // Unwrap events if it's nested under an 'events' property
549
549
  const events = /** @type {YotoPlaybackEvents} */ ('events' in eventsMessage ? eventsMessage.events : eventsMessage)
550
550
 
551
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Unwrapped events - cardId:`, events.cardId)
551
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Unwrapped events - cardId:`, events.cardId)
552
552
  this.currentEvents = events
553
553
  this.lastUpdateTime = Date.now()
554
554
  this.accessory.context.lastEvents = events
@@ -567,7 +567,7 @@ export class YotoPlayerAccessory {
567
567
  * @param {import('./types.js').MqttCommandResponse} response - Command response
568
568
  */
569
569
  handleCommandResponse (response) {
570
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Command response:`, response)
570
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Command response:`, response)
571
571
  }
572
572
 
573
573
  /**
@@ -789,7 +789,7 @@ export class YotoPlayerAccessory {
789
789
  * @param {CharacteristicValue} value - Target state
790
790
  */
791
791
  async setTargetMediaState (value) {
792
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set target media state:`, value)
792
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set target media state:`, value)
793
793
 
794
794
  try {
795
795
  if (value === this.platform.Characteristic.TargetMediaState.PLAY) {
@@ -800,7 +800,7 @@ export class YotoPlayerAccessory {
800
800
  await this.mqtt.stopCard(this.device.deviceId)
801
801
  }
802
802
  } catch (error) {
803
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to set media state:`, error)
803
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to set media state:`, error)
804
804
  throw new this.platform.api.hap.HapStatusError(
805
805
  this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
806
806
  )
@@ -812,16 +812,16 @@ export class YotoPlayerAccessory {
812
812
  * @returns {Promise<CharacteristicValue>}
813
813
  */
814
814
  async getVolume () {
815
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getVolume - currentEvents:`, this.currentEvents)
816
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getVolume - events.volume:`, this.currentEvents?.volume)
815
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] getVolume - currentEvents:`, this.currentEvents)
816
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] getVolume - events.volume:`, this.currentEvents?.volume)
817
817
 
818
818
  // Volume comes from events, not status
819
819
  if (!this.currentEvents || this.currentEvents.volume === undefined) {
820
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getVolume - no volume in events, returning default: 50`)
820
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] getVolume - no volume in events, returning default: 50`)
821
821
  return 50
822
822
  }
823
823
  const volume = Number(this.currentEvents.volume) || 50
824
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getVolume - returning volume:`, volume)
824
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] getVolume - returning volume:`, volume)
825
825
  return volume
826
826
  }
827
827
 
@@ -830,12 +830,12 @@ export class YotoPlayerAccessory {
830
830
  * @param {CharacteristicValue} value - Volume level (0-100)
831
831
  */
832
832
  async setVolume (value) {
833
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set volume:`, value)
833
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set volume:`, value)
834
834
 
835
835
  try {
836
836
  await this.mqtt.setVolume(this.device.deviceId, Number(value))
837
837
  } catch (error) {
838
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to set volume:`, error)
838
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to set volume:`, error)
839
839
  throw new this.platform.api.hap.HapStatusError(
840
840
  this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
841
841
  )
@@ -859,7 +859,7 @@ export class YotoPlayerAccessory {
859
859
  * @param {CharacteristicValue} value - Mute state
860
860
  */
861
861
  async setMute (value) {
862
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set mute:`, value)
862
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set mute:`, value)
863
863
 
864
864
  try {
865
865
  if (value) {
@@ -872,7 +872,7 @@ export class YotoPlayerAccessory {
872
872
  await this.mqtt.setVolume(this.device.deviceId, targetVolume)
873
873
  }
874
874
  } catch (error) {
875
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to set mute:`, error)
875
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to set mute:`, error)
876
876
  throw new this.platform.api.hap.HapStatusError(
877
877
  this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
878
878
  )
@@ -884,15 +884,15 @@ export class YotoPlayerAccessory {
884
884
  * @returns {Promise<CharacteristicValue>}
885
885
  */
886
886
  async getBatteryLevel () {
887
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getBatteryLevel - currentStatus:`, this.currentStatus)
888
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getBatteryLevel - batteryLevel:`, this.currentStatus?.batteryLevel)
887
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] getBatteryLevel - currentStatus:`, this.currentStatus)
888
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] getBatteryLevel - batteryLevel:`, this.currentStatus?.batteryLevel)
889
889
 
890
890
  if (!this.currentStatus || this.currentStatus.batteryLevel === undefined) {
891
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getBatteryLevel - returning default: 100`)
891
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] getBatteryLevel - returning default: 100`)
892
892
  return 100
893
893
  }
894
894
  const battery = Number(this.currentStatus.batteryLevel) || 100
895
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getBatteryLevel - returning:`, battery)
895
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] getBatteryLevel - returning:`, battery)
896
896
  return battery
897
897
  }
898
898
 
@@ -998,7 +998,7 @@ export class YotoPlayerAccessory {
998
998
  * @param {CharacteristicValue} value - On/off state
999
999
  */
1000
1000
  async setDisplayOn (value) {
1001
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set display on:`, value)
1001
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set display on:`, value)
1002
1002
 
1003
1003
  try {
1004
1004
  // Refresh config if not cached
@@ -1019,7 +1019,7 @@ export class YotoPlayerAccessory {
1019
1019
 
1020
1020
  await this.platform.yotoApi.updateDeviceConfig(this.device.deviceId, this.deviceConfig)
1021
1021
  } catch (error) {
1022
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to set display on:`, error)
1022
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to set display on:`, error)
1023
1023
  throw new this.platform.api.hap.HapStatusError(
1024
1024
  this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
1025
1025
  )
@@ -1048,7 +1048,7 @@ export class YotoPlayerAccessory {
1048
1048
  * @param {CharacteristicValue} value - Brightness level (0-100)
1049
1049
  */
1050
1050
  async setDisplayBrightness (value) {
1051
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set display brightness:`, value)
1051
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set display brightness:`, value)
1052
1052
 
1053
1053
  try {
1054
1054
  // Refresh config if not cached
@@ -1065,7 +1065,7 @@ export class YotoPlayerAccessory {
1065
1065
 
1066
1066
  await this.platform.yotoApi.updateDeviceConfig(this.device.deviceId, this.deviceConfig)
1067
1067
  } catch (error) {
1068
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to set display brightness:`, error)
1068
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to set display brightness:`, error)
1069
1069
  throw new this.platform.api.hap.HapStatusError(
1070
1070
  this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
1071
1071
  )
@@ -1088,7 +1088,7 @@ export class YotoPlayerAccessory {
1088
1088
  * @param {CharacteristicValue} value - Enabled state
1089
1089
  */
1090
1090
  async setBluetoothEnabled (value) {
1091
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set Bluetooth:`, value)
1091
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set Bluetooth:`, value)
1092
1092
 
1093
1093
  try {
1094
1094
  // Refresh config if not cached
@@ -1099,7 +1099,7 @@ export class YotoPlayerAccessory {
1099
1099
  this.deviceConfig.config.bluetoothEnabled = value ? 'true' : 'false'
1100
1100
  await this.platform.yotoApi.updateDeviceConfig(this.device.deviceId, this.deviceConfig)
1101
1101
  } catch (error) {
1102
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to set Bluetooth:`, error)
1102
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to set Bluetooth:`, error)
1103
1103
  throw new this.platform.api.hap.HapStatusError(
1104
1104
  this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
1105
1105
  )
@@ -1122,7 +1122,7 @@ export class YotoPlayerAccessory {
1122
1122
  * @param {CharacteristicValue} value - Repeat state
1123
1123
  */
1124
1124
  async setRepeatAll (value) {
1125
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set repeat all:`, value)
1125
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set repeat all:`, value)
1126
1126
 
1127
1127
  try {
1128
1128
  // Refresh config if not cached
@@ -1133,7 +1133,7 @@ export class YotoPlayerAccessory {
1133
1133
  this.deviceConfig.config.repeatAll = Boolean(value)
1134
1134
  await this.platform.yotoApi.updateDeviceConfig(this.device.deviceId, this.deviceConfig)
1135
1135
  } catch (error) {
1136
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to set repeat all:`, error)
1136
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to set repeat all:`, error)
1137
1137
  throw new this.platform.api.hap.HapStatusError(
1138
1138
  this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
1139
1139
  )
@@ -1156,7 +1156,7 @@ export class YotoPlayerAccessory {
1156
1156
  * @param {CharacteristicValue} value - Enabled state
1157
1157
  */
1158
1158
  async setBtHeadphonesEnabled (value) {
1159
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set BT headphones:`, value)
1159
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set BT headphones:`, value)
1160
1160
 
1161
1161
  try {
1162
1162
  // Refresh config if not cached
@@ -1167,7 +1167,7 @@ export class YotoPlayerAccessory {
1167
1167
  this.deviceConfig.config.btHeadphonesEnabled = Boolean(value)
1168
1168
  await this.platform.yotoApi.updateDeviceConfig(this.device.deviceId, this.deviceConfig)
1169
1169
  } catch (error) {
1170
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to set BT headphones:`, error)
1170
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to set BT headphones:`, error)
1171
1171
  throw new this.platform.api.hap.HapStatusError(
1172
1172
  this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
1173
1173
  )
@@ -1192,7 +1192,7 @@ export class YotoPlayerAccessory {
1192
1192
  * @param {CharacteristicValue} value - Active state
1193
1193
  */
1194
1194
  async setSleepTimerActive (value) {
1195
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set sleep timer active:`, value)
1195
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set sleep timer active:`, value)
1196
1196
 
1197
1197
  try {
1198
1198
  if (value === this.platform.Characteristic.Active.INACTIVE) {
@@ -1203,7 +1203,7 @@ export class YotoPlayerAccessory {
1203
1203
  await this.mqtt.setSleepTimer(this.device.deviceId, 30 * 60)
1204
1204
  }
1205
1205
  } catch (error) {
1206
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to set sleep timer active:`, error)
1206
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to set sleep timer active:`, error)
1207
1207
  throw new this.platform.api.hap.HapStatusError(
1208
1208
  this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
1209
1209
  )
@@ -1230,7 +1230,7 @@ export class YotoPlayerAccessory {
1230
1230
  * @param {CharacteristicValue} value - Rotation speed (0-100)
1231
1231
  */
1232
1232
  async setSleepTimerMinutes (value) {
1233
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set sleep timer minutes:`, value)
1233
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set sleep timer minutes:`, value)
1234
1234
 
1235
1235
  try {
1236
1236
  // Map rotation speed (0-100) to minutes (0-120)
@@ -1245,7 +1245,7 @@ export class YotoPlayerAccessory {
1245
1245
  await this.mqtt.setSleepTimer(this.device.deviceId, seconds)
1246
1246
  }
1247
1247
  } catch (error) {
1248
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to set sleep timer:`, error)
1248
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to set sleep timer:`, error)
1249
1249
  throw new this.platform.api.hap.HapStatusError(
1250
1250
  this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
1251
1251
  )
@@ -1267,7 +1267,7 @@ export class YotoPlayerAccessory {
1267
1267
  */
1268
1268
  async setDayVolumeLimitEnabled (_value) {
1269
1269
  // No-op - always enabled, use brightness to control
1270
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Day volume limit always enabled`)
1270
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Day volume limit always enabled`)
1271
1271
  }
1272
1272
 
1273
1273
  /**
@@ -1287,7 +1287,7 @@ export class YotoPlayerAccessory {
1287
1287
  // Map 0-16 to 0-100
1288
1288
  return Math.round((limit / 16) * 100)
1289
1289
  } catch (error) {
1290
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to parse day volume limit:`, error)
1290
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to parse day volume limit:`, error)
1291
1291
  return 100
1292
1292
  }
1293
1293
  }
@@ -1297,7 +1297,7 @@ export class YotoPlayerAccessory {
1297
1297
  * @param {CharacteristicValue} value - Brightness value (0-100)
1298
1298
  */
1299
1299
  async setDayVolumeLimit (value) {
1300
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set day volume limit:`, value)
1300
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set day volume limit:`, value)
1301
1301
 
1302
1302
  try {
1303
1303
  // Refresh config if not cached
@@ -1310,7 +1310,7 @@ export class YotoPlayerAccessory {
1310
1310
  this.deviceConfig.config.maxVolumeLimit = String(limit)
1311
1311
  await this.platform.yotoApi.updateDeviceConfig(this.device.deviceId, this.deviceConfig)
1312
1312
  } catch (error) {
1313
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to set day volume limit:`, error)
1313
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to set day volume limit:`, error)
1314
1314
  throw new this.platform.api.hap.HapStatusError(
1315
1315
  this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
1316
1316
  )
@@ -1332,7 +1332,7 @@ export class YotoPlayerAccessory {
1332
1332
  */
1333
1333
  async setNightVolumeLimitEnabled (_value) {
1334
1334
  // No-op - always enabled, use brightness to control
1335
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Night volume limit always enabled`)
1335
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Night volume limit always enabled`)
1336
1336
  }
1337
1337
 
1338
1338
  /**
@@ -1352,7 +1352,7 @@ export class YotoPlayerAccessory {
1352
1352
  // Map 0-16 to 0-100
1353
1353
  return Math.round((limit / 16) * 100)
1354
1354
  } catch (error) {
1355
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to parse night volume limit:`, error)
1355
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to parse night volume limit:`, error)
1356
1356
  return 100
1357
1357
  }
1358
1358
  }
@@ -1362,7 +1362,7 @@ export class YotoPlayerAccessory {
1362
1362
  * @param {CharacteristicValue} value - Brightness value (0-100)
1363
1363
  */
1364
1364
  async setNightVolumeLimit (value) {
1365
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set night volume limit:`, value)
1365
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set night volume limit:`, value)
1366
1366
 
1367
1367
  try {
1368
1368
  // Refresh config if not cached
@@ -1375,7 +1375,7 @@ export class YotoPlayerAccessory {
1375
1375
  this.deviceConfig.config.nightMaxVolumeLimit = String(limit)
1376
1376
  await this.platform.yotoApi.updateDeviceConfig(this.device.deviceId, this.deviceConfig)
1377
1377
  } catch (error) {
1378
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to set night volume limit:`, error)
1378
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to set night volume limit:`, error)
1379
1379
  throw new this.platform.api.hap.HapStatusError(
1380
1380
  this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
1381
1381
  )
@@ -1396,7 +1396,7 @@ export class YotoPlayerAccessory {
1396
1396
  // Consider light "on" if not pure black
1397
1397
  return color !== '000000'
1398
1398
  } catch (error) {
1399
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to parse ambient light state:`, error)
1399
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to parse ambient light state:`, error)
1400
1400
  return false
1401
1401
  }
1402
1402
  }
@@ -1406,7 +1406,7 @@ export class YotoPlayerAccessory {
1406
1406
  * @param {CharacteristicValue} value - On/off state
1407
1407
  */
1408
1408
  async setAmbientLightOn (value) {
1409
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set ambient light on:`, value)
1409
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set ambient light on:`, value)
1410
1410
 
1411
1411
  try {
1412
1412
  // Refresh config if not cached
@@ -1422,7 +1422,7 @@ export class YotoPlayerAccessory {
1422
1422
  await this.mqtt.setAmbientLight(this.device.deviceId, 0, 0, 0)
1423
1423
  }
1424
1424
  } catch (error) {
1425
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to set ambient light on:`, error)
1425
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to set ambient light on:`, error)
1426
1426
  throw new this.platform.api.hap.HapStatusError(
1427
1427
  this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
1428
1428
  )
@@ -1446,7 +1446,7 @@ export class YotoPlayerAccessory {
1446
1446
  }
1447
1447
  return h
1448
1448
  } catch (error) {
1449
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to parse ambient light hue:`, error)
1449
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to parse ambient light hue:`, error)
1450
1450
  return 0
1451
1451
  }
1452
1452
  }
@@ -1456,7 +1456,7 @@ export class YotoPlayerAccessory {
1456
1456
  * @param {CharacteristicValue} value - Hue value (0-360)
1457
1457
  */
1458
1458
  async setAmbientLightHue (value) {
1459
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set ambient light hue:`, value)
1459
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set ambient light hue:`, value)
1460
1460
  // Store for combined update with saturation and brightness
1461
1461
  this.pendingAmbientHue = Number(value)
1462
1462
  await this.updateAmbientLightColor()
@@ -1479,7 +1479,7 @@ export class YotoPlayerAccessory {
1479
1479
  }
1480
1480
  return s
1481
1481
  } catch (error) {
1482
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to parse ambient light saturation:`, error)
1482
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to parse ambient light saturation:`, error)
1483
1483
  return 0
1484
1484
  }
1485
1485
  }
@@ -1489,7 +1489,7 @@ export class YotoPlayerAccessory {
1489
1489
  * @param {CharacteristicValue} value - Saturation value (0-100)
1490
1490
  */
1491
1491
  async setAmbientLightSaturation (value) {
1492
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set ambient light saturation:`, value)
1492
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set ambient light saturation:`, value)
1493
1493
  // Store for combined update with hue and brightness
1494
1494
  this.pendingAmbientSaturation = Number(value)
1495
1495
  await this.updateAmbientLightColor()
@@ -1513,7 +1513,7 @@ export class YotoPlayerAccessory {
1513
1513
  }
1514
1514
  return brightness
1515
1515
  } catch (error) {
1516
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to parse ambient brightness:`, error)
1516
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to parse ambient brightness:`, error)
1517
1517
  return 0
1518
1518
  }
1519
1519
  }
@@ -1523,7 +1523,7 @@ export class YotoPlayerAccessory {
1523
1523
  * @param {CharacteristicValue} value - Brightness value (0-100)
1524
1524
  */
1525
1525
  async setAmbientLightBrightness (value) {
1526
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Set ambient light brightness:`, value)
1526
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Set ambient light brightness:`, value)
1527
1527
  // Store for combined update with hue and saturation
1528
1528
  this.pendingAmbientBrightness = Number(value)
1529
1529
  await this.updateAmbientLightColor()
@@ -1558,7 +1558,7 @@ export class YotoPlayerAccessory {
1558
1558
  this.pendingAmbientSaturation = undefined
1559
1559
  this.pendingAmbientBrightness = undefined
1560
1560
  } catch (error) {
1561
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to update ambient light:`, error)
1561
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to update ambient light:`, error)
1562
1562
  }
1563
1563
  }
1564
1564
 
@@ -1655,33 +1655,33 @@ export class YotoPlayerAccessory {
1655
1655
 
1656
1656
  // Handle no card inserted
1657
1657
  if (!cardId || cardId === 'none' || cardId === 'null') {
1658
- this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] No card inserted`)
1658
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] No card inserted`)
1659
1659
  this.activeContentInfo = null
1660
1660
  this.accessory.context.activeContentInfo = null
1661
1661
  return
1662
1662
  }
1663
1663
 
1664
- this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Active card changed: ${cardId}`)
1664
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Active card changed: ${cardId}`)
1665
1665
 
1666
1666
  // Use event data if available for immediate content info
1667
1667
  if (events?.trackTitle || events?.chapterTitle) {
1668
1668
  const title = events.trackTitle || events.chapterTitle || cardId
1669
- this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Now playing: "${title}"`)
1669
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Now playing: "${title}"`)
1670
1670
 
1671
1671
  if (events.chapterKey && events.chapterKey !== events.chapterTitle) {
1672
- this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Chapter: ${events.chapterKey}`)
1672
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Chapter: ${events.chapterKey}`)
1673
1673
  }
1674
1674
 
1675
1675
  // Optionally update accessory display name with current content
1676
1676
  if (this.platform.config.updateAccessoryName) {
1677
- this.accessory.displayName = `${this.device.name} - ${title}`
1678
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Updated display name`)
1677
+ this.accessory.displayName = `${this.accessory.displayName} - ${title}`
1678
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Updated display name`)
1679
1679
  }
1680
1680
  }
1681
1681
 
1682
1682
  // Check if we own this card to fetch additional details
1683
1683
  if (!this.platform.isCardOwned(cardId)) {
1684
- this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Card ${cardId} (not in library - using event data)`)
1684
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Card ${cardId} (not in library - using event data)`)
1685
1685
  this.activeContentInfo = null
1686
1686
  this.accessory.context.activeContentInfo = null
1687
1687
  return
@@ -1694,11 +1694,11 @@ export class YotoPlayerAccessory {
1694
1694
 
1695
1695
  // Log additional metadata from API
1696
1696
  if (content.card?.metadata?.author) {
1697
- this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Author: ${content.card.metadata.author}`)
1697
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Author: ${content.card.metadata.author}`)
1698
1698
  }
1699
1699
 
1700
1700
  if (content.card?.metadata?.category) {
1701
- this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Category: ${content.card.metadata.category}`)
1701
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Category: ${content.card.metadata.category}`)
1702
1702
  }
1703
1703
 
1704
1704
  // Store in context for persistence
@@ -1706,17 +1706,17 @@ export class YotoPlayerAccessory {
1706
1706
  } catch (error) {
1707
1707
  // Handle 403 Forbidden (store-bought cards user doesn't own)
1708
1708
  if (error instanceof Error && error.message.includes('403')) {
1709
- this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Card ${cardId} API access denied (using event data)`)
1709
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Card ${cardId} API access denied (using event data)`)
1710
1710
  this.activeContentInfo = null
1711
1711
  this.accessory.context.activeContentInfo = null
1712
1712
  } else if (error instanceof Error && error.message.includes('404')) {
1713
1713
  // Card not found - might be deleted or invalid
1714
- this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Card ${cardId} not found in API`)
1714
+ this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Card ${cardId} not found in API`)
1715
1715
  this.activeContentInfo = null
1716
1716
  this.accessory.context.activeContentInfo = null
1717
1717
  } else {
1718
1718
  // Other errors
1719
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to fetch content details:`, error)
1719
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.accessory.displayName}] Failed to fetch content details:`, error)
1720
1720
  }
1721
1721
  }
1722
1722
  }
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.22",
4
+ "version": "0.0.24",
5
5
  "author": "Bret Comnes <bcomnes@gmail.com> (https://bret.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/bcomnes/homebridge-yoto/issues"