mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-27 13:23:06 +00:00
arrival: Change voltage range for battery remaining calculation
This commit is contained in:
@@ -95,16 +95,17 @@ private handleBatteryEvent(rawValue) {
|
|||||||
]
|
]
|
||||||
|
|
||||||
def volts = rawValue / 10
|
def volts = rawValue / 10
|
||||||
if (volts > 3.5) {
|
if (volts > 0){
|
||||||
eventMap.descriptionText = "${linkText} battery has too much power (${volts} volts)."
|
def minVolts = 2.0
|
||||||
}
|
def maxVolts = 2.8
|
||||||
else if (volts > 0){
|
|
||||||
def minVolts = 2.1
|
if (volts < minVolts)
|
||||||
def maxVolts = 3.0
|
volts = minVolts
|
||||||
|
else if (volts > maxVolts)
|
||||||
|
volts = maxVolts
|
||||||
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||||
if (pct < 0)
|
|
||||||
pct = 0
|
eventMap.value = Math.round(pct * 100)
|
||||||
eventMap.value = Math.min(100, (int) pct * 100)
|
|
||||||
eventMap.descriptionText = "${linkText} battery was ${eventMap.value}%"
|
eventMap.descriptionText = "${linkText} battery was ${eventMap.value}%"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user