homebridge-yoto 0.0.15 → 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.
@@ -514,10 +514,10 @@ export class YotoPlayerAccessory {
514
514
  * @param {YotoDeviceStatus} status - Status data
515
515
  */
516
516
  handleStatusUpdate (status) {
517
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Received status update:`, JSON.stringify(status, null, 2))
518
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Status - batteryLevel:`, status.batteryLevel)
519
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Status - userVolume:`, status.userVolume)
520
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Status - volume:`, status.volume)
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
521
 
522
522
  this.currentStatus = status
523
523
  this.lastUpdateTime = Date.now()
@@ -789,15 +789,15 @@ export class YotoPlayerAccessory {
789
789
  * @returns {Promise<CharacteristicValue>}
790
790
  */
791
791
  async getVolume () {
792
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getVolume - currentStatus:`, this.currentStatus)
793
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getVolume - userVolume:`, this.currentStatus?.userVolume)
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
794
 
795
795
  if (!this.currentStatus || this.currentStatus.userVolume === undefined) {
796
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getVolume - returning default: 50`)
796
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getVolume - returning default: 50`)
797
797
  return 50
798
798
  }
799
799
  const volume = Number(this.currentStatus.userVolume) || 50
800
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getVolume - returning:`, volume)
800
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getVolume - returning:`, volume)
801
801
  return volume
802
802
  }
803
803
 
@@ -859,15 +859,15 @@ export class YotoPlayerAccessory {
859
859
  * @returns {Promise<CharacteristicValue>}
860
860
  */
861
861
  async getBatteryLevel () {
862
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getBatteryLevel - currentStatus:`, this.currentStatus)
863
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getBatteryLevel - batteryLevel:`, this.currentStatus?.batteryLevel)
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
864
 
865
865
  if (!this.currentStatus || this.currentStatus.batteryLevel === undefined) {
866
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getBatteryLevel - returning default: 100`)
866
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getBatteryLevel - returning default: 100`)
867
867
  return 100
868
868
  }
869
869
  const battery = Number(this.currentStatus.batteryLevel) || 100
870
- this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getBatteryLevel - returning:`, battery)
870
+ this.log.info(LOG_PREFIX.ACCESSORY, `[${this.device.name}] getBatteryLevel - returning:`, battery)
871
871
  return battery
872
872
  }
873
873
 
@@ -992,12 +992,16 @@ export class YotoPlayerAccessory {
992
992
  * @returns {Promise<CharacteristicValue>}
993
993
  */
994
994
  async getDisplayBrightness () {
995
- if (!this.currentStatus) {
995
+ if (!this.currentStatus || this.currentStatus.dnowBrightness === undefined) {
996
996
  return 100
997
997
  }
998
998
 
999
999
  // Use current brightness value (0-100)
1000
- return Math.min(100, Math.max(0, this.currentStatus.dnowBrightness))
1000
+ const brightness = Number(this.currentStatus.dnowBrightness)
1001
+ if (isNaN(brightness)) {
1002
+ return 100
1003
+ }
1004
+ return Math.min(100, Math.max(0, brightness))
1001
1005
  }
1002
1006
 
1003
1007
  /**
@@ -1220,6 +1224,9 @@ export class YotoPlayerAccessory {
1220
1224
  try {
1221
1225
  const config = await this.platform.yotoApi.getDeviceConfig(this.device.deviceId)
1222
1226
  const limit = parseInt(config.config.maxVolumeLimit || '16')
1227
+ if (isNaN(limit)) {
1228
+ return 100
1229
+ }
1223
1230
  // Map 0-16 to 0-100
1224
1231
  return Math.round((limit / 16) * 100)
1225
1232
  } catch (error) {
@@ -1275,6 +1282,9 @@ export class YotoPlayerAccessory {
1275
1282
  try {
1276
1283
  const config = await this.platform.yotoApi.getDeviceConfig(this.device.deviceId)
1277
1284
  const limit = parseInt(config.config.nightMaxVolumeLimit || '16')
1285
+ if (isNaN(limit)) {
1286
+ return 100
1287
+ }
1278
1288
  // Map 0-16 to 0-100
1279
1289
  return Math.round((limit / 16) * 100)
1280
1290
  } catch (error) {
@@ -1352,6 +1362,9 @@ export class YotoPlayerAccessory {
1352
1362
  const config = await this.platform.yotoApi.getDeviceConfig(this.device.deviceId)
1353
1363
  const hex = config.config.ambientColour || '#000000'
1354
1364
  const { h } = this.hexToHsv(hex)
1365
+ if (isNaN(h)) {
1366
+ return 0
1367
+ }
1355
1368
  return h
1356
1369
  } catch (error) {
1357
1370
  this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to get ambient light hue:`, error)
@@ -1379,6 +1392,9 @@ export class YotoPlayerAccessory {
1379
1392
  const config = await this.platform.yotoApi.getDeviceConfig(this.device.deviceId)
1380
1393
  const hex = config.config.ambientColour || '#000000'
1381
1394
  const { s } = this.hexToHsv(hex)
1395
+ if (isNaN(s)) {
1396
+ return 0
1397
+ }
1382
1398
  return s
1383
1399
  } catch (error) {
1384
1400
  this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to get ambient light saturation:`, error)
@@ -1404,11 +1420,15 @@ export class YotoPlayerAccessory {
1404
1420
  async getAmbientLightBrightness () {
1405
1421
  try {
1406
1422
  const config = await this.platform.yotoApi.getDeviceConfig(this.device.deviceId)
1407
- const hex = config.config.ambientColour || '#000000'
1423
+ const hex = config.config.ambientColour
1408
1424
  const { v } = this.hexToHsv(hex)
1409
- return v
1425
+ const brightness = Math.round(v)
1426
+ if (isNaN(brightness)) {
1427
+ return 100
1428
+ }
1429
+ return brightness
1410
1430
  } catch (error) {
1411
- this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to get ambient light brightness:`, error)
1431
+ this.log.error(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Failed to get ambient brightness:`, error)
1412
1432
  return 100
1413
1433
  }
1414
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.15",
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"