homebridge-yoto 0.0.17 → 0.0.18
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/playerAccessory.js +28 -20
- package/package.json +1 -1
package/lib/playerAccessory.js
CHANGED
|
@@ -546,9 +546,9 @@ export class YotoPlayerAccessory {
|
|
|
546
546
|
this.lastUpdateTime = Date.now()
|
|
547
547
|
this.accessory.context.lastEvents = events
|
|
548
548
|
|
|
549
|
-
// Track active content changes
|
|
549
|
+
// Track active content changes with event data
|
|
550
550
|
if (this.platform.config.exposeActiveContent !== false && events.cardId) {
|
|
551
|
-
this.handleActiveContentChange(events.cardId)
|
|
551
|
+
this.handleActiveContentChange(events.cardId, events)
|
|
552
552
|
}
|
|
553
553
|
|
|
554
554
|
// Update playback-related characteristics
|
|
@@ -1567,8 +1567,9 @@ export class YotoPlayerAccessory {
|
|
|
1567
1567
|
/**
|
|
1568
1568
|
* Handle active content change
|
|
1569
1569
|
* @param {string} cardId - Card ID
|
|
1570
|
+
* @param {YotoPlaybackEvents} [events] - Optional event data with track/chapter info
|
|
1570
1571
|
*/
|
|
1571
|
-
async handleActiveContentChange (cardId) {
|
|
1572
|
+
async handleActiveContentChange (cardId, events) {
|
|
1572
1573
|
// Skip if same card
|
|
1573
1574
|
if (this.activeContentCardId === cardId) {
|
|
1574
1575
|
return
|
|
@@ -1584,25 +1585,38 @@ export class YotoPlayerAccessory {
|
|
|
1584
1585
|
return
|
|
1585
1586
|
}
|
|
1586
1587
|
|
|
1587
|
-
|
|
1588
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Active card changed: ${cardId}`)
|
|
1589
|
+
|
|
1590
|
+
// Use event data if available for immediate content info
|
|
1591
|
+
if (events?.trackTitle || events?.chapterTitle) {
|
|
1592
|
+
const title = events.trackTitle || events.chapterTitle || cardId
|
|
1593
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Now playing: "${title}"`)
|
|
1594
|
+
|
|
1595
|
+
if (events.chapterKey && events.chapterKey !== events.chapterTitle) {
|
|
1596
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Chapter: ${events.chapterKey}`)
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
// Optionally update accessory display name with current content
|
|
1600
|
+
if (this.platform.config.updateAccessoryName) {
|
|
1601
|
+
this.accessory.displayName = `${this.device.name} - ${title}`
|
|
1602
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Updated display name`)
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
// Check if we own this card to fetch additional details
|
|
1588
1607
|
if (!this.platform.isCardOwned(cardId)) {
|
|
1589
|
-
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}]
|
|
1608
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Card ${cardId} (not in library - using event data)`)
|
|
1590
1609
|
this.activeContentInfo = null
|
|
1591
1610
|
this.accessory.context.activeContentInfo = null
|
|
1592
1611
|
return
|
|
1593
1612
|
}
|
|
1594
1613
|
|
|
1595
|
-
|
|
1596
|
-
|
|
1614
|
+
// Attempt to fetch full card details for owned cards
|
|
1597
1615
|
try {
|
|
1598
|
-
// Fetch card details for owned cards
|
|
1599
1616
|
const content = await this.platform.yotoApi.getContent(cardId)
|
|
1600
1617
|
this.activeContentInfo = content
|
|
1601
1618
|
|
|
1602
|
-
// Log
|
|
1603
|
-
const title = content.card?.title || 'Unknown'
|
|
1604
|
-
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Now playing: "${title}"`)
|
|
1605
|
-
|
|
1619
|
+
// Log additional metadata from API
|
|
1606
1620
|
if (content.card?.metadata?.author) {
|
|
1607
1621
|
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Author: ${content.card.metadata.author}`)
|
|
1608
1622
|
}
|
|
@@ -1611,23 +1625,17 @@ export class YotoPlayerAccessory {
|
|
|
1611
1625
|
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Category: ${content.card.metadata.category}`)
|
|
1612
1626
|
}
|
|
1613
1627
|
|
|
1614
|
-
// Optionally update accessory display name with current content
|
|
1615
|
-
if (this.platform.config.updateAccessoryName && content.card?.title) {
|
|
1616
|
-
this.accessory.displayName = `${this.device.name} - ${content.card.title}`
|
|
1617
|
-
this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Updated display name`)
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
1628
|
// Store in context for persistence
|
|
1621
1629
|
this.accessory.context.activeContentInfo = this.activeContentInfo
|
|
1622
1630
|
} catch (error) {
|
|
1623
1631
|
// Handle 403 Forbidden (store-bought cards user doesn't own)
|
|
1624
1632
|
if (error instanceof Error && error.message.includes('403')) {
|
|
1625
|
-
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}]
|
|
1633
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Card ${cardId} API access denied (using event data)`)
|
|
1626
1634
|
this.activeContentInfo = null
|
|
1627
1635
|
this.accessory.context.activeContentInfo = null
|
|
1628
1636
|
} else if (error instanceof Error && error.message.includes('404')) {
|
|
1629
1637
|
// Card not found - might be deleted or invalid
|
|
1630
|
-
this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Card ${cardId} not found`)
|
|
1638
|
+
this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Card ${cardId} not found in API`)
|
|
1631
1639
|
this.activeContentInfo = null
|
|
1632
1640
|
this.accessory.context.activeContentInfo = null
|
|
1633
1641
|
} else {
|
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.18",
|
|
5
5
|
"author": "Bret Comnes <bcomnes@gmail.com> (https://bret.io)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/bcomnes/homebridge-yoto/issues"
|