homebridge-yoto 0.0.12 → 0.0.13

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.
@@ -785,10 +785,10 @@ export class YotoPlayerAccessory {
785
785
  * @returns {Promise<CharacteristicValue>}
786
786
  */
787
787
  async getVolume () {
788
- if (!this.currentStatus) {
788
+ if (!this.currentStatus || this.currentStatus.userVolume === undefined) {
789
789
  return 50
790
790
  }
791
- return this.currentStatus.userVolume
791
+ return Number(this.currentStatus.userVolume) || 50
792
792
  }
793
793
 
794
794
  /**
@@ -813,10 +813,10 @@ export class YotoPlayerAccessory {
813
813
  * @returns {Promise<CharacteristicValue>}
814
814
  */
815
815
  async getMute () {
816
- if (!this.currentStatus) {
816
+ if (!this.currentStatus || this.currentStatus.userVolume === undefined) {
817
817
  return false
818
818
  }
819
- return this.currentStatus.userVolume === 0
819
+ return Number(this.currentStatus.userVolume) === 0
820
820
  }
821
821
 
822
822
  /**
@@ -849,10 +849,10 @@ export class YotoPlayerAccessory {
849
849
  * @returns {Promise<CharacteristicValue>}
850
850
  */
851
851
  async getBatteryLevel () {
852
- if (!this.currentStatus) {
852
+ if (!this.currentStatus || this.currentStatus.batteryLevel === undefined) {
853
853
  return 100
854
854
  }
855
- return this.currentStatus.batteryLevel
855
+ return Number(this.currentStatus.batteryLevel) || 100
856
856
  }
857
857
 
858
858
  /**
@@ -1527,6 +1527,15 @@ export class YotoPlayerAccessory {
1527
1527
  }
1528
1528
 
1529
1529
  this.activeContentCardId = cardId
1530
+
1531
+ // Handle no card inserted
1532
+ if (!cardId || cardId === 'none' || cardId === 'null') {
1533
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] No card inserted`)
1534
+ this.activeContentInfo = null
1535
+ this.accessory.context.activeContentInfo = null
1536
+ return
1537
+ }
1538
+
1530
1539
  this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Active card changed: ${cardId}`)
1531
1540
 
1532
1541
  try {
@@ -1555,7 +1564,20 @@ export class YotoPlayerAccessory {
1555
1564
  // Store in context for persistence
1556
1565
  this.accessory.context.activeContentInfo = this.activeContentInfo
1557
1566
  } catch (error) {
1558
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to fetch content details:`, error)
1567
+ // Handle 403 Forbidden (store-bought cards user doesn't own)
1568
+ if (error instanceof Error && error.message.includes('403')) {
1569
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Playing card ${cardId} (store content - details not available)`)
1570
+ this.activeContentInfo = null
1571
+ this.accessory.context.activeContentInfo = null
1572
+ } else if (error instanceof Error && error.message.includes('404')) {
1573
+ // Card not found - might be deleted or invalid
1574
+ this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Card ${cardId} not found`)
1575
+ this.activeContentInfo = null
1576
+ this.accessory.context.activeContentInfo = null
1577
+ } else {
1578
+ // Other errors
1579
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to fetch content details:`, error)
1580
+ }
1559
1581
  }
1560
1582
  }
1561
1583
  }
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.12",
4
+ "version": "0.0.13",
5
5
  "author": "Bret Comnes <bcomnes@gmail.com> (https://bret.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/bcomnes/homebridge-yoto/issues"