@rfranzoi/scrypted-mqtt-securitysystem 1.0.52 → 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 +82 -26
- 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 {
|
package/dist/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED