Hi,
ich habe einen Shelly Pro 3 gekauft, um meine zwei Zirkulationspumpen damit anzusteuern. Für die drei Input-Switches habe ich drei Programme erstellt: Normal, Party, Urlaub. Jedes hat einen eigenen Zeitplan, der mit den Detached Inputs ein- oder ausgeschaltet wird.
Was mich interessieren würde: Wie könnte ich in der App in irgendeiner Form darstellen, welches Programm aktuell eingeschaltet ist?
Oder soll ich die digitalen Eingänge einfach immer 'an' lassen, statt sie auszuschalten? Macht das nichts aus?
Setup:
Code
http://192.168.7.43/rpc/Input.SetConfig?id=0&config={"name":"Normal","type":"switch","enable":true,"invert":false}
http://192.168.7.43/rpc/Input.SetConfig?id=1&config={"name":"Party","type":"switch","enable":true,"invert":false}
http://192.168.7.43/rpc/Input.SetConfig?id=2&config={"name":"Urlaub","type":"switch","enable":true,"invert":false}
http://192.168.7.43/rpc/Switch.SetConfig?id=0&config={"name":"Zirko 1","in_mode":"detached","initial_state":"off"}
http://192.168.7.43/rpc/Switch.SetConfig?id=1&config={"name":"Zirko 2","in_mode":"detached","initial_state":"off"}
http://192.168.7.43/rpc/Switch.SetConfig?id=2&config={"name":"Zirko 3","in_mode":"detached","initial_state":"off"}
http://192.168.7.43/rpc/Schedule.DeleteAll
http://192.168.7.43/rpc/Schedule.Create?timespec="0 0,30 6-22 * * *"&calls=[{"method": "switch.set","params": {"on": true,"toggle_after": 300,"id": 0}},{"method": "switch.set","params": {"on": true,"toggle_after": 300,"id": 1}}]
http://192.168.7.43/rpc/Schedule.Create?timespec="0 0,30 * * * *"&calls=[{"method": "switch.set","params": {"on": true,"toggle_after": 300,"id": 0}},{"method": "switch.set","params": {"on": true,"toggle_after": 300,"id": 1}}]
http://192.168.7.43/rpc/Schedule.Create?timespec="0 0 10 * * *"&calls=[{"method": "switch.set","params": {"on": true,"toggle_after": 300,"id": 0}},{"method": "switch.set","params": {"on": true,"toggle_after": 300,"id": 1}}]
http://192.168.7.43/rpc/Schedule.Update?id=0&enable=true
http://192.168.7.43/rpc/Schedule.Update?id=1&enable=false
http://192.168.7.43/rpc/Schedule.Update?id=2&enable=false
Alles anzeigen
script:
Code
var htimer0
var htimer1
var htimer2
Shelly.addEventHandler(function(e) {
if (e.component === "switch:0") {
if ((e.info.event === "toggle") && (e.info.state === true)) {
Timer.clear(htimer0);
htimer0 = Timer.set(100, false, turnOff0);
Shelly.call("Schedule.Update",{"id": 1,"enable": true});
Shelly.call("Schedule.Update",{"id": 2,"enable": false});
Shelly.call("Schedule.Update",{"id": 3,"enable": false});
}
}
else if (e.component === "switch:1") {
if ((e.info.event === "toggle") && (e.info.state === true)) {
Timer.clear(htimer1);
htimer1 = Timer.set(100, false, turnOff1);
Shelly.call("Schedule.Update",{"id": 1,"enable": false});
Shelly.call("Schedule.Update",{"id": 2,"enable": true});
Shelly.call("Schedule.Update",{"id": 3,"enable": false});
}
}
else if (e.component === "switch:2") {
if ((e.info.event === "toggle") && (e.info.state === true)) {
Timer.clear(htimer2);
htimer2 = Timer.set(100, false, turnOff2);
Shelly.call("Schedule.Update",{"id": 1,"enable": false});
Shelly.call("Schedule.Update",{"id": 2,"enable": false});
Shelly.call("Schedule.Update",{"id": 3,"enable": true});
}
}
});
function turnOff0() {
Shelly.call("Switch.set", {'id': 0, 'on': false});
};
function turnOff1() {
Shelly.call("Switch.set", {'id': 1, 'on': false});
};
function turnOff2() {
Shelly.call("Switch.set", {'id': 2, 'on': false});
};
Alles anzeigen