homebridge-yoto 0.0.20 → 0.0.21

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.
@@ -467,7 +467,7 @@ export class YotoPlayerAccessory {
467
467
  try {
468
468
  // Check if device is online first
469
469
  if (!this.device.online) {
470
- this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Device is offline, skipping MQTT connection`)
470
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Device is offline, skipping MQTT connection`)
471
471
  return
472
472
  }
473
473
 
@@ -477,12 +477,7 @@ export class YotoPlayerAccessory {
477
477
  return
478
478
  }
479
479
 
480
- // TEMPORARY: Debug logging for MQTT troubleshooting
481
- this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.device.name}] MQTT Connection Details:`)
482
- this.log.warn(LOG_PREFIX.ACCESSORY, ` Device Online: ${this.device.online}`)
483
- this.log.warn(LOG_PREFIX.ACCESSORY, ` Device ID: ${this.device.deviceId}`)
484
- this.log.warn(LOG_PREFIX.ACCESSORY, ` Access Token: ${this.platform.config.accessToken}`)
485
- this.log.warn(LOG_PREFIX.ACCESSORY, ` Token Length: ${this.platform.config.accessToken.length}`)
480
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] Connecting to MQTT (device online: ${this.device.online})`)
486
481
 
487
482
  // Connect MQTT with device ID and access token
488
483
  await this.mqtt.connect(
@@ -503,12 +498,12 @@ export class YotoPlayerAccessory {
503
498
  // Set up MQTT event listeners
504
499
  this.mqtt.on('disconnected', () => {
505
500
  this.mqttConnected = false
506
- this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.device.name}] MQTT disconnected`)
501
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] MQTT disconnected`)
507
502
  })
508
503
 
509
504
  this.mqtt.on('offline', () => {
510
505
  this.mqttConnected = false
511
- this.log.warn(LOG_PREFIX.ACCESSORY, `[${this.device.name}] MQTT offline`)
506
+ this.log.debug(LOG_PREFIX.ACCESSORY, `[${this.device.name}] MQTT offline`)
512
507
  })
513
508
 
514
509
  this.mqtt.on('connected', () => {
@@ -616,12 +611,18 @@ export class YotoPlayerAccessory {
616
611
 
617
612
  // Update temperature
618
613
  if (this.temperatureService && this.currentStatus.temp) {
619
- const temp = parseFloat(this.currentStatus.temp)
620
- if (!isNaN(temp)) {
621
- this.temperatureService.updateCharacteristic(
622
- this.platform.Characteristic.CurrentTemperature,
623
- temp
624
- )
614
+ // Parse temp string format "x:temp:y" to get middle value
615
+ const tempParts = this.currentStatus.temp.split(':')
616
+ if (tempParts.length >= 2) {
617
+ const temp = Number(tempParts[1])
618
+ if (!isNaN(temp)) {
619
+ // Clamp to HomeKit's valid range: 0-100°C
620
+ const clampedTemp = Math.max(0, Math.min(100, temp))
621
+ this.temperatureService.updateCharacteristic(
622
+ this.platform.Characteristic.CurrentTemperature,
623
+ clampedTemp
624
+ )
625
+ }
625
626
  }
626
627
 
627
628
  // Update display brightness
@@ -929,11 +930,22 @@ export class YotoPlayerAccessory {
929
930
  */
930
931
  async getCurrentTemperature () {
931
932
  if (!this.currentStatus || !this.currentStatus.temp) {
933
+ return 20 // Default room temperature
934
+ }
935
+
936
+ // Parse temp string format "x:temp:y" to get middle value (actual temperature)
937
+ const tempParts = this.currentStatus.temp.split(':')
938
+ if (tempParts.length < 2) {
939
+ return 20
940
+ }
941
+
942
+ const temp = Number(tempParts[1])
943
+ if (isNaN(temp)) {
932
944
  return 20
933
945
  }
934
946
 
935
- const temp = parseFloat(this.currentStatus.temp)
936
- return isNaN(temp) ? 20 : temp
947
+ // Clamp to HomeKit's valid range: 0-100°C
948
+ return Math.max(0, Math.min(100, temp))
937
949
  }
938
950
 
939
951
  /**
package/lib/yotoMqtt.js CHANGED
@@ -60,7 +60,7 @@ export class YotoMqtt extends EventEmitter {
60
60
  */
61
61
  async connect (accessToken, deviceId) {
62
62
  if (this.client) {
63
- this.log.warn(LOG_PREFIX.MQTT, 'Already connected, disconnecting first...')
63
+ this.log.debug(LOG_PREFIX.MQTT, 'Already connected, disconnecting first...')
64
64
  await this.disconnect()
65
65
  }
66
66
 
@@ -70,21 +70,7 @@ export class YotoMqtt extends EventEmitter {
70
70
  const clientId = `DASH${deviceId}`
71
71
  const username = `${deviceId}?x-amz-customauthorizer-name=${YOTO_MQTT_AUTH_NAME}`
72
72
 
73
- // TEMPORARY: Detailed debug logging for MQTT troubleshooting
74
- this.log.warn(LOG_PREFIX.MQTT, '='.repeat(60))
75
- this.log.warn(LOG_PREFIX.MQTT, 'MQTT CONNECTION DETAILS')
76
- this.log.warn(LOG_PREFIX.MQTT, '='.repeat(60))
77
- this.log.warn(LOG_PREFIX.MQTT, `Broker URL: ${this.brokerUrl}`)
78
- this.log.warn(LOG_PREFIX.MQTT, `Client ID: ${clientId}`)
79
- this.log.warn(LOG_PREFIX.MQTT, `Username: ${username}`)
80
- this.log.warn(LOG_PREFIX.MQTT, `Device ID: ${deviceId}`)
81
- this.log.warn(LOG_PREFIX.MQTT, `Token: ${accessToken}`)
82
- this.log.warn(LOG_PREFIX.MQTT, `Token length: ${accessToken.length}`)
83
- this.log.warn(LOG_PREFIX.MQTT, 'Port: 443')
84
- this.log.warn(LOG_PREFIX.MQTT, 'Protocol: wss')
85
- this.log.warn(LOG_PREFIX.MQTT, 'Keepalive: 300')
86
- this.log.warn(LOG_PREFIX.MQTT, `Connect Timeout: ${MQTT_CONNECT_TIMEOUT}ms`)
87
- this.log.warn(LOG_PREFIX.MQTT, '='.repeat(60))
73
+ this.log.debug(LOG_PREFIX.MQTT, `Connecting with client ID: ${clientId}`)
88
74
 
89
75
  this.client = mqtt.connect(this.brokerUrl, {
90
76
  keepalive: 300,
@@ -135,7 +121,7 @@ export class YotoMqtt extends EventEmitter {
135
121
  this.emit('disconnected')
136
122
 
137
123
  if (wasConnected) {
138
- this.log.warn(LOG_PREFIX.MQTT, ERROR_MESSAGES.MQTT_DISCONNECTED)
124
+ this.log.info(LOG_PREFIX.MQTT, ERROR_MESSAGES.MQTT_DISCONNECTED)
139
125
  this.handleReconnect()
140
126
  } else {
141
127
  this.log.error(LOG_PREFIX.MQTT, 'Connection closed before establishing connection')
@@ -156,18 +142,18 @@ export class YotoMqtt extends EventEmitter {
156
142
 
157
143
  this.client.on('offline', () => {
158
144
  this.connected = false
159
- this.log.warn(LOG_PREFIX.MQTT, 'MQTT client offline - connection failed or lost')
145
+ this.log.debug(LOG_PREFIX.MQTT, 'MQTT client offline - connection failed or lost')
160
146
 
161
147
  // Emit offline event
162
148
  this.emit('offline')
163
149
  })
164
150
 
165
151
  this.client.on('end', () => {
166
- this.log.warn(LOG_PREFIX.MQTT, 'MQTT client ended')
152
+ this.log.debug(LOG_PREFIX.MQTT, 'MQTT client ended')
167
153
  })
168
154
 
169
155
  this.client.on('disconnect', (packet) => {
170
- this.log.warn(LOG_PREFIX.MQTT, 'MQTT client disconnected:', packet)
156
+ this.log.debug(LOG_PREFIX.MQTT, 'MQTT client disconnected:', packet)
171
157
  })
172
158
 
173
159
  this.client.on('packetreceive', (packet) => {
@@ -309,10 +295,10 @@ export class YotoMqtt extends EventEmitter {
309
295
  // Request initial status after a short delay
310
296
  setTimeout(() => {
311
297
  this.requestStatus(deviceId).catch(err => {
312
- this.log.warn(LOG_PREFIX.MQTT, `Failed to request initial status for ${deviceId}:`, err)
298
+ this.log.debug(LOG_PREFIX.MQTT, `Failed to request initial status for ${deviceId}:`, err)
313
299
  })
314
300
  this.requestEvents(deviceId).catch(err => {
315
- this.log.warn(LOG_PREFIX.MQTT, `Failed to request initial events for ${deviceId}:`, err)
301
+ this.log.debug(LOG_PREFIX.MQTT, `Failed to request initial events for ${deviceId}:`, err)
316
302
  })
317
303
  }, INITIAL_STATUS_REQUEST_DELAY)
318
304
 
@@ -371,7 +357,7 @@ export class YotoMqtt extends EventEmitter {
371
357
  const deviceId = this.extractDeviceId(topic)
372
358
 
373
359
  if (!deviceId) {
374
- this.log.warn(LOG_PREFIX.MQTT, `Could not extract device ID from topic: ${topic}`)
360
+ this.log.debug(LOG_PREFIX.MQTT, `Could not extract device ID from topic: ${topic}`)
375
361
  return
376
362
  }
377
363
 
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.20",
4
+ "version": "0.0.21",
5
5
  "author": "Bret Comnes <bcomnes@gmail.com> (https://bret.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/bcomnes/homebridge-yoto/issues"