Skip to content

Commit d731789

Browse files
committed
Additional message debug logging (qos, dup, retain)
1 parent dfe7710 commit d731789

4 files changed

Lines changed: 12 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
All notable changes to homebridge-dummy will be documented in this file.
44

5-
## 1.5.16-beta.1 ()
5+
## 1.5.16-beta.2 ()
66

77
### Added
88
- Added `topicGetAvailable` for "Last Will and Testament" (LWT) before an accessory goes offline
99
- If value does not match `valueAvailable`, then accessory will show "No Response" in HomeKit until the next successful get event
10+
- Packet info (qos, dup, retain) to verbose message logging
1011

1112
### Changed
1213
- Renamed "Get Availability" to "Get Active Status" in config UI to avoid confusion with the new `topicGetAvailable` (see above)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"displayName": "Homebridge Easy MQTT",
55
"description": "Homebridge plugin for MQTT devices",
66
"type": "module",
7-
"version": "1.5.16-beta.1",
7+
"version": "1.5.16-beta.2",
88
"homepage": "https://github.com/mpatfield/homebridge-easy-mqtt#readme",
99
"repository": {
1010
"type": "git",

src/model/mqtt.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export class MQTT {
198198
});
199199
});
200200

201-
this.client.on('message', (topic, message) => this.messageReceived(topic, message.toString()));
201+
this.client.on('message', (_topic, _message, packet) => this.messageReceived(packet));
202202

203203
this.client.on('close', () => this.connectionClosed());
204204

@@ -319,15 +319,17 @@ export class MQTT {
319319
}
320320
}
321321

322-
private messageReceived(topic: string, message: string) {
322+
private messageReceived(packet: mqtt.IPublishPacket) {
323323

324324
this.reconnectCount = 0;
325325

326-
try {
326+
const topic = packet.topic;
327+
const message = packet.payload.toString().trim();
328+
const meta = `(qos: ${packet.qos}, dup: ${packet.dup}, retain: ${packet.retain})`;
327329

328-
message = message.trim();
330+
try {
329331

330-
this.log.ifVerbose(strings.mqttClient.receivedMessage, this.host, topic, `\n${message}`);
332+
this.log.ifVerbose(strings.mqttClient.receivedMessage, this.host, topic, `${meta}\n${message}`);
331333

332334
const listeners = this.listeners.get(topic);
333335
if (!listeners || listeners.length === 0) {

0 commit comments

Comments
 (0)