Hi,
I have several items with batteries, actual I ony have a specific view of this group (gBatteries): there I can see all battery percentages from these items.
I find some rules from other oH users, they are using the lowbatt option from items and monitor these in a “loop” over all battery-items (a switch, is “on” when item decide “my battery is low”)
Actual I don’t use this lowBatt function on the battery items, so can I also work with the % from batteries ?
Is it also possible to create a “loop” over all gBatteries -items and check the battery level /%) from these batteries and compare with a threshold and trigger an action than (like: pushover …) ?
See my rule. i put alle battery item in a group and loop one a day trough alle item and send a pushover message.
rule "Publish Battery Status"
when
Time cron "0 0 18 ? * * *"
then
val String ruleIdentifier = "Publish Battery Status"
val Integer batteryThreshold = 10 // %. This should be enough to change the battery within a few days
val StringBuilder aMessage = new StringBuilder
var Integer emptyBatteries = 0
emptyBatteries = gBatteryStatus.members.filter[ i | ((i.state instanceof DecimalType) && (i.state < batteryThreshold)) || ((i.state instanceof OnOffType) && (i.state == ON)) ].size
logInfo(ruleIdentifier, "Daily battery check found {} empty batteries to report!", emptyBatteries)
if (emptyBatteries != 0) {
aMessage.append("-> Batteriestatusreport <-\n")
gBatteryStatus.members.filter[ i | ((i.state instanceof DecimalType) && (i.state < batteryThreshold)) || ((i.state instanceof OnOffType) && (i.state == ON)) ].forEach[ aBattery |
aMessage.append(aBattery.label+"\n")
]
aMessage.append("-> Ende <-")
sendPushoverMessage(pushoverBuilder(aMessage.toString).withDevice("Disorganiser"))
logInfo(ruleIdentifier, "Information about {} empty batteries has been published!", emptyBatteries)
}
end
Is it possible to add to every low battery line also the actuall battery level?
(like: “Bath temperatur sensor: Batt=17%” (instead only: “Bath temperatur sensor”))
(I think it’s possible, but how? This syntax is very “small”, in one line )