[SOLVED] The "right" place to do temperature conversion?

I have what seems to be a simple question. What is the “right” place to convert a temperature from an Aeotec Multisensor 6, originally in Centigrade to Fahrenheit? I have spent about a day on this and so far, no success. Clearly I don’t understand something.

Seems to me my options are:

  1. Set the sensor to ˚F.
  2. Do the conversion in the Item
  3. Do the conversion in the Sitemap

Option #1 Set the sensor to ˚F-
Aeotec’s Engineering Sheet for the Multisensor 6 lists Property 64 (0x40) as "Set the default unit of the automatic temperature report in parameter 101-103. 1 = Celsius. 2= Fahrenheit.

Seems simple. I go to HABMin, find the Multisensor, find Property 64, set it to ‘2’, hit Save. No change. Event log still shows temperature report is in ˚C. Also, I have two of these, and one with older firmware does not support this option. So I need to figure out how to flash the firmware. Not a big deal, but perhaps I should be using Option #2 or Option #3 .

Option #2 Do the conversion in the Item
Hum. I have been using OH since 1.x, so doing the conversion in a .items file would be no problem. Since OH 2.x, I have tried to do everything in PAPERUI. Maybe I should delete the Item I created when I linked from the Thing to the Item using the PAPERUI and manually create an item for this?

Option #3 Do the conversion in the Sitemap
Well, some way to go on this. I tried simply adding [%.1f ˚F] to the sitemap label for the item. That changed the label from ˚C to ˚F, but I did not get any numerical conversion. (27.3 ˚C is now displayed as 27.3 ˚F).

Converting in the Sitemap has a downside I don’t like, which is that if I want to also use temperature-triggered rules, then I have to use ˚C in the rules, or convert there too. So to me, either setting the Multisensor to deliver in ˚F, or doing the conversion in the Item is the way to go. But I don’t know the right way to do that in 2.x.

I read the article on Units Of Measure in the Concepts section of the documentation. Interesting, but not enough information there for me to figure out how/where to apply it.

I would very much appreciate help in not only doing the conversion, but in understanding the thinking behind your suggestion.

Thanks so much in advance.


1 Like

We’d better begin with … what type of Item do you have? Is it a Number or a Number:Temperature ? Very different games.

Number:Temperature, but just in case someone is looking for just Number, maybe you can talk about both cases.

If you use this, openHAB automatically will convert it to the units you have defined in your system configuration.

To be more clear, it’s based off the locale you have configured in openHAB.

For others who come looking at this post, you set locale in PAPERUI under SYSTEM.

Okay I have changed that. Let’s see what happens. But in the meantime, I am still curious about how you modify Items that you have added with PAPERUI.

But if this works, it seems to be the answer, since I am sure locale is used to set other things in OH as well. FWIW, I had set this before in my system when I started using the ASTRO plugin. It was not set when I just checked, so don’t know what happened there.

1 Like

And you will find methods in these forums to handle this kind of “Quantity Type” in rules in these forums.
For example, you can compare your Item with say 21°C without worrying about whether your Item is in C,F or K
For display, designate what units you want and again no worries about what units are held in the Item.

FTR, it’s described here in the documentation.

I read about “Quantity Type” in the manual. But I am unclear. Since we are exchanging messages in near realtime here, know that as of right now, the BASICUI is still displaying the temperatures from my two Multisensors in ˚C, even though I just set the locale. Log shows an entry, Discovery Result with UID 'astro:moon:local' has been added, so obviously the system recognized the locale update already.

But back to your point. So I have a sensor generating Number:Temperature in ˚C. I see the updates in the event log coming in in ˚C. I want to display ˚F in the UI, and I want to use ˚F in my rules. You say,

For example, you can compare your Item with say 21°C without worrying about whether your Item is in C,F or K

How and where do I set this?

Okay - we are getting somewhere. Event Log just showed this:

Node22_Temperature changed from 20.9 ˚C to 63.5 ˚F

Out of curiousity, what would be the recommendation if this was a Number with a sensor value that can’t be changed at the source and can’t be modified by locale?

I’m guessing that Option 3 would typically make more sense than Option 2, since it retains the flexibility to act on the transformed value with a rule (even if you never do that).

Thanks - and I did read this. But the documentation says nothing about where you apply this information. Can you explain further?

He was referring to how you can use these types in a rule. Described here.

How long did you wait? The Z-wave controller probably queued this up and is waiting for the device to wake up which could be a long time, even up to a day or more. On the other hand, even if it worked, the UoM will change it to whatever it deems appropriate regardless of what is coming directly from the device.

So is the syntax [%.2f ˚F] only a formatting command (for example, used in a Sitemap changes a temperature from 27.4 ˚C to 27.4˚F) or does it actually trigger a conversion? I tried it and it seems to only do text formatting, no maths.

It should do the conversion so long as you have the item defined as Number:Temperature.

I do that here in order to get the rainfall rate into the right units. Otherwise, if I use %unit% it shows up as miles per hour, which isn’t very helpful when you’re trying to understand how hard it’s raining. :wink:

Number:Speed                WS1400IP_RainHourlyRate
                            "Rain Hourly Rate [%.2f in/h]"
                            { channel="ambientweather:ws1400ip:ws1400ip:weatherDataWs1400ip#rainHourlyRate" }

It took about 10 minutes from the time I changed the locale? Maybe 15 minutes? I woke up the multisensor since it runs on batteries in order to speed up the process.

Okay - in my case, it did not do any conversion. If I did not include the modifier, it came out as 27.4 ˚C. If I included %unit% it came out 27.4 ˚C. If I included [%.2f ˚F], it came out 27.4 ˚F. Problem solved :slight_smile: (sort of :frowning: ).

Somehow, if it was a LOT of rain, that would actually make sense??!!

1 Like