hm2mqtt 3.4.1 → 3.4.3
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.
- package/index.js +9 -1
- package/package.json +1 -1
- package/scripts/addon-api.js +6 -3
package/index.js
CHANGED
|
@@ -96,7 +96,15 @@ function firstIp() {
|
|
|
96
96
|
|
|
97
97
|
// the option's default is $STATE_DIRECTORY only, so --install does not freeze this fallback into the env file
|
|
98
98
|
config.stateDir = config.stateDir || path.join(os.homedir(), '.hm2mqtt');
|
|
99
|
-
|
|
99
|
+
try {
|
|
100
|
+
fs.mkdirSync(config.stateDir, {recursive: true});
|
|
101
|
+
} catch (error) {
|
|
102
|
+
// a home directory that does not exist or a read-only filesystem: say which path and what to
|
|
103
|
+
// set, instead of an ENOENT stack trace from deep in node:fs
|
|
104
|
+
console.error(`error: cannot create the state directory ${config.stateDir}: ${error.message}`);
|
|
105
|
+
console.error('set --state-dir (HM2MQTT_STATE_DIR) to a writable path');
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
100
108
|
|
|
101
109
|
let nameFile = {};
|
|
102
110
|
if (config.nameFile) {
|
package/package.json
CHANGED
package/scripts/addon-api.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import Rega from 'homematic-rega';
|
|
19
19
|
import {discover} from 'mqtt-interfaces-core';
|
|
20
|
-
import {probeInterfaces, INTERFACE_NAMES} from '../lib/interfaces.js';
|
|
20
|
+
import {probeInterfaces, detectLocal, INTERFACE_NAMES} from '../lib/interfaces.js';
|
|
21
21
|
import {discoveryHint, interfacesOf} from '../lib/discovery.js';
|
|
22
22
|
import {compileTemplate, DEFAULT_ITEM_TEMPLATE} from '../lib/topics.js';
|
|
23
23
|
|
|
@@ -84,8 +84,11 @@ const commands = {
|
|
|
84
84
|
|
|
85
85
|
async probe() {
|
|
86
86
|
const host = String(args.host || '127.0.0.1');
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
// on the CCU the addon talks to the interface processes directly, so probe those ports -
|
|
88
|
+
// the proxy ports may answer as well, but they are not what will be connected to
|
|
89
|
+
const local = args.local === undefined ? await detectLocal(host) : args.local !== 'false';
|
|
90
|
+
const found = await probeInterfaces(host, {tls: Boolean(args.tls), local, timeout: 2000});
|
|
91
|
+
return {host, local, interfaces: found, known: INTERFACE_NAMES};
|
|
89
92
|
},
|
|
90
93
|
|
|
91
94
|
async 'mqtt-test'() {
|