Postupdate and UoM driving me crazy

I need Fahrenheit so can I simply just switch .toUnit(“°C”) to .toUnit(“°F”) ???

1 Like

Exactly… I misread your OP. But I’m confused… how are you getting Celcius? If your locale is set properly, you should be getting Fahrenheit already and just need to strip the units.

1 Like

Color me confused as well…

I have my local/regional settings set as:


image

Which should have me set to Fahrenheit. Is their another area I need to set?

1 Like

No, that should do it. Have you restarted OH since setting it?

1 Like

yup,many times and have cleared cache and tmp

1 Like

Instead of this…

Number:Temperature localCurrentTemperature "Current temperature [%.0f %unit%]" <temperature> { channel="darksky:weather-and-forecast:ead7c7a1:current#temperature" }

Try this…

Number:Temperature localCurrentTemperature "Current temperature [%.0f °F]" <temperature> { channel="darksky:weather-and-forecast:ead7c7a1:current#temperature" }

Scott -

My original item works as it’s supposed to and when placed in Basic UI it delivers temps in Fahrenheit as expected. Where I’m having difficulty is trying to get this into HabPanel. HabPanel will not accept number:temperature so I can’t use it. It will accept Number, but when used it comes in as Celsius…hence the need to convert.

1 Like

It if uses the Item label, specifying F might just work. I do not use HABPanel.

1 Like

@ysc Can you provide any HabPanel insight here?

Why can’t I use Number:Temperature?

1 Like

It’s in the other thread you abandoned. ‘Server supplied’ state “65 °F” is a string, so you cannot format it with sprintf %.0f at the habpanel widget (You don’t need to when you format it with %.0f at the sever end).

1 Like

I did not abandon the thread…I could not get it to work so I tried another approach…and did not want to clutter the two.

So you are saying this line from HabPanel

<h2 style="margin-bottom:1em;">{{'%.0f' | sprintf:itemValue('Weather_Temperature_R')}} °F</h2>

should be:

<h2 style="margin-bottom:1em;">{(itemValue('Weather_Temperature_R')}} °F</h2>
1 Like

I just setup Darksky with a temperature Item like you have, a Number Item, and a rule like in your OP. I do not get Celsius values in a rule. BTW, this should give an error, since %unit% is only for UoM Items, but it does not…

Number Weather_Temperature_R "[%.0f %unit%]" 

The only other thing I can think of is that you have not set the location for the Darksky Local Weather and Forecast Thing and that this is somehow tripping things up. Mine is set. O wait… what version of OH are you using!?

1 Like

OH version 2.5.2

Just checked the local thing config and my coordinates are in there no other locale setting.

1 Like

Hmmm… how about…

1 Like

Ok - Progress…

@rossko57 was on to something here…I re-read his comments and made the following changes.

I changed my line in HabPanel from:

<h2 style="margin-bottom:1em;">{{'%.0f' | sprintf:itemValue('Weather_Temperature_R')}} °F</h2>

to

<h2 style="margin-bottom:1em;">{{itemValue('Weather_Temperature')}}</h2>

Which gives me a display of temp in Fahrenheit! YAY!..but the value contains a decimal + 3 digits.

image

My items contains formatting which should keep it as a whole number…right?

Number:Temperature localCurrentTemperature "Current temperature [%.0f %unit%]" <temperature> { channel="darksky:weather-and-forecast:ead7c7a1:current#temperature" }

There’s something you have to do in HABpanel to select “use server formatting” which should use the [stuff] like the other sitemap based UIs.

1 Like

Unfortunately, no. The API doesn’t apply the formatting, it’s left to the client, which is weird indeed since the server would be in the best position to do it. It’ll improve in 3.0, but in 2.5 that’s what you have to deal with. And since states are not really numbers because the unit is affixed to it, the client “sprintf” fails, so what you have to do is split the value and the unit, sprintf the first part and append the unit back, like so:

<h2 style="margin-bottom:1em;">
{{('%.0f' | sprintf:itemState('Weather_Temperature').split(' ')[0]) + ' ' +
itemState('Weather_Temperature').split(' ')[1}}
</h2>

@ysc

Glad to see I wasn’t completely off base… :stuck_out_tongue:

So I’ve taken your code:

      <h2 style="margin-bottom:1em;">{{('%.0f' | sprintf:itemState('Weather_Temperature2').split(' ')[0]) + ' ' +itemState('Weather_Temperature2').split(' ')[1}}</h2>

With my item:

Number:Temperature Weather_Temperature2 "[%.0f %unit%]" { channel="darksky:weather-and-forecast:ead7c7a1:current#temperature" }

and I get…a mess


It breaks all of my other items on the page as well

1 Like

it’s missing a ] before the }}

2 Likes

Learnt something, I was sure it did do number format too, and was wrong there.

Why do you keep regressing to %unit% ? It’ll default, which ought to be right for you … but after all this trouble you can just tell it to do F regardless.
“[%.0f °F]”

2 Likes