Negative data-values not resolving correctly

I've got an issue, only on one device so suspect it must be the driver, where negative values (temperature in this case) show in, what i refer to as, "scientific notiation"
ie, value of -1.5 shows as value=0E+1 which doesnt translate when i wish to send a numeric value as a GET command. (positive values work as expected)

The device for which this happens is the Fibaro FGBS-222 Child Temperature Sensor using the driver:

Fibaro FGBS-222 Child Temperature Sensor

metadata {
	definition (name: "Fibaro FGBS-222 Child Temperature Sensor", namespace: "christi999", author: "", importUrl: "") {
		capability "Refresh"
		capability "Sensor"
		capability "Temperature Measurement"

void refresh() {

Looking at the code (and being a numbskull when it comes to driver code) does Hubitat retrieve the driver code on demand from the URL shown or is it permanently located/stored locally in the Hubitat?

1 Like

A copy is stored on the hub. The importUrl is used to do a quick re-import of the code from the source for refreshes if you want to do this manually instead of using an app like HPM.

thanks, @thebearmay , that's useful to know.
If the driver-developer updates the code might this mean i could have modified code in my hubitat, for better or worse?

You would have to do something overt to pull it to your hub, i.e. import the new code, update using HPM, etc. Nothing along those lines is automatic.

So the entire driver is here: Hubitat/Fibaro FBGS-222 Smart Implant at master · muchu999/Hubitat · GitHub

There is all sorts of stuff going on here in the Fibaro FBGS-222 Smart Implant.groovy
Calling another functions to do all sorts of conversions, etc....
Section starting at Line 423 and 465 look the same so you will need to fix both

		case [7,8,9,10,11,12,13]:
			(finalVal,units) = convertTemperature(cmd)
			finalVal = finalVal.toFloat() + settings["${"sensorOffset" + (endpoint-7).toString()}"]
			finalVal = Math.round(finalVal* 10.0)/10.0
			target?.sendEvent(name: "temperature", value: finalVal, unit: units, descriptionText:"${target} temperature is ${finalVal}${units}" )

I think the issue is probably with the toFloat, Float values are odd in Groovy especially when you start doing math with them. In my driver that deals with temperatures I use BigDecimal types.

You could try replacing the line that has the toFloat (in both sections) with this, and also comment out the rounding bit right after that.

			finalVal = "${finalVal}".toBigDecimal() + settings["${"sensorOffset" + (endpoint-7).toString()}"]
			//finalVal = Math.round(finalVal* 10.0)/10.0

Also for testing please set the "Temperature Units" setting to default.

Download the Hubitat app