Multipurpose Sensor - Is reporting temp to one decimal an easy handler tweak?

I have very little experience, but I’d like my Samsung Multipurpose sensor to report temps to one decimal place.

I’m sure it has the capability, and wondered if someone can tell me if is would be potentially easy to do?

I’ve looked at the template but nothing easy stands out to me?

Thanks to anyone that can help

You can do this, but you will have to handle the temperature report in parse yourself including a conversion to the right scale if you want to. In the DTH there is a section already for handling some custom stuff to do with temperature

else if (maps[0].name == "temperature") {
		def map = maps[0]
		if (tempOffset) {
			map.value = (int) map.value + (int) tempOffset
		}
		map.descriptionText = temperatureScale == 'C' ? '{{ device.displayName }} was {{ value }}°C' : '{{ device.displayName }} was {{ value }}°F'
		map.translatable = true
	}

In your case however, you can’t use the event that is generated in maps[0] because it will already be rounded, you can use this if statement to verify it is the right message however. There are two different types of messages that can generate temperature readings. The first is a catchall or read attr description, both of which can be parsed similarly. You can use the method zigbee.parseDescriptionAsMap(description) to get back a broken down map of the fields represented by the description given. This would include a field encoding which specifies the ZCL data type of the value and a field value which has that value. In this case value should be an INT16. That is a 2 byte signed integer, but it will still be stored as a string. You will have to convert this to a numeric value using something like Integer.parseInt(value, 16) and then handle signedness by doing two’s complement (There may be a way to do this using the Short type but I’m not sure off the top of my head as Java/groovy make some lower level type size management annoying). This value will be in 100ths of a degree, so you have to divide by 100 to get degrees. Feel free to look into the zigbee ZCL specification Temperature Measurement Cluster measured value attribute for more info. The degrees will be in Celsius, so if you want Fahrenheit you will have to do that conversion.

Additionally you will have to handle the second type of temperature message that could be sent from the device to the cloud, which instead of a catchall starts with temperature: These descriptions should be in the form Temperature: <value> C and should be decimal values, and you can parse out that string as an int and convert to F if need be.

Unfortunately some of this parsing gets a little hairy which is why we try to handle it for you with zigbee.getEvent but there isn’t currently an easy way to do what you want and get a more accurate reading. We have plans in the future to make some of this easier, but as is always the case, so many things to do and so little time.

2 Likes

I suspect the reason SmartThings now reports temperatures without decimals in the mobile app is that most temperature sensors are barely accurate +/- 1°C…
So beware what you look for :

  • an accurate temperature reading ? (in the absolute sense, as compared to a very accurate thermometer)
  • a more sensitive delta temperature reading for a single sensor ? (ie. reporting small variations, independently of the accuracy of the global figure)
  • multiple comparable temperature values ? (like in multiple rooms)

My own experience, using a dozen of Fibaro FGK-101 sensors with the optional DS18B20 temperature sensor, is that relative reports of +/- 0.3°C variations are significant for a single thermometer, but aiming absolute accuracy better than +/- 0.5°C across multiple thermometers is likely unreasonable. Note that 0.5°C is about the smallest temperature variation that a human being can perceive…
Remember also that WHERE you put your thermometer in a room can easily skew the reported temperature values by 2-3°C (near the floor or ceiling, near the windows or center of the room, near a computer or TV, …).

For an example of a custom handler reporting temperatures with 0.1°C accuracy, you can look at my FGK-101 custom handler on github.