Simulated/Virtual Sensor Devices - Humidity & Temp Sensor (w/ decimal)?

Hi, has anyone seen any device handlers for humidity or for a temp sensor with a decimal? I’ve been looking all over but can only find the ones that Smartthings provided. I have been using the temp sensor handler SmartThings provides for both, but it’s less than ideal for humidity and I would like to see the decimal point for the temperature (in line with the rest of my sensors). I’m using these devices in Webcore to calculate the average humidity and temperature of the house every so often.

Not much to it, just report the value with a decimal point, are you facing a specific issue? To start with, does your device report decimal values?

I am sure I am missing something very simple here, but how do I do that? I am using the ‘Simulated Temperature Sensor’ device handler found in the IDE and am not seeing any options for reporting differently.

I use WebCore to set the average of 4 different sensors around the house every 20 min and use that value to set the simulated temp sensor. WebCore sets the device with a decimal but it reports as a whole number. I use the difference between the average temp and a particular sensor’s temp to identify the “hot zones” in the house and help control the A/C with the Ecobee Suite Smartapp. The app could be a little more precise if I could get the house avg temp to report with a decimal.

Thanks for the assistance! I’ve been a customer of your for a while now and use your lock app and a few of your custom device handlers.

1 Like

You’ll need to modify the DTH from:

Math.round(new BigDecimal(pct)).toString()

to

(Math.round((new BigDecimal(pct) * 100.0)/100.0).toString()

This will give you 2 decimal places, if you want 3 use 1000.0 and 100.0 in both places.

Thanks, I’ve been playing with this but no success. I believe this is for the regular temperature sensor DTH. I made the modification but can’t update the value with WebCore. Any idea how to modify the Simulated Temperature Sensor DTH to show the decimal value? Thanks

You don’t have to modify the DTH code. It accepts 2 decimal point. In webcore, go to the device and click set temperature instead of set level. There you can input a decimal variable.