Trivial question regarding device capability "units"

In this device should I be able to use °C or must I use only C? And same for °F

Or is there a method to define the units without typing in the °C ? I realize I can use a variable but I was thinking there maybe a way to "select" the units value.

image

Similarly:
For RH is are the units a "default" with no entry in the sendevent map?

image

I always send the °C or °F as the units don’t set to a default if omitted.

If I add the ° character I get the error ....

unexpected char: 0xB0 @ line 35, column 70

Are you sending it as a string, i.e.

sendEvent(name:”temperature”, value:32, unit:”°C”)

Conventionally, the driver author will choose send the events using whatever unit is specified in the hub's location preferences. This can be retrieved using the getTemperatureScale() method documented here: Common Methods Object - Hubitat Documentation

That being said, you can use whatever units you want; I've seen some drivers offer a preference here. I just think it makes sense to follow the convention of using the hub units. :smiley:

For the other part of the question, I don't believe any units are sent as part of the event--for any attribute--unless you do so yourself. But along the same lines, I'm not aware of many (any?) apps that actually use these units, and they are not nearly as easy as the attribute value to get after the fact if you didn't capture the event as it happened.

1 Like

Thank you.
I have a unique situation here. The data (temperature and RH) is coming from a sensor through an Arduino to a cc2530 Zigbee and is received as a string of Hex. At this point I am more interested in learning the sendevent command with the intent of trying to use it "properly"

I use:

sendEvent(name: 'coolingSetpoint', value: temp as Integer, unit:"°${location.temperatureScale}")

or variations on the theme. That will set units to degree symbol + the C or F set in the Hub Details page of the Hub.

3 Likes