Help with a line of code in a DTH I can't figure out

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?

great update! I only knew that O/C reports disappeared at some unspecified low voltage. Even all reports may stop 66-77% on the standard DTH.

Sorry I don’t have specific notes on your questions. This sensor (specific to gen2 using coincell CR2045) hardware reliability may not be worth your effort.

I hear you there. I have retired 3 to monitoring refrigerator and freezer temps. One is being powered by an external pack of AAs beacue the battery tab broke off during a battery change. I should retire the remainig 3 on doors at some point.