As part of above I listed a script that I was having trouble firing. Hopefully sorted. So I started looking at the actual code.
I have one real battery (sitting at about 84% and two that should never drop off 100).
I’m using this, which I thought is to cycle through the 3 batties:
g_battery.allMembers.forEach[g |
logInfo(“BatteryMonitor”,"Item " + g.name + " state: " + g.state as DecimalType)
var DecimalType currentBattery = (g.state as DecimalType)
logInfo(“BatteryMonitor”,"Item " + g.name + " state: " + currentBattery + " threshold: " + lowBatteryThreshold)
if (currentBattery < lowBatteryThreshold)
{
report = report + “Item " + g.name + " state: " + g.state as DecimalType) + " Low Battery”
logInfo(“BatteryMonitor”,“Low Battery”)
}
]
But for some reason, even though I’ve set the threshold to 90F all three post that Low Battery log message. is that g_battery.allMembers.forEach[g | not what I want for a loop?
Here’s the logging:
2017-01-10 22:01:28.627 [INFO ] [.o.model.script.BatteryMonitor] - Received Command
2017-01-10 22:01:28.687 [INFO ] [.o.model.script.BatteryMonitor] - Found some item(s) under threshold
2017-01-10 22:01:29.102 [INFO ] [.o.model.script.BatteryMonitor] - Report produced: Battery levels (Threshold:90.0):
bm1_battery: 84.3294117647
apc600_battery: 100
apc1000_battery: 100
2017-01-10 22:01:29.325 [INFO ] [.o.model.script.BatteryMonitor] - Item bm1_battery state: 84.3294117647
2017-01-10 22:01:29.331 [INFO ] [.o.model.script.BatteryMonitor] - Item bm1_battery state: 84.3294117647 threshold: 90.0
2017-01-10 22:01:29.336 [INFO ] [.o.model.script.BatteryMonitor] - Low Battery
2017-01-10 22:01:29.338 [INFO ] [.o.model.script.BatteryMonitor] - Item apc600_battery state: 100
2017-01-10 22:01:29.338 [INFO ] [.o.model.script.BatteryMonitor] - Item apc600_battery state: 100 threshold: 90.0
2017-01-10 22:01:29.339 [INFO ] [.o.model.script.BatteryMonitor] - Low Battery
2017-01-10 22:01:29.339 [INFO ] [.o.model.script.BatteryMonitor] - Item apc1000_battery state: 100
2017-01-10 22:01:29.340 [INFO ] [.o.model.script.BatteryMonitor] - Item apc1000_battery state: 100 threshold: 90.0
2017-01-10 22:01:29.340 [INFO ] [.o.model.script.BatteryMonitor] - Low Battery
2017-01-10 22:01:29.388 [INFO ] [.o.model.script.BatteryMonitor] - Message: Battery levels (Threshold:90.0):
bm1_battery: 84.3294117647
apc600_battery: 100
apc1000_battery: 100
2017-01-10 22:01:29.411 [INFO ] [g.openhab.io.net.exec.ExecUtil] - executed commandLine ‘/etc/openhab/configurations/scripts/boxcar.sh Battery levels (Threshold:90.0):
bm1_battery: 84.3294117647
apc600_battery: 100
apc1000_battery: 100’