Skip to content

Commit 009e4cd

Browse files
committed
Release 0.6.0
1 parent c32fe39 commit 009e4cd

2 files changed

Lines changed: 16 additions & 32 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Changelog
1+
# <img src="https://github.com/Luligu/matterbridge/blob/main/frontend/public/matterbridge%2064x64.png" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge shelly plugin changelog
22

33
All notable changes to this project will be documented in this file.
44

@@ -16,7 +16,7 @@ If you like this project and find it useful, please consider giving it a star on
1616
- [package]: Updated dependencies
1717

1818
<a href="https://www.buymeacoffee.com/luligugithub">
19-
<img src="https://github.com/Luligu/matterbridge/yellow-button.png" alt="Buy me a coffee" width="120">
19+
<img src="./yellow-button.png" alt="Buy me a coffee" width="120">
2020
</a>
2121

2222
## [0.5.1] - 2024-06-25

src/coapServer.ts

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ export class CoapServer extends EventEmitter {
106106
// agent: this.coapAgent,
107107
})
108108
.on('response', (msg: IncomingMessage) => {
109-
this.log.debug(`Coap got device description ("/cit/d") code ${BLUE}${msg.code}${db} url ${BLUE}${msg.url}${db} rsinfo ${debugStringify(msg.rsinfo)}:`);
109+
this.log.debug(`CoIoT (coap) received device description ("/cit/d") code ${BLUE}${msg.code}${db} url ${BLUE}${msg.url}${db} rsinfo ${debugStringify(msg.rsinfo)}:`);
110110
msg.url = '/cit/d';
111111
this.parseShellyMessage(msg);
112112
resolve(msg);
113113
})
114114
.on('error', (err) => {
115-
this.log.error('Coap error getting device description ("/cit/d"):', err);
115+
this.log.error('CoIoT (coap) error getting device description ("/cit/d"):', err);
116116
reject(err);
117117
})
118118
.end();
@@ -131,20 +131,20 @@ export class CoapServer extends EventEmitter {
131131
// agent: this.coapAgent,
132132
})
133133
.on('response', (msg: IncomingMessage) => {
134-
this.log.debug(`Coap got device status ("/cit/s") code ${BLUE}${msg.code}${db} url ${BLUE}${msg.url}${db} rsinfo ${debugStringify(msg.rsinfo)}:`);
134+
this.log.debug(`CoIoT (coap) received device status ("/cit/s") code ${BLUE}${msg.code}${db} url ${BLUE}${msg.url}${db} rsinfo ${debugStringify(msg.rsinfo)}:`);
135135
this.parseShellyMessage(msg);
136136
resolve(msg);
137137
})
138138
.on('error', (err) => {
139-
this.log.error('Coap error getting device status ("/cit/s"):', err);
139+
this.log.error('CoIoT (coap) error getting device status ("/cit/s"):', err);
140140
reject(err);
141141
})
142142
.end();
143143
});
144144
}
145145

146146
getMulticastDeviceStatus(timeout = 60): Promise<IncomingMessage | null> {
147-
this.log.debug('Requesting multicast device status...');
147+
this.log.debug('Requesting CoIoT (coap) multicast device status...');
148148
return new Promise((resolve, reject) => {
149149
const request = coap
150150
.request({
@@ -163,7 +163,7 @@ export class CoapServer extends EventEmitter {
163163
})
164164
.on('error', (err) => {
165165
clearTimeout(timer);
166-
this.log.error('Coap error requesting multicast device status ("/cit/s"):', err);
166+
this.log.error('CoIoT (coap) error requesting multicast device status ("/cit/s"):', err);
167167
reject(err);
168168
})
169169
.end();
@@ -231,7 +231,7 @@ export class CoapServer extends EventEmitter {
231231
}
232232

233233
private parseShellyMessage(msg: IncomingMessage) {
234-
this.log.debug(`Parsing device Coap response...`);
234+
this.log.debug(`Parsing device CoIoT (coap) response...`);
235235

236236
const host = msg.rsinfo.address;
237237
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -370,25 +370,9 @@ export class CoapServer extends EventEmitter {
370370
multicastAddress: COAP_MULTICAST_ADDRESS,
371371
});
372372

373-
/*
374-
// 192.168.1.189:5683
375-
// insert our own middleware right before requests are handled (the last step)
376-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
377-
this.coapServer._middlewares.splice(Math.max(this.coapServer._middlewares.length - 1, 0), 0, (req: any, next: any) => {
378-
this.log.warn(`Server middleware got a messagge code ${req.packet.code} rsinfo ${debugStringify(req.rsinfo)}...`);
379-
// Unicast messages from Shelly devices will have the 2.05 code, which the
380-
// server will silently drop (since its a response code and not a request
381-
// code). To avoid this, we change it to 0.30 here.
382-
if (req.packet.code === '2.05') {
383-
req.packet.code = '0.30';
384-
}
385-
next();
386-
});
387-
*/
388-
389373
// eslint-disable-next-line @typescript-eslint/no-unused-vars
390374
this.coapServer.on('request', (msg: IncomingMessage, res: OutgoingMessage) => {
391-
this.log.debug(`Coap server got a messagge code ${BLUE}${msg.code}${db} url ${BLUE}${msg.url}${db} rsinfo ${debugStringify(msg.rsinfo)}...`);
375+
this.log.debug(`CoIoT (coap) server got a messagge code ${BLUE}${msg.code}${db} url ${BLUE}${msg.url}${db} rsinfo ${debugStringify(msg.rsinfo)}...`);
392376
if (msg.code === '0.30' && msg.url === '/cit/s') {
393377
// const coapMessage = this.parseShellyMessage(msg);
394378
// this.emit('update', coapMessage);
@@ -401,9 +385,9 @@ export class CoapServer extends EventEmitter {
401385

402386
this.coapServer.listen((err) => {
403387
if (err) {
404-
this.log.warn('Coap server error while listening:', err);
388+
this.log.warn('CoIoT (coap) server error while listening:', err);
405389
} else {
406-
this.log.info('Coap server is listening ...');
390+
this.log.info('CoIoT (coap) server is listening ...');
407391
}
408392
});
409393
}
@@ -417,21 +401,21 @@ export class CoapServer extends EventEmitter {
417401
start(debug = false) {
418402
this.log.setLogDebug(debug);
419403
if (this._isListening) return;
420-
this.log.info('Starting CoIoT server for shelly devices...');
404+
this.log.info('Starting CoIoT (coap) server for shelly devices...');
421405
this._isListening = true;
422406
this.listenForStatusUpdates();
423-
this.log.info('Started CoIoT server for shelly devices.');
407+
this.log.info('Started CoIoT (coap) server for shelly devices.');
424408
}
425409

426410
stop() {
427-
this.log.info('Stopping CoIoT server for shelly devices...');
411+
this.log.info('Stopping CoIoT (coap) server for shelly devices...');
428412
this.removeAllListeners();
429413
this._isListening = false;
430414
globalAgent.close();
431415
// this.coapAgent.close();
432416
if (this.coapServer) this.coapServer.close();
433417
this.devices.clear();
434-
this.log.info('Stopped CoIoT server for shelly devices.');
418+
this.log.info('Stopped CoIoT (coap) server for shelly devices.');
435419
}
436420
}
437421

0 commit comments

Comments
 (0)