Hallo @De kat,
vielen Dank für den Link.
Da brauch ich mal 'ne ruhige Minute für.
Vielleicht kannst Du meinen Code mal bei Dir testen ?
Danke
Patrick
Ergänzung (11:00): Debug deaktiviert, Script auf dem 2ten Plug verwendet, größere Last.
Jetzt geht es auf beiden mit geringer Verzögerung, welche dem Timer geschuldet sein dürfte.
Ich versteh es nicht mehr (kopfschütteln).
Hauptsache es funzt
Code
// 25.11.2023
//
// This script is monitoring the consumption of this plug and switching an 2nd plug on/off
//
// Configuration script:
let CONFIG = {
Local: {
minUsage: 0.1, //consumption 0.1W
active: 'on',
stop: 'off',
delayTms: 500 //millisecond (=0.5 Minuten)
},
Remote: {
ip: '192.168.178.100',
relay: '0',
remote_status: 'off'
}
};
function fkt_switch_remote(command) {
if (command != CONFIG.Remote.remote_status) {
CONFIG.Remote.remote_status = command;
Shelly.call(
"http.get",
{ url: 'http://' + CONFIG.Remote.ip + '/relay/' + CONFIG.Remote.relay + '?turn=' + command },
function (response, error_code, error_message, ud) {
//print(JSON.stringify(response));
},
null
);
}
//print("Switch comand: ", command);
}
function fkt_get_power() {
alertTimer = Timer.set(CONFIG.Local.delayTms,
true,
function () {
Shelly.call(
"switch.getStatus",
{ id: 0 },
function (res, error_code, error_msg, ud) {
if (res.apower > CONFIG.Local.minUsage) {
fkt_switch_remote(CONFIG.Local.active);
}
else {
fkt_switch_remote(CONFIG.Local.stop);
}
},
null
);
},
null
);
}
fkt_get_power();
Alles anzeigen