SmartThings Community

Zigbee Temp/Humidity Sensor Questions: how to display non-truncated value?

I am developing a Zigbee based Temp/Humidity (and pressure) sensor and have gotten to the point of wanting to get it playing nice in environments such as ST. I currently have two versions of a device handler that function to different extents and am needing a little help understanding what I am doing wrong.

  1. How exactly does ST handle humidity values from a Zigbee (or any) sensor? Based on the log, ST seems to only care about the integer part of the value sent to the hub. For instance, the humidity measured value attribute is set to 4258 (42.58 %rh). When ST reads this attribute however all that is logged is 42. It does seem like some rounding is happening but I am unable to manipulate the humidity value as a decimal.

  2. I would like to be able to view the values of temperature and humidity with their decimal portion. The new ST app shows this in the graph that is part of the temperature and humidity tile but I think it would be nice to see this as the value as well. After finding an implementation of this created by another user, I have temperature showing a decimal in the old ST app but it completely breaks the new ST app, showing no tiles. Is it possible for the new ST app to support decimal/float values or am I out of luck?

  3. Is there any reason an attribute would be reported twice on an update in value? I have randomly begun seeing cases where the temperature value, when reported, creates two log entries back to back and I am unsure why. I may have to use a sniffer to check the zigbee traffic but thought it might be a fluke. This double reporting does not always happen but does often enough to be a concern if I am actually reporting multiple times but the same value from the sensor.

The following gist has both versions of my DTH. _V1 is the version that works best but is not trying to show a decimal in the app. A log has also been included to show how humidity values are not coming across the same way as my temperature values.
DTH Gist

Thanks for your help,

1 Like

You can do whatever you want at the reading of the value in your DTH to convert it to a value you want to display, as a float for instance before sending the event to the tile. You can check my code here

Example: I read a string and convert it to a float to be displayed.

The tile is defined:

standardTile(“humidity”, “device.humidity”, width: 2, height: 2) {

        state "default", label: '${currentValue}%', 

The event sends the value like this:

def humid_float =[1].td[5].text()

events << createEvent(name: “humidity”, value: humid_float.toString().format(java.util.Locale.US,"%.1f", humid_float.toFloat()))

I have a device that shows in both classic app and new app. You can check the code here
But indeed the new app doesn’t show decimals and round up in the gauge.

I see in your code you use a valuetile rather than a standardtile. Maybe look around that?

Do you have a picture of your log? Are you seeing 2 times a log.debug output? if so suggest you debug the logs by adding a counter so you can discriminate your log actually called twice or a logger glitch (it is not free of it…).


I have included an image of my log. I have not had a chance to add a counter to the log yet but will probably try to tackle that this weekend. I will also have to try to figure out why the humidity is always logged as an integer rather than the full value. It looks like it may be getting rounded behind the scenes before it is logged.

Thanks for sharing your code, I am sure it will be helpful.

1 Like