It seems that HabPanel does not like UoM and my weather items need to be transformed from Celsius to Fahrenheit. I spent a great deal of time trying to inline convert and was not successful.
So my next plan of attack was to create dummy items with the correct Fahrenheit temperatures that work as intended on the sitemaps.
For Example, I have this item:
Number:Temperature localCurrentTemperature "Current temperature [%.0f %unit%]" <temperature> { channel="darksky:weather-and-forecast:ead7c7a1:current#temperature" }
Which generates the correct data:
So my plan was to create a dummy item and then postupdate it’s value
Here’s the dummy item:
Number Weather_Temperature_R "[%.0f %unit%]"
And the rule to update it:
rule "current temp"
when
Item Weather_Temperature changed
then
Weather_Temperature_R.postUpdate(Weather_Temperature.state)
end
When the rule runs, I get the Celsius value, not the Fahrenheit value that’s displayed on the sitemap…
What am I missing or doing wrong???
And yes, I have my settings set to the US and Imperial Units.
If HabPanel would take a Number:Temperature I would be in business.
rule "temp"
when
Item Weather_Temperature received update
then
var celsius = Weather_Temperature .state as Number
var Number fahrenheit = (celsius * 1.8) + 32
Weather_Temperature_R.postUpdate(fahrenheit)
end
@KidSquid EDIT: I just changed the item names to match yours.
QuantityTypes can be converted to whatever compatible units you want. To use a Number:Temperature Item to update a Number Item with temperatures in Centrigrade, you can do something like this…
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.
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.
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).
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!?