@rfranzoi/scrypted-mqtt-securitysystem 1.0.13 → 1.0.15
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 +35 -28
- package/dist/plugin.zip +0 -0
- package/package.json +1 -1
package/dist/main.nodejs.js
CHANGED
|
@@ -34087,7 +34087,7 @@ const DEFAULT_OUTGOING = {
|
|
|
34087
34087
|
[sdk_1.SecuritySystemMode.NightArmed]: 'arm_night',
|
|
34088
34088
|
};
|
|
34089
34089
|
/** Common incoming synonyms → SecuritySystemMode
|
|
34090
|
-
* (
|
|
34090
|
+
* (transitori non alterano la modalità corrente) */
|
|
34091
34091
|
function payloadToMode(payload) {
|
|
34092
34092
|
if (payload == null)
|
|
34093
34093
|
return;
|
|
@@ -34101,7 +34101,7 @@ function payloadToMode(payload) {
|
|
|
34101
34101
|
return sdk_1.SecuritySystemMode.AwayArmed;
|
|
34102
34102
|
if (['arm_night', 'night', 'armed_night', 'sleep', 'arm_sleep', 'armed_sleep'].includes(p))
|
|
34103
34103
|
return sdk_1.SecuritySystemMode.NightArmed;
|
|
34104
|
-
//
|
|
34104
|
+
// transitori: non cambiano il mode
|
|
34105
34105
|
if (['entry_delay', 'exit_delay', 'pending', 'arming', 'disarming'].includes(p))
|
|
34106
34106
|
return undefined;
|
|
34107
34107
|
return undefined;
|
|
@@ -34130,18 +34130,21 @@ class ParadoxMqttSecuritySystem extends sdk_1.ScryptedDeviceBase {
|
|
|
34130
34130
|
// Connect on start
|
|
34131
34131
|
this.connectMqtt().catch(e => this.console.error('MQTT connect error:', e));
|
|
34132
34132
|
// chiusura pulita del client MQTT ai reload/stop del plugin
|
|
34133
|
-
|
|
34134
|
-
|
|
34135
|
-
|
|
34136
|
-
|
|
34137
|
-
|
|
34138
|
-
|
|
34139
|
-
|
|
34140
|
-
|
|
34141
|
-
|
|
34142
|
-
|
|
34133
|
+
try {
|
|
34134
|
+
process.once('SIGTERM', () => { try {
|
|
34135
|
+
this.client?.end(true);
|
|
34136
|
+
}
|
|
34137
|
+
catch { } });
|
|
34138
|
+
process.once('SIGINT', () => { try {
|
|
34139
|
+
this.client?.end(true);
|
|
34140
|
+
}
|
|
34141
|
+
catch { } });
|
|
34142
|
+
process.on('exit', () => { try {
|
|
34143
|
+
this.client?.end(true);
|
|
34144
|
+
}
|
|
34145
|
+
catch { } });
|
|
34143
34146
|
}
|
|
34144
|
-
catch { }
|
|
34147
|
+
catch { }
|
|
34145
34148
|
}
|
|
34146
34149
|
// --- Settings UI ---
|
|
34147
34150
|
async getSettings() {
|
|
@@ -34191,12 +34194,11 @@ class ParadoxMqttSecuritySystem extends sdk_1.ScryptedDeviceBase {
|
|
|
34191
34194
|
return { url, opts };
|
|
34192
34195
|
}
|
|
34193
34196
|
async connectMqtt(reconnect = false) {
|
|
34194
|
-
const
|
|
34195
|
-
|
|
34196
|
-
|
|
34197
|
-
|
|
34198
|
-
|
|
34199
|
-
].filter(Boolean);
|
|
34197
|
+
const tTarget = this.storage.getItem('topicGetTarget') || '';
|
|
34198
|
+
const tCurrent = this.storage.getItem('topicGetCurrent') || '';
|
|
34199
|
+
const tTamper = this.storage.getItem('topicTamper') || '';
|
|
34200
|
+
const tOnline = this.storage.getItem('topicOnline') || '';
|
|
34201
|
+
const subs = [tTarget, tCurrent, tTamper, tOnline].filter(Boolean);
|
|
34200
34202
|
if (!subs.length && !this.storage.getItem('topicSetTarget')) {
|
|
34201
34203
|
this.console.warn('Configura almeno un topic nelle impostazioni.');
|
|
34202
34204
|
}
|
|
@@ -34228,7 +34230,7 @@ class ParadoxMqttSecuritySystem extends sdk_1.ScryptedDeviceBase {
|
|
|
34228
34230
|
try {
|
|
34229
34231
|
const p = payload?.toString() ?? '';
|
|
34230
34232
|
// Online
|
|
34231
|
-
if (topic ===
|
|
34233
|
+
if (topic === tOnline) {
|
|
34232
34234
|
if (truthy(p) || p.toLowerCase() === 'online')
|
|
34233
34235
|
this.online = true;
|
|
34234
34236
|
if (falsy(p) || p.toLowerCase() === 'offline')
|
|
@@ -34236,7 +34238,7 @@ class ParadoxMqttSecuritySystem extends sdk_1.ScryptedDeviceBase {
|
|
|
34236
34238
|
return;
|
|
34237
34239
|
}
|
|
34238
34240
|
// Tamper
|
|
34239
|
-
if (topic ===
|
|
34241
|
+
if (topic === tTamper) {
|
|
34240
34242
|
const np = normalize(p);
|
|
34241
34243
|
if (truthy(np) || ['tamper', 'intrusion', 'cover', 'motion', 'magnetic'].includes(np)) {
|
|
34242
34244
|
this.tampered = ['cover', 'intrusion', 'motion', 'magnetic'].find(x => x === np) || true;
|
|
@@ -34246,8 +34248,8 @@ class ParadoxMqttSecuritySystem extends sdk_1.ScryptedDeviceBase {
|
|
|
34246
34248
|
}
|
|
34247
34249
|
return;
|
|
34248
34250
|
}
|
|
34249
|
-
//
|
|
34250
|
-
if (
|
|
34251
|
+
// CURRENT state → aggiorna il mode mostrato
|
|
34252
|
+
if (topic === tCurrent) {
|
|
34251
34253
|
const mode = payloadToMode(payload);
|
|
34252
34254
|
const isAlarm = ['alarm', 'triggered'].includes(normalize(p));
|
|
34253
34255
|
const current = this.securitySystemState || { mode: sdk_1.SecuritySystemMode.Disarmed };
|
|
@@ -34264,6 +34266,12 @@ class ParadoxMqttSecuritySystem extends sdk_1.ScryptedDeviceBase {
|
|
|
34264
34266
|
this.securitySystemState = newState;
|
|
34265
34267
|
return;
|
|
34266
34268
|
}
|
|
34269
|
+
// TARGET state → NON cambia il mode; lo memorizziamo solo come pending
|
|
34270
|
+
if (topic === tTarget) {
|
|
34271
|
+
this.pendingTarget = payloadToMode(payload);
|
|
34272
|
+
this.console.log('Target state reported:', p, '->', this.pendingTarget);
|
|
34273
|
+
return;
|
|
34274
|
+
}
|
|
34267
34275
|
}
|
|
34268
34276
|
catch (e) {
|
|
34269
34277
|
this.console.error('MQTT message handler error', e);
|
|
@@ -34288,17 +34296,16 @@ class ParadoxMqttSecuritySystem extends sdk_1.ScryptedDeviceBase {
|
|
|
34288
34296
|
async armSecuritySystem(mode) {
|
|
34289
34297
|
const payload = this.getOutgoing(mode);
|
|
34290
34298
|
this.console.log('armSecuritySystem', mode, '->', payload);
|
|
34299
|
+
this.pendingTarget = mode; // memorizza target, ma NON cambiare il current
|
|
34291
34300
|
this.publishSetTarget(payload);
|
|
34292
|
-
//
|
|
34293
|
-
const st = this.securitySystemState || { mode: sdk_1.SecuritySystemMode.Disarmed };
|
|
34294
|
-
this.securitySystemState = { ...st, mode, triggered: false };
|
|
34301
|
+
// niente update ottimistico: HomeKit vedrà Target ≠ Current e mostrerà "Arming..."
|
|
34295
34302
|
}
|
|
34296
34303
|
async disarmSecuritySystem() {
|
|
34297
34304
|
const payload = this.getOutgoing(sdk_1.SecuritySystemMode.Disarmed);
|
|
34298
34305
|
this.console.log('disarmSecuritySystem ->', payload);
|
|
34306
|
+
this.pendingTarget = sdk_1.SecuritySystemMode.Disarmed;
|
|
34299
34307
|
this.publishSetTarget(payload);
|
|
34300
|
-
|
|
34301
|
-
this.securitySystemState = { ...st, mode: sdk_1.SecuritySystemMode.Disarmed, triggered: false };
|
|
34308
|
+
// niente update ottimistico: aspetta il feedback CURRENT
|
|
34302
34309
|
}
|
|
34303
34310
|
getOutgoing(mode) {
|
|
34304
34311
|
const map = {
|
package/dist/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED