I have been trouble shooting my ST SmartSense (MFG:Centralite) multi sensors since support was of no help. I have 3 test case DTHs reporting percentages, each using a differentl way. The least modified version has me scratcbing my head. Can anybody tell me it this line is correct.
def curValVolts = Integer.parseInt(device.currentState(“battery”)?.value ?: “100”) / 100.0
This is line 278 of the DTH for the Smartsense Multi Sensor. If I remove the ?: “100” to where it looks like this:
def curValVolts = Integer.parseInt(device.currentState(“battery”)?.value ) / 100.0
The Centralite sensor begins to report what looks to be correct values in the app instead of 100% all the time. I also played with the min and max voltage. Original max was 2.7 volts. Min voltage was 2.1. I changed this to 2.5 because i know at 2.5 volts the device no longer reports open/close.
I know they will all run in the cloud now, just trying to get a battery percentage to keep from having the device drop from the system without any warning.
If anyone could help explain if that original line is correct I would be greatful.
Edit: from what I understand, parseInt (string, radix) is the format. Radix is an integer between 2 and 32. If blank it will asume 10 (decimal numeral system). So correct format should be
def curValVolts = Integer.parseInt(device.currentState(“battery”)?.value , 10) / 100.0
Correct?