@rfranzoi/scrypted-mqtt-securitysystem 1.0.20 → 1.0.21
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/dist/main.nodejs.js +15 -6
- package/dist/plugin.zip +0 -0
- package/package.json +1 -1
package/dist/main.nodejs.js
CHANGED
|
@@ -34112,7 +34112,7 @@ class BaseMqttSensor extends sdk_1.ScryptedDeviceBase {
|
|
|
34112
34112
|
constructor(nativeId, cfg) {
|
|
34113
34113
|
super(nativeId);
|
|
34114
34114
|
this.cfg = cfg;
|
|
34115
|
-
// ⚠️ Non
|
|
34115
|
+
// ⚠️ Non impostare stati qui: il discovery non è ancora completato
|
|
34116
34116
|
}
|
|
34117
34117
|
/** Called by parent on each MQTT message */
|
|
34118
34118
|
handleMqtt(topic, payload) {
|
|
@@ -34141,7 +34141,9 @@ class BaseMqttSensor extends sdk_1.ScryptedDeviceBase {
|
|
|
34141
34141
|
this.batteryLevel = n;
|
|
34142
34142
|
}
|
|
34143
34143
|
else if (topic === this.cfg.topics.lowBattery && !this.cfg.topics.batteryLevel) {
|
|
34144
|
-
//
|
|
34144
|
+
// Solo se abbiamo il topic lowBattery e NON c'è un batteryLevel numerico:
|
|
34145
|
+
// True -> 10% (warning)
|
|
34146
|
+
// False -> 100% (ok)
|
|
34145
34147
|
this.batteryLevel = truthy(np) ? 10 : 100;
|
|
34146
34148
|
}
|
|
34147
34149
|
// primary handled by subclasses
|
|
@@ -34305,19 +34307,21 @@ class ParadoxMqttSecuritySystem extends sdk_1.ScryptedDeviceBase {
|
|
|
34305
34307
|
// 1) Prepara i manifest (niente istanze qui)
|
|
34306
34308
|
const manifests = this.sensorsCfg.map(cfg => {
|
|
34307
34309
|
const nativeId = `sensor:${cfg.id}`;
|
|
34308
|
-
// interfacce dinamiche
|
|
34309
34310
|
const t = cfg.topics || {};
|
|
34310
34311
|
const interfaces = [
|
|
34311
34312
|
sdk_1.ScryptedInterface.Online,
|
|
34312
|
-
sdk_1.ScryptedInterface.TamperSensor,
|
|
34313
34313
|
];
|
|
34314
|
+
// Tamper solo se c'è un topic tamper
|
|
34315
|
+
if (t.tamper)
|
|
34316
|
+
interfaces.push(sdk_1.ScryptedInterface.TamperSensor);
|
|
34317
|
+
// Interfaccia primaria
|
|
34314
34318
|
if (cfg.kind === 'contact')
|
|
34315
34319
|
interfaces.unshift(sdk_1.ScryptedInterface.EntrySensor);
|
|
34316
34320
|
else if (cfg.kind === 'motion')
|
|
34317
34321
|
interfaces.unshift(sdk_1.ScryptedInterface.MotionSensor);
|
|
34318
34322
|
else
|
|
34319
34323
|
interfaces.unshift(sdk_1.ScryptedInterface.OccupancySensor);
|
|
34320
|
-
//
|
|
34324
|
+
// Battery solo se previsto
|
|
34321
34325
|
if (t.batteryLevel || t.lowBattery) {
|
|
34322
34326
|
interfaces.push(sdk_1.ScryptedInterface.Battery);
|
|
34323
34327
|
}
|
|
@@ -34356,6 +34360,11 @@ class ParadoxMqttSecuritySystem extends sdk_1.ScryptedDeviceBase {
|
|
|
34356
34360
|
else {
|
|
34357
34361
|
dev.cfg = cfg;
|
|
34358
34362
|
}
|
|
34363
|
+
// ★ Default “OK” se abbiamo Battery ma nessun valore ancora ricevuto
|
|
34364
|
+
const hasBattery = !!(cfg.topics.batteryLevel || cfg.topics.lowBattery);
|
|
34365
|
+
if (hasBattery && dev.batteryLevel === undefined) {
|
|
34366
|
+
dev.batteryLevel = 100;
|
|
34367
|
+
}
|
|
34359
34368
|
}
|
|
34360
34369
|
// 4) Rimuovi quelli spariti
|
|
34361
34370
|
const announced = new Set(manifests.map(m => m.nativeId));
|
|
@@ -34408,7 +34417,7 @@ class ParadoxMqttSecuritySystem extends sdk_1.ScryptedDeviceBase {
|
|
|
34408
34417
|
}
|
|
34409
34418
|
return Array.from(subs);
|
|
34410
34419
|
}
|
|
34411
|
-
async connectMqtt(
|
|
34420
|
+
async connectMqtt(_reconnect = false) {
|
|
34412
34421
|
const subs = this.collectAllSubscriptions();
|
|
34413
34422
|
if (!subs.length && !this.storage.getItem('topicSetTarget')) {
|
|
34414
34423
|
this.console.warn('Configura almeno un topic nelle impostazioni.');
|
package/dist/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED