HSM Battery Monitor bug in latest firmware - Java exception?

HSM Battery Monitor is throwing a Java exception in the latest firmware. From the error message the driver is returning a decimal level for the battery (100.0) but the Java parser is expecting something else (an integer?)

What driver are you using for this device? I guess it might actually be hard to figure out which one it was from this error, so you might need to look through all the devices you have selected for battery monitoring and see which is reporting "100.0" as the level. Start with ones that use a custom driver, since that's more likely to be an issue. It appears the battery level might be a string (text), not a number, but a battery level should be an integer and not a decimal anyway, so that driver should probably be fixed either way. HSM could probably handle this more gracefully, too, at least if the value is actually numeric, but fixing the driver is a good idea regardless.

The devices are Sonoff SNZB-03 Zigbee motion sensors, specifically using the "Zigbee - Sonoff Motion Sensor" driver from OhLa Labs, which are well respected.

Looking at the driver code I see where the handling is a BigDecimal so that could be changed. Ideally HSM would be able to handle either Int or Decimal though.

I am aware of those drivers and have used them before. Hubitat has a built-in driver for those now if you wanted to use that instead (hint if you do: temporarily switch to the "Device" driver first and run the commands to clear state and scheduled jobs), but I understand that this community driver may have other features you're looking for (e.g., "presence" for detecting a device that may have fallen off). It should be noted that the author is no longer actively using Hubitat and the drivers are unlikely to receive much future development, if that influences your choice.

I'd still probably address this in the driver either way--changing the BigDecimal to an Integer (and making sure any rounding it's doing anywhere happens properly, so I'm not saying that exact line/declaration is literally where you should make the change) should be suffficient. The docs have never been clear on this, but staff have indicated in the forums recently that most numeric values are expected to be integers (with exceptions for things like temperature, where the precision can be of real-world value). Even if HSM were modified to handle this more gracefully, you never know what another app might do. :slight_smile: (But they have been known to make modifications to handle unexpected types better recently in others apps, I think either RM or Notifications comes to mind. It's still probably best to address this on the driver side, though.)

HSM Rule is definitely looking for an integer there, not a decimal, as that's how the capability is defined. But, we've been working through places where these pop up to not choke on decimal values. This particular one will be fixed for the next release. But, since you have the source, send an integer value instead in the meantime.