homebridge-yoto 0.0.14 → 0.0.16
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 +47 -11
- package/package.json +1 -1
package/lib/playerAccessory.js
CHANGED
|
@@ -510,16 +510,20 @@ export class YotoPlayerAccessory {
|
|
|
510
510
|
}
|
|
511
511
|
|
|
512
512
|
/**
|
|
513
|
-
* Handle
|
|
514
|
-
* @param {YotoDeviceStatus} status -
|
|
513
|
+
* Handle status update from MQTT
|
|
514
|
+
* @param {YotoDeviceStatus} status - Status data
|
|
515
515
|
*/
|
|
516
516
|
handleStatusUpdate (status) {
|
|
517
|
-
this.log.
|
|
517
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Received status update:`, JSON.stringify(status, null, 2))
|
|
518
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Status - batteryLevel:`, status.batteryLevel)
|
|
519
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Status - userVolume:`, status.userVolume)
|
|
520
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Status - volume:`, status.volume)
|
|
521
|
+
|
|
518
522
|
this.currentStatus = status
|
|
519
523
|
this.lastUpdateTime = Date.now()
|
|
520
524
|
this.accessory.context.lastStatus = status
|
|
525
|
+
this.accessory.context.lastUpdate = this.lastUpdateTime
|
|
521
526
|
|
|
522
|
-
// Update all characteristics
|
|
523
527
|
this.updateCharacteristics()
|
|
524
528
|
}
|
|
525
529
|
|
|
@@ -785,10 +789,16 @@ export class YotoPlayerAccessory {
|
|
|
785
789
|
* @returns {Promise<CharacteristicValue>}
|
|
786
790
|
*/
|
|
787
791
|
async getVolume () {
|
|
792
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getVolume - currentStatus:`, this.currentStatus)
|
|
793
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getVolume - userVolume:`, this.currentStatus?.userVolume)
|
|
794
|
+
|
|
788
795
|
if (!this.currentStatus || this.currentStatus.userVolume === undefined) {
|
|
796
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getVolume - returning default: 50`)
|
|
789
797
|
return 50
|
|
790
798
|
}
|
|
791
|
-
|
|
799
|
+
const volume = Number(this.currentStatus.userVolume) || 50
|
|
800
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getVolume - returning:`, volume)
|
|
801
|
+
return volume
|
|
792
802
|
}
|
|
793
803
|
|
|
794
804
|
/**
|
|
@@ -849,10 +859,16 @@ export class YotoPlayerAccessory {
|
|
|
849
859
|
* @returns {Promise<CharacteristicValue>}
|
|
850
860
|
*/
|
|
851
861
|
async getBatteryLevel () {
|
|
862
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getBatteryLevel - currentStatus:`, this.currentStatus)
|
|
863
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getBatteryLevel - batteryLevel:`, this.currentStatus?.batteryLevel)
|
|
864
|
+
|
|
852
865
|
if (!this.currentStatus || this.currentStatus.batteryLevel === undefined) {
|
|
866
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getBatteryLevel - returning default: 100`)
|
|
853
867
|
return 100
|
|
854
868
|
}
|
|
855
|
-
|
|
869
|
+
const battery = Number(this.currentStatus.batteryLevel) || 100
|
|
870
|
+
this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getBatteryLevel - returning:`, battery)
|
|
871
|
+
return battery
|
|
856
872
|
}
|
|
857
873
|
|
|
858
874
|
/**
|
|
@@ -976,12 +992,16 @@ export class YotoPlayerAccessory {
|
|
|
976
992
|
* @returns {Promise<CharacteristicValue>}
|
|
977
993
|
*/
|
|
978
994
|
async getDisplayBrightness () {
|
|
979
|
-
if (!this.currentStatus) {
|
|
995
|
+
if (!this.currentStatus || this.currentStatus.dnowBrightness === undefined) {
|
|
980
996
|
return 100
|
|
981
997
|
}
|
|
982
998
|
|
|
983
999
|
// Use current brightness value (0-100)
|
|
984
|
-
|
|
1000
|
+
const brightness = Number(this.currentStatus.dnowBrightness)
|
|
1001
|
+
if (isNaN(brightness)) {
|
|
1002
|
+
return 100
|
|
1003
|
+
}
|
|
1004
|
+
return Math.min(100, Math.max(0, brightness))
|
|
985
1005
|
}
|
|
986
1006
|
|
|
987
1007
|
/**
|
|
@@ -1204,6 +1224,9 @@ export class YotoPlayerAccessory {
|
|
|
1204
1224
|
try {
|
|
1205
1225
|
const config = await this.platform.yotoApi.getDeviceConfig(this.device.deviceId)
|
|
1206
1226
|
const limit = parseInt(config.config.maxVolumeLimit || '16')
|
|
1227
|
+
if (isNaN(limit)) {
|
|
1228
|
+
return 100
|
|
1229
|
+
}
|
|
1207
1230
|
// Map 0-16 to 0-100
|
|
1208
1231
|
return Math.round((limit / 16) * 100)
|
|
1209
1232
|
} catch (error) {
|
|
@@ -1259,6 +1282,9 @@ export class YotoPlayerAccessory {
|
|
|
1259
1282
|
try {
|
|
1260
1283
|
const config = await this.platform.yotoApi.getDeviceConfig(this.device.deviceId)
|
|
1261
1284
|
const limit = parseInt(config.config.nightMaxVolumeLimit || '16')
|
|
1285
|
+
if (isNaN(limit)) {
|
|
1286
|
+
return 100
|
|
1287
|
+
}
|
|
1262
1288
|
// Map 0-16 to 0-100
|
|
1263
1289
|
return Math.round((limit / 16) * 100)
|
|
1264
1290
|
} catch (error) {
|
|
@@ -1336,6 +1362,9 @@ export class YotoPlayerAccessory {
|
|
|
1336
1362
|
const config = await this.platform.yotoApi.getDeviceConfig(this.device.deviceId)
|
|
1337
1363
|
const hex = config.config.ambientColour || '#000000'
|
|
1338
1364
|
const { h } = this.hexToHsv(hex)
|
|
1365
|
+
if (isNaN(h)) {
|
|
1366
|
+
return 0
|
|
1367
|
+
}
|
|
1339
1368
|
return h
|
|
1340
1369
|
} catch (error) {
|
|
1341
1370
|
this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to get ambient light hue:`, error)
|
|
@@ -1363,6 +1392,9 @@ export class YotoPlayerAccessory {
|
|
|
1363
1392
|
const config = await this.platform.yotoApi.getDeviceConfig(this.device.deviceId)
|
|
1364
1393
|
const hex = config.config.ambientColour || '#000000'
|
|
1365
1394
|
const { s } = this.hexToHsv(hex)
|
|
1395
|
+
if (isNaN(s)) {
|
|
1396
|
+
return 0
|
|
1397
|
+
}
|
|
1366
1398
|
return s
|
|
1367
1399
|
} catch (error) {
|
|
1368
1400
|
this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to get ambient light saturation:`, error)
|
|
@@ -1388,11 +1420,15 @@ export class YotoPlayerAccessory {
|
|
|
1388
1420
|
async getAmbientLightBrightness () {
|
|
1389
1421
|
try {
|
|
1390
1422
|
const config = await this.platform.yotoApi.getDeviceConfig(this.device.deviceId)
|
|
1391
|
-
const hex = config.config.ambientColour
|
|
1423
|
+
const hex = config.config.ambientColour
|
|
1392
1424
|
const { v } = this.hexToHsv(hex)
|
|
1393
|
-
|
|
1425
|
+
const brightness = Math.round(v)
|
|
1426
|
+
if (isNaN(brightness)) {
|
|
1427
|
+
return 100
|
|
1428
|
+
}
|
|
1429
|
+
return brightness
|
|
1394
1430
|
} catch (error) {
|
|
1395
|
-
this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to get ambient
|
|
1431
|
+
this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to get ambient brightness:`, error)
|
|
1396
1432
|
return 100
|
|
1397
1433
|
}
|
|
1398
1434
|
}
|
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.16",
|
|
5
5
|
"author": "Bret Comnes <bcomnes@gmail.com> (https://bret.io)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/bcomnes/homebridge-yoto/issues"
|