-
Notifications
You must be signed in to change notification settings - Fork 0
/
Battery.js
executable file
·38 lines (36 loc) · 1.28 KB
/
Battery.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function battery_check() {
var battery = getObject("enum.functions.battery").common["members"];
var output = "";
var need_to_send = false;
output += "<b> Batterieren Tauschen </b>:\n";
for (let i = 0; i < battery.length; i++) {
switch (getObject(battery[i]).common.role) {
case "thermostat":
if (getState(battery[i] + ".batteryLow").val === true) {
output += getObject(battery[i]).common.name + "\n";
need_to_send = true;
}
break;
case "indicator":
if (getState(battery[i] + ".batteryLow").val === true) {
output += getObject(battery[i]).common.name + "\n";
need_to_send = true;
}
break;
case "temp_humid":
if (getState(battery[i] + ".battery").val <= 11) {
output += "Thermometer " + getObject(battery[i]).common.name + "\n";
need_to_send = true;
}
break;
}
}
if (need_to_send === true) {
sendTo('telegram', {
user: "Arne",
text: output,
parse_mode: "HTML"
});
}
}
schedule('0 16 * * 6',battery_check);