@rfranzoi/scrypted-mqtt-securitysystem 1.0.50 → 1.0.54
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 +84 -28
- package/dist/plugin.zip +0 -0
- package/package.json +1 -1
package/dist/main.nodejs.js
CHANGED
|
@@ -34139,38 +34139,94 @@ class BaseMqttSensor extends sdk_1.ScryptedDeviceBase {
|
|
|
34139
34139
|
handleMqtt(topic, payload) {
|
|
34140
34140
|
const raw = payload?.toString() ?? '';
|
|
34141
34141
|
const np = normalize(raw);
|
|
34142
|
-
//
|
|
34143
|
-
if (topic === this.
|
|
34144
|
-
|
|
34145
|
-
|
|
34146
|
-
|
|
34147
|
-
this.
|
|
34148
|
-
|
|
34149
|
-
|
|
34150
|
-
|
|
34151
|
-
|
|
34152
|
-
|
|
34153
|
-
|
|
34142
|
+
// CONTACT
|
|
34143
|
+
if (topic === this.topics.contact) {
|
|
34144
|
+
const open = truthy(np) || np === 'open';
|
|
34145
|
+
this.contact = open;
|
|
34146
|
+
try {
|
|
34147
|
+
this.onDeviceEvent(sdk_1.ScryptedInterface.BinarySensor, open);
|
|
34148
|
+
}
|
|
34149
|
+
catch { }
|
|
34150
|
+
return;
|
|
34151
|
+
}
|
|
34152
|
+
// MOTION
|
|
34153
|
+
if (topic === this.topics.motion) {
|
|
34154
|
+
const motion = truthy(np) || np === 'motion';
|
|
34155
|
+
this.motionDetected = motion;
|
|
34156
|
+
try {
|
|
34157
|
+
this.onDeviceEvent(sdk_1.ScryptedInterface.MotionSensor, motion);
|
|
34158
|
+
}
|
|
34159
|
+
catch { }
|
|
34160
|
+
return;
|
|
34161
|
+
}
|
|
34162
|
+
// OCCUPANCY
|
|
34163
|
+
if (topic === this.topics.occupancy) {
|
|
34164
|
+
const occ = truthy(np) || np === 'occupied';
|
|
34165
|
+
this.occupied = occ;
|
|
34166
|
+
try {
|
|
34167
|
+
this.onDeviceEvent(sdk_1.ScryptedInterface.OccupancySensor, occ);
|
|
34168
|
+
}
|
|
34169
|
+
catch { }
|
|
34170
|
+
return;
|
|
34171
|
+
}
|
|
34172
|
+
// TAMPER
|
|
34173
|
+
if (topic === this.topics.tamper) {
|
|
34174
|
+
if (truthy(np) || ['tamper', 'intrusion', 'cover'].includes(np)) {
|
|
34175
|
+
const val = ['cover', 'intrusion'].find(x => x === np) || true;
|
|
34176
|
+
this.tampered = val;
|
|
34177
|
+
try {
|
|
34178
|
+
this.onDeviceEvent(sdk_1.ScryptedInterface.TamperSensor, val);
|
|
34179
|
+
}
|
|
34180
|
+
catch { }
|
|
34154
34181
|
}
|
|
34155
34182
|
else if (falsy(np)) {
|
|
34156
|
-
this.
|
|
34183
|
+
this.tampered = false;
|
|
34184
|
+
try {
|
|
34185
|
+
this.onDeviceEvent(sdk_1.ScryptedInterface.TamperSensor, false);
|
|
34186
|
+
}
|
|
34187
|
+
catch { }
|
|
34157
34188
|
}
|
|
34189
|
+
return;
|
|
34190
|
+
}
|
|
34191
|
+
// ONLINE
|
|
34192
|
+
if (topic === this.topics.online) {
|
|
34193
|
+
const online = truthy(np) || np === 'online';
|
|
34194
|
+
this.online = online;
|
|
34195
|
+
try {
|
|
34196
|
+
this.onDeviceEvent(sdk_1.ScryptedInterface.Online, online);
|
|
34197
|
+
}
|
|
34198
|
+
catch { }
|
|
34199
|
+
return;
|
|
34158
34200
|
}
|
|
34159
|
-
//
|
|
34160
|
-
if (topic === this.
|
|
34161
|
-
const
|
|
34162
|
-
|
|
34163
|
-
|
|
34201
|
+
// 🔋 LOW BATTERY (bool) – QUI LA PATCH
|
|
34202
|
+
if (topic === this.topics.lowBattery) {
|
|
34203
|
+
const isLow = np === 'true' ||
|
|
34204
|
+
np === '1' ||
|
|
34205
|
+
np === 'on' ||
|
|
34206
|
+
np === 'low' ||
|
|
34207
|
+
np === 'battery_low' ||
|
|
34208
|
+
truthy(np);
|
|
34209
|
+
this.lowBattery = isLow;
|
|
34210
|
+
try {
|
|
34211
|
+
// per l’interfaccia Battery di Scrypted un booleano "low" è sufficiente
|
|
34212
|
+
this.onDeviceEvent(sdk_1.ScryptedInterface.Battery, isLow);
|
|
34213
|
+
}
|
|
34214
|
+
catch { }
|
|
34215
|
+
return;
|
|
34164
34216
|
}
|
|
34165
|
-
|
|
34166
|
-
|
|
34167
|
-
|
|
34168
|
-
|
|
34169
|
-
|
|
34170
|
-
this.
|
|
34217
|
+
// 🔋 BATTERY LEVEL (0..100) – per quando userai Battery Level Topic
|
|
34218
|
+
if (topic === this.topics.batteryLevel) {
|
|
34219
|
+
const n = Number(raw);
|
|
34220
|
+
if (isFinite(n)) {
|
|
34221
|
+
const pct = Math.max(0, Math.min(100, n));
|
|
34222
|
+
this.batteryLevel = pct;
|
|
34223
|
+
try {
|
|
34224
|
+
this.onDeviceEvent(sdk_1.ScryptedInterface.Battery, { level: pct });
|
|
34225
|
+
}
|
|
34226
|
+
catch { }
|
|
34227
|
+
}
|
|
34228
|
+
return;
|
|
34171
34229
|
}
|
|
34172
|
-
// primary handled by subclasses
|
|
34173
|
-
this.handlePrimary(topic, np, raw);
|
|
34174
34230
|
}
|
|
34175
34231
|
}
|
|
34176
34232
|
class ContactMqttSensor extends BaseMqttSensor {
|
|
@@ -34330,13 +34386,13 @@ class ParadoxMqttSecuritySystem extends sdk_1.ScryptedDeviceBase {
|
|
|
34330
34386
|
{ group: 'Parsing / State tokens', key: 'currentStateValues', title: 'Accepted Current State Values (JSON array)', placeholder: '["armed_home","armed_away","armed_night","disarmed","triggered"]', value: this.storage.getItem('currentStateValues') || '["armed_home","armed_away","armed_night","disarmed","triggered"]' },
|
|
34331
34387
|
{ group: 'Parsing / State tokens', key: 'triggeredValues', title: 'Triggered tokens (JSON array)', placeholder: '["triggered","alarm"]', value: this.storage.getItem('triggeredValues') || '["triggered","alarm"]' },
|
|
34332
34388
|
// --- Publish Payloads (override) ---
|
|
34333
|
-
{ group: 'Publish Payloads (override)', key: 'payloadDisarm', title: 'Payload for Disarm', placeholder: 'disarmed', value: this.storage.getItem('payloadDisarm') || '', description: '
|
|
34389
|
+
{ group: 'Publish Payloads (override)', key: 'payloadDisarm', title: 'Payload for Disarm', placeholder: 'disarmed', value: this.storage.getItem('payloadDisarm') || '', description: 'If empty, use targetStateValues (strict ON) or the arm_*/disarm defaults (strict OFF).' },
|
|
34334
34390
|
{ group: 'Publish Payloads (override)', key: 'payloadHome', title: 'Payload for Home Armed', placeholder: 'armed_home', value: this.storage.getItem('payloadHome') || '' },
|
|
34335
34391
|
{ group: 'Publish Payloads (override)', key: 'payloadAway', title: 'Payload for Away Armed', placeholder: 'armed_away', value: this.storage.getItem('payloadAway') || '' },
|
|
34336
34392
|
{ group: 'Publish Payloads (override)', key: 'payloadNight', title: 'Payload for Night Armed', placeholder: 'armed_night', value: this.storage.getItem('payloadNight') || '' },
|
|
34337
34393
|
// --- Logging ---
|
|
34338
34394
|
{ group: 'Logging', key: 'logSensors', title: 'Log sensor state changes', type: 'boolean', value: this.storage.getItem('logSensors') === 'true' },
|
|
34339
|
-
{ group: 'Logging', key: 'logMqttAll', title: 'Log ALL MQTT messages', type: 'boolean', value: this.storage.getItem('logMqttAll') === 'true', description: '
|
|
34395
|
+
{ group: 'Logging', key: 'logMqttAll', title: 'Log ALL MQTT messages', type: 'boolean', value: this.storage.getItem('logMqttAll') === 'true', description: 'Warning: this will be very verbose.' },
|
|
34340
34396
|
];
|
|
34341
34397
|
// ---- UI Add Sensor ----
|
|
34342
34398
|
out.push({ group: 'Add Sensor', key: 'new.id', title: 'New Sensor ID', placeholder: 'porta-ingresso', value: this.storage.getItem('new.id') || '' }, { group: 'Add Sensor', key: 'new.name', title: 'Name', placeholder: 'Porta Ingresso', value: this.storage.getItem('new.name') || '' }, { group: 'Add Sensor', key: 'new.kind', title: 'Type', value: this.storage.getItem('new.kind') || 'contact', choices: ['contact', 'motion', 'occupancy'] }, { group: 'Add Sensor', key: 'new.create', title: 'Create sensor', type: 'boolean', description: 'Fill the fields above and toggle this on to create the sensor. After creation, restart this plugin to see the accessory listed below. To show it in HomeKit, restart the HomeKit plugin as well.' });
|
package/dist/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED