mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-23 19:19:52 +00:00
chore: Update dependencies (#18459)
* fix(ignore): update dependencies * Make compatible with MQTT 5 * updates --------- Co-authored-by: Koenkk <Koenkk@users.noreply.github.com>
This commit is contained in:
@@ -124,7 +124,7 @@ export default class Frontend extends Extension {
|
||||
if (!isBinary && data) {
|
||||
const message = data.toString();
|
||||
const {topic, payload} = JSON.parse(message);
|
||||
this.mqtt.onMessage(`${this.mqttBaseTopic}/${topic}`, stringify(payload));
|
||||
this.mqtt.onMessage(`${this.mqttBaseTopic}/${topic}`, Buffer.from(stringify(payload)));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+6
-5
@@ -4,6 +4,7 @@ import * as settings from './util/settings';
|
||||
import utils from './util/utils';
|
||||
import fs from 'fs';
|
||||
import bind from 'bind-decorator';
|
||||
import type {QoS} from 'mqtt-packet';
|
||||
|
||||
export default class MQTT {
|
||||
private publishedTopics: Set<string> = new Set();
|
||||
@@ -26,7 +27,7 @@ export default class MQTT {
|
||||
const options: mqtt.IClientOptions = {
|
||||
will: {
|
||||
topic: `${settings.get().mqtt.base_topic}/bridge/state`,
|
||||
payload: utils.availabilityPayload('offline', settings.get()),
|
||||
payload: Buffer.from(utils.availabilityPayload('offline', settings.get())),
|
||||
retain: settings.get().mqtt.force_disable_retain ? false : true,
|
||||
qos: 1,
|
||||
},
|
||||
@@ -133,11 +134,11 @@ export default class MQTT {
|
||||
this.client.subscribe(topic);
|
||||
}
|
||||
|
||||
@bind public onMessage(topic: string, message: string): void {
|
||||
@bind public onMessage(topic: string, message: Buffer): void {
|
||||
// Since we subscribe to zigbee2mqtt/# we also receive the message we send ourselves, skip these.
|
||||
if (!this.publishedTopics.has(topic)) {
|
||||
logger.debug(`Received MQTT message on '${topic}' with data '${message}'`);
|
||||
this.eventBus.emitMQTTMessage({topic, message: message + ''});
|
||||
logger.debug(`Received MQTT message on '${topic}' with data '${message.toString()}'`);
|
||||
this.eventBus.emitMQTTMessage({topic, message: message.toString()});
|
||||
}
|
||||
|
||||
if (this.republishRetainedTimer && topic === `${settings.get().mqtt.base_topic}/bridge/info`) {
|
||||
@@ -153,7 +154,7 @@ export default class MQTT {
|
||||
async publish(topic: string, payload: string, options: MQTTOptions={},
|
||||
base=settings.get().mqtt.base_topic, skipLog=false, skipReceive=true,
|
||||
): Promise<void> {
|
||||
const defaultOptions: {qos: mqtt.QoS, retain: boolean} = {qos: 0, retain: false};
|
||||
const defaultOptions: {qos: QoS, retain: boolean} = {qos: 0, retain: false};
|
||||
topic = `${base}/${topic}`;
|
||||
|
||||
if (skipReceive) {
|
||||
|
||||
Vendored
+3
-3
@@ -31,7 +31,7 @@ import type TypeDevice from 'lib/model/device';
|
||||
import type TypeGroup from 'lib/model/group';
|
||||
import type TypeExtension from 'lib/extension/extension';
|
||||
|
||||
import type mqtt from 'mqtt';
|
||||
import type {QoS} from 'mqtt-packet';
|
||||
|
||||
declare global {
|
||||
// Define some class types as global
|
||||
@@ -45,7 +45,7 @@ declare global {
|
||||
|
||||
// Types
|
||||
interface MQTTResponse {data: KeyValue, status: 'error' | 'ok', error?: string, transaction?: string}
|
||||
interface MQTTOptions {qos?: mqtt.QoS, retain?: boolean, properties?: {messageExpiryInterval: number}}
|
||||
interface MQTTOptions {qos?: QoS, retain?: boolean, properties?: {messageExpiryInterval: number}}
|
||||
type StateChangeReason = 'publishDebounce' | 'groupOptimistic' | 'lastSeenChanged' | 'publishCached';
|
||||
type PublishEntityState = (entity: Device | Group, payload: KeyValue,
|
||||
stateChangeReason?: StateChangeReason) => Promise<void>;
|
||||
@@ -189,7 +189,7 @@ declare global {
|
||||
base_topic: string,
|
||||
include_device_information: boolean,
|
||||
force_disable_retain: boolean
|
||||
version?: number,
|
||||
version?: 3 | 4 | 5,
|
||||
user?: string,
|
||||
password?: string,
|
||||
server: string,
|
||||
|
||||
Reference in New Issue
Block a user