NEWS
Bei scharfschalten der Alarmanlage
-
Hallo zusammen
steuere damit grad die Fenster- und Bewegungsmelder-Sensoren an. Wie kann ich das Script so gestalten, das wenn ich die Alarmanlage aktiviere und das Fenster ist noch offen, nicht der Alarm ausgelöst wird, sondern ich erstmal einen Benachrichtigung bekomme, das es noch offen ist. Wenn das Schlafzimmerfenster noch offen ist, sollte die Alarmanlage deaktivieren.
Das Skript, das ich geschrieben habe, funktioniert aber nur beim ersten Mal, beschwert sich dann aber beim zweiten mal.
kann jemand mir helfen
on({id: "fensterid", change: 'any'}, function (obj) { log("value: " + obj.state.val) switch (obj.state.val) { case true : setStateDelayed("snips.0.devices.default.send.text", 'Die fenster ist nocht offen '); setStateDelayed('javascript.0.scriptEnabled.Alarmanlage_.Alarm_LED', true); setStateDelayed('javascript.0.scriptEnabled.Alarmanlage_.Alarm_code_an', true); setStateDelayed('javascript.0.scriptEnabled.Alarmanlage_.Alarm_code_aus', false); break; case false : setStateDelayed("snips.0.devices.default.send.text", 'aktivieren'); setStateDelayed('javascript.0.scriptEnabled.Alarmanlage_.Alarm_code_aus', true); setStateDelayed('javascript.0.scriptEnabled.snips.Tür_Say', false); break; }});
log date
10:50:58.319 info javascript.0 script.js.snips.Tür_Say: registered 2 subscriptions and 0 schedules 10:50:58.320 info javascript.0 script.js.snips.Tür_Say: value: false 10:50:58.320 info javascript.0 script.js.snips.Tür_Say: value: false 10:50:58.356 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:58.383 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:58.417 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:58.472 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:58.601 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:58.636 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:58.708 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:58.745 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:58.793 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:58.823 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:58.852 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:58.901 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:58.931 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:58.959 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:58.992 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.028 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.057 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.088 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.121 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.150 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.174 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.211 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.235 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.260 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.284 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.311 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.333 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.368 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.391 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.427 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.449 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.475 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.497 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.522 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.549 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.574 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.598 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.623 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.647 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.672 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.696 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.720 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.744 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.770 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.793 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.816 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.840 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.866 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.887 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.911 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.937 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.965 info javascript.0 Stop script script.js.snips.Tür_Say 10:50:59.993 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.024 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.056 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.081 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.104 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.126 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.151 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.175 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.199 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.225 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.246 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.271 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.297 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.323 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.347 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.505 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.582 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.610 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.631 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.652 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.676 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.700 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.724 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.748 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.772 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.797 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.829 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.857 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.912 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:00.985 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.009 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.034 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.057 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.083 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.104 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.133 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.156 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.180 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.205 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.223 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.238 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.253 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.268 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.283 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.299 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.314 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.329 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.344 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.359 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.422 info javascript.0 Stop script script.js.snips.Tür_Say 10:51:01.437 info javascript.0 Stop script script.js.snips.Tür_Say 10:52:38.075 info javascript.0 Stop script script.js.snips.Tür_Say
-
@Tolas-Mariwan sagte:
on({id: "fensterid", change: 'any'}, function (obj) {
Was soll das für eine Datenpunkt-ID sein ?
Weshalb change: 'any' ?Keine eigenen Datenpunkte unter 'javascript.0.scriptEnabled' anlegen, sondern direkt unter javascript.0 !!
Weshalb setStateDelayed(), wenn keine Verzögerung angegeben ist ?setStateDelayed('javascript.0.scriptEnabled.snips.Tür_Say', false);
stoppt das Skript.
-
@Tolas-Mariwan sagte:
wenn ich die Alarmanlage aktiviere und das Fenster ist noch offen, nicht der Alarm ausgelöst wird, sondern ich erstmal einen Benachrichtigung bekomme, das es noch offen ist. Wenn das Schlafzimmerfenster noch offen ist, sollte die Alarmanlage deaktivieren.
Wenn das Skript auf "Alarmanlage aktivieren" reagieren soll, muss dies auch der Trigger sein.
const idAktiv = '...'; const idFenster = '...'; // mind. 1 Fenster ist offen oder Anzahl offener Fenster const idMsg = 'snips.0.devices.default.send.text'; on({id: idAktiv, change: 'ne', val: true}, function(dp) { // Alarm wird aktiviert if(getState(idFenster).val) { setState(idMsg, 'Mindestens ein Fenster ist offen '); setState(dp.id, false); // Alarm wird deaktiviert } else setState(idMsg, 'Alarm aktiviert'); });
-
Ich danke dir @paul53
Das hat geholfen.
habe es jetzt folgend so gelöst.var Offene_Fenster; on({id: "Alarmanlage_.Alarm_code_an", change: "ne"}, function (obj) { var value = obj.state.val; var oldValue = obj.oldState.val; if (getState("Alarmanlage_.Alarm_code_an").val == true) { Offene_Fenster = []; if (getState("mihome.0.devices.magnet_15ZTT000236fd23.state").val == true) { Offene_Fenster.push('Das große Schlafzimmerfenster'); log("value: " + obj.state.val) } if (getState("mihome.0.devices.magnet_158d236fd23.state").val == true) { Offene_Fenster.push('Das kleine Schlafzimmerfenster'); log("value: " + obj.state.val+ Offene_Fenster) } if (getState("mihome.0.devices.magnet_158d000236fe97.state").val == true) { Offene_Fenster.push('Das Küchenfenster'); } if (getState("hm-rpc.0.OEQ0423676.1.STATE").val == true) { Offene_Fenster.push('Die Balkontür'); } if (getState("hm-rpc.0.OEQ0425806.1.STATE").val == true) { Offene_Fenster.push('Die Wohnungstür'); } if (getState("mihome.0.devices.magnet_158d000236fd23.state").val == true) { Offene_Fenster.push('Die Kellertür'); } if (getState("mihome.0.devices.magnet_158d0002048400.state").val == true) { Offene_Fenster.push('Das Gefrierfach'); } if (getState("hm-rpc.0.NEQ1510598.1.STATE").val == true) { Offene_Fenster.push('die Haustür ist nicht abgeschlossen'); } if (getState("Alarmanlage_an").val == false) { Offene_Fenster.push('und Die Alarmanlage ist ausgeschalten'); } if (!Offene_Fenster.length) { setState("snips.0.devices.default.send.text", ('Es ist alles gesichert')); setState("Alarmanlage_.Alarm_code_aus", true); setState("Alarmanlage_.Alarm_code_an", false); setState("Alarmanlage_.Check_sensor", false); setState("Alarmanlage_.Tur1", true); } else { setState("snips.0.devices.default.send.text", (['Die folgenden Türen und Fenster sind offen und zwar',Offene_Fenster,'.'].join(''))); setState("Alarmanlage_.Check_sensor", false); } } });