optolink-bridge 1.4.0 → 1.4.1

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.
Files changed (2) hide show
  1. package/index.js +11 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -85,6 +85,10 @@ async function applyConfig(config) {
85
85
  const device = config.mqtt?.device_discovery?.overrides?.device;
86
86
  deviceSerialNo = device?.serial_number || device?.identifiers || deviceSerialNo;
87
87
  Array.isArray(deviceSerialNo) && (deviceSerialNo = deviceSerialNo[0]);
88
+
89
+ if (deviceSerialNo) {
90
+ logger.warn('No device serial number set in the config.toml, device discovery will be deferred until Vitoconnect sends it')
91
+ }
88
92
  }
89
93
 
90
94
  deviceDiscoveryOptions = config.mqtt?.device_discovery;
@@ -105,7 +109,10 @@ let mqttClient, mqttTopic, mqttAvailabilityTopic, mqttDpTopic = dp => {
105
109
  };
106
110
 
107
111
  deviceDiscovery = async function(options = (deviceDiscoveryOptions ?? { enabled: true })) {
108
- if (!mqttClient?.connected || !deviceSerialNo || !(options?.enabled ?? true)) {
112
+ if (!mqttClient?.connected || !deviceSerialNo) {
113
+ return;
114
+ } else if (!(options?.enabled ?? true)) {
115
+ logger.warn('Device discovery is disabled in the config.toml');
109
116
  return;
110
117
  }
111
118
 
@@ -156,7 +163,9 @@ if (config.mqtt && config.mqtt.url) {
156
163
  };
157
164
 
158
165
  // connect to MQTT broker
166
+ logger.info('Connecting to MQTT broker and waiting for connection...');
159
167
  mqttClient = await mqttConnect(config.mqtt.url, mqttOptions);
168
+ logger.info('MQTT connected, proceeding with publishing online topic / device discovery');
160
169
  const mqttConnected = async () => {
161
170
  config.mqtt.online && await mqttClient.publishAsync(
162
171
  mqttAvailabilityTopic, `${true}`, { retain: true });
@@ -216,6 +225,7 @@ const packetQueue = async.queue(async task => {
216
225
  // we wait for the serial number to be sent by Vitoconnect (0xF010) and then publish the discovery message
217
226
  if (!deviceSerialNo && packet.addr === 0xF010 && (config.mqtt?.device_discovery?.enabled ?? true)) {
218
227
  deviceSerialNo = parseValue('string', packet.data)?.trim?.();
228
+ logger.info(`Device serial number received from Vitoconnect: ${deviceSerialNo}`);
219
229
  await deviceDiscovery();
220
230
  }
221
231
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "optolink-bridge",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Safely bridge the Optolink bus of your Viessmann heating system and publish attributes via MQTT + Home Assistant Device Discovery",
5
5
  "keywords": [
6
6
  "viessmann",