Es scheint, dass Sie einen VPN- oder Proxy-Dienst verwenden. Bitte beachten Sie, dass die Nutzung eines solchen Dienstes die Funktionalität dieser Webseite einschränken kann.
Die gewünschte Schaltfunktion muss innerhalb des Shelly.call für HTTP GET eingefügt werden.
1. ist der Aufruf asynchron und kann kurz dauern, weshalb man "außerhalb" ggf. false Werte bekommt
2. wären die Variablen außerhalb nicht sichtbar
Im konkreten Kontext ist das aber wenig problematisch, weil man es am besten nur 1x täglich aufruft und falls man dann "außerhalb" der Funktion ggf. Werte vom Vortag verwendet, wäre das auch nicht sonderlich problematisch.
Das kannst du einfach als getrenntes Skript laufen lassen. Wenn in der Console unter dem Skript was ausgegeben wird -> perfekt. Wenn da "undefined" steht, gibt es kein apower für den Switch. Ich habe leider keinen Plug zum Testen zur Hand.
This is basically a suitable shelly. But I think you still have trouble understanding the right connection:
Der Inhalt kann nicht angezeigt werden, da Sie keine Berechtigung haben, diesen Inhalt zu sehen.
Legend
Terminals
Wires
I
Load circuit input terminal
L
Live wire (110-240 V~)
O
Load circuit output terminal
N
Neutral wire
SW
Switch (controlling O) input terminal
+
12/24-48V ⎓ positive wire
+12V
12 V⎓ positive terminal
GND
12/24-48V⎓ ground wire
L
Live terminal (110-240 V~)
N
Neutral terminal
+
24-48 V⎓ positive terminal
Ʇ
12/24-48V⎓ ground terminal
I and O are the dry contact - just output
You can connect SW with + as a test. Then the Shelly relay should switch -> I + O are connected. You can read out the status of SW. You can also set whether the relay should switch with SW or whether you want to trigger a different action.
so I have configured the dry contact with a twisted pair of solid copper to complete and break the circuit. So far no matter what configuration, setting, or pinout that I set will give me any "state of change" indication.
A “dry contact” is a relay - it is an output, not an input. The Shelly can switch on or off, but cannot “read”.
If you operate the Shelly with 12V or 24V, you could try connecting the reed contact to SW.
This setup is not permitted at higher operating voltages because the reed contact could then come into contact with this dangerously high voltage.
Mein Plan war eine Katzenklingel zu bauen mit einem shelly blu motion und einer shelly plus plug s.
Ich habe gerade nochmal geschaut, was du für Shellys einsetzt.
Ich befürchte, meine Idee mit dem BLU Motion einen http Aufruf zum Plug zu machen, funktioniert nicht, weil man für die volle Funktionalität der BLU Geräte Gen3 Shellys als Gateway benötigt. Dein Plus Plug ist Gen2.
Möglicherweise kann man mit etwas mehr Aufwand das ganze mit Skripting lösen, so dass man den BLU Motion via Skript ausliest, aber da kenne ich mich nicht gut genug mit aus.
Vielleicht hat jemand anderes eine Lösungsidee. Es gibt hier im Forum Nutzer mit deutlich besseren Skript-Kenntnissen als mich
Das Skript was ich oben eingefügt habe funktioniert ja auch. Aber leider läuft es nicht. Bzw es läuft nur einmal alleine an, wenn ich den plug neu starte.
Du kannst in dem Skript einen HTTP Handler einbauen (siehe im Skript ganz am Ende) und diesen aufrufen, wenn der BLU Motion Bewegung erkennt via Webhook:
Code
http://<shelly-ip>/script/1/blinken
Die 1 ist die Skript-Nummer - diese wird in der Skript-Übersicht angezeigt.
Hier das komplette Skript etwas lesbarer formatiert und mit HTTP Handler:
Code
let cycle = 0;
let maxCycles = 5;
print("Skript gestartet");
function runCycle() {
print("runCycle aufgerufen! Zyklus " + cycle);
if (cycle >= maxCycles) {
print("Alle Zyklen abgeschlossen. Plug bleibt aus.");
Shelly.call("Switch.Set", { id: 0, on: false }, function(result, error) {
if (error) {
print("Fehler beim Ausschalten nach allen Zyklen:", JSON.stringify(error));
} else {
print("Plug wurde nach allen Zyklen erfolgreich ausgeschaltet.");
}
});
return;
}
cycle++;
print("Zyklus " + cycle + ": Plug EIN");
Shelly.call("Switch.Set", { id: 0, on: true }, function(result1, error1) {
if (error1) {
print("Fehler beim Einschalten:", JSON.stringify(error1));
return;
}
print("Plug erfolgreich eingeschaltet!");
// Hier können wir den Timer besser nachvollziehen
print("3-Sekunden Timer gestartet...");
Timer.set(3000, false, function() {
print("Timer abgelaufen - Plug AUS");
Shelly.call("Switch.Set", { id: 0, on: false }, function(result2, error2) {
if (error2) {
print("Fehler beim Ausschalten:", JSON.stringify(error2));
} else {
print("Plug erfolgreich ausgeschaltet!");
}
// Bestätigung, dass der Plug ausgeschaltet wurde
print("2-Sekunden-Wartezeit für nächsten Zyklus...");
Timer.set(2000, false, function() {
print("Nächster Zyklus startet...");
runCycle(); // Starte den nächsten Zyklus
});
});
});
});
}
function httpServerHandler(request, response) {
cycle = 0;
runCycle();
response.code = 200;
response.body = "runCycle aufgerufen";
response.send();
}
HTTPServer.registerEndpoint("blinken", httpServerHandler);