89new: Du wolltest ja den Shelly Push Service nutzen. Wie in #18 und #20 geschrieben, auch das funktioniert. Schön ist meine Lösung sicher nicht, ich erkläre hier trotzdem, wie ich es gemacht habe. Diesmal nutze ich einen PlusPlugS, den ich mit der Benachrichtigung auch ausschalte.
Zur Vorgehensweise: Du erstellst eine zeitgesteuerte Szene, die dir die Benachrichtigung schickt. Als Zeitpunkt habe ich diesmal einen Zeitpunkt in der Vergangenheit gewählt, da man jetzt nur noch 10 Jahre in die Zukunft kann. Von dieser Szene brauchst du die Szenen-ID (kopieren und in einem Texteditor einfügen).
Weiterhin brauchst du deinen Cloud-Server und deinen Authorisierungsschlüssel (beides ebenfalls kopieren). Ich hoffe, du weißt, wo du diese Infos findest, sonst beschreibe ich es auf Wunsch auch gerne.
Im folgenden Script ersetzt du die Platzhalter durch die 3 soeben gewonnenen Informationen, am besten auch alles offline in einem Texteditor, dann kopierst du alles und klebst es als neues Script ein. Meine Zeitspanne ist relativ kurz gewählt, nach einer Minute mit geringer Leistung wird die Szene getriggert und der PlusPlugS ausgeschaltet. Die Zeiten und Intervalle kannst du aber nach eigenem Bedarf anpassen.
/**
* @copyright shelly-tools contributors
* @license GNU Affero General Public License (https://www.gnu.org/licenses/agpl-3.0.de.html)
* @authors https://github.com/shelly-tools/shelly-script-examples/graphs/contributors
*
* This script is intended to measure power consumption from the local device, e.g. a Shelly Plus 1PM,
* and send a signal push notification once the power consumption stops for a given time period.
* the idea behind is to monitor a washing machine or dryer and send a notification once the appliance
* has finished.
*/
// CONFIG START
// your cloud server
let cloud = 'https://shelly-xx-eu.shelly.cloud';
// your Shelly auth_key
let auth_key = 'Ein_ellenlanger_Schluessel_1234567890ABCDEFGHIJKLMNOPQRSTUVWabcdefghijk';
// your scene ID
let scene_ID = 'xxxxxxxxxxxxxxxxx';
// the number of consecutive times the check will run until the appliance is considered as finished power consumption has to be below "EndUsage"
let timesInactive = 6; // in steps of 10 seconds
// Startusage .. above this value the appliance is considered as "started"..
// Endusage below this value and timesInactive is reached the appliance is considered as finished.
let startUsage = 100; // Watts
let endUsage = 2; // Watts
// CONFIG END
// Do not change code below this line!
let countInactive = 0;
let alertTimer = null;
let active = false;
let stopped = false;
function startMonitor() {
alertTimer = Timer.set(10 * 1000, //changed to 10 seconds
true,
function () {
Shelly.call(
"switch.getStatus",
{ id: 0 },
function (res, error_code, error_msg, ud) {
if (res.apower > startUsage) {
countInactive = 0;
activate();
}
//print('10 seconds test started...');
print ('10 seconds test started, Power= ' + JSON.stringify(res.apower) + ' W');
if (active) {
isReady(res.apower);
}
},
null
);
},
null
);
}
function activate() {
if (active === false) {
active = true;
print('appliance started');
}
}
function isReady(usage) {
if (active && usage < endUsage) {
countInactive = countInactive + 1;
print ('CountInactive= ' + JSON.stringify(countInactive));
}
if (active && countInactive > timesInactive) {
countInactive = 0;
active = false;
sendMessage();
PlugOFF();
print('appliance finished');
}
}
function sendMessage() {
Shelly.call(
"http.get", {
url: cloud + '/scene/manual_run&id=' + scene_ID + '&auth_key=' + auth_key
},
function (response, error_code, error_message, ud) {
print(JSON.stringify(response));
},
null
);
}
function PlugOFF() {
Shelly.call(
"http.get", {
url: 'http://127.0.0.1/rpc/Switch.Set?id=0&on=false'
},
);
};
startMonitor();
Alles anzeigen