Problems with units (from Netatmo) after upgrading to OH2.3

Hi everybody,

I run OH since the release 2.0 and this is the first time I face a problem I cannot solve on my own/with all the documentation.
I think that is a good sign for OH at all, but nervertheless I am still a beginner.
I am running OH2.3 stable on openhabian.

I have a problem with my Netatmo items since I upgraded from 2.2 stable.

Screenshots:

  • PaperUI


    Redundant items are there, because of the active “Simple Mode”.

  • BasicUI
    (As a new user to the forum I can only upload one picture :smile:)
    In BasicUI there is “Err” behind the label.

I tried playing around with some item definitions like [%.1f %unit%] and so on. Those werent needed in OH2.2 for proper use.

items definition:

Number 	temp_aussen 			"Außentemperatur [%.1f %unit%]"	<temperature>	[ "CurrentTemperature" ]	{channel="netatmo:NAModule1:*:Temperature"}
Number 	regen_aussen 			"Regen"				<rain>	 									{channel="netatmo:NAModule3:*:Rain"}

I also tried to change the item in the sitemap to Text.

sitemap definition:

sitemap default label=“openHAB”
{
Frame label=“Garten”
{
Text item=temp_aussen
Default item=regen_aussen

Logs:

These log entries appear as soon as I open up the BasicUI.

2018-06-02 12:49:37.640 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘19.299999237060546875’ of item temp_aussen with format ‘%.1f %unit%’: Conversion = ‘u’

2018-06-02 12:49:37.653 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘0’ of item regen_aussen with format ‘%.2f %unit%’: Conversion = ‘u’

2018-06-02 12:49:37.725 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘24.1000003814697265625’ of item temp_wohnzimmer with format ‘%.1f %unit%’: Conversion = ‘u’

2018-06-02 12:49:37.736 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘438’ of item co2_wohnzimmer with format ‘%.0f %unit%’: Conversion = ‘u’

2018-06-02 12:49:37.748 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘36’ of item db_wohnzimmer with format ‘%.0f %unit%’: Conversion = ‘u’

2018-06-02 12:49:37.758 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘71’ of item feucht_wohnzimmer with format ‘%.0f %unit%’: Conversion = ‘u’

2018-06-02 12:49:37.997 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘23.8999996185302734375’ of item temp_schlafzimmer with format ‘%.1f %unit%’: Conversion = ‘u’

2018-06-02 12:49:38.013 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘510’ of item co2_schlafzimmer with format ‘%.0f %unit%’: Conversion = ‘u’

2018-06-02 12:49:38.026 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘62’ of item feucht_schlafzimmer with format ‘%.0f %unit%’: Conversion = ‘u’

I think it worked for a minute after changing one item defintion a couple of times, but I cannot reproduces that.
Please help :slight_smile:

Thanks in advance
Lukas

Try

Number:Temperature 	temp_aussen 			"Außentemperatur [%.1f %unit%]"	<temperature>	[ "CurrentTemperature" ]	{channel="netatmo:NAModule1:*:Temperature"}
Number:Dimensionless 	regen_aussen 			"Regen"				<rain>	 									{channel="netatmo:NAModule3:*:Rain"}

Thank you very much.
Now it is working again.

I have to restart several times, because OH was not updating the format after changing the item file.

2018-06-02 15:23:32.908 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘73 %’ of item feucht_wohnzimmer with format ‘%.0f %’: Conversion = ‘%’

I got this message even minutes after the item file was changed.

Try Number:Dimensionless and please read the ninding focumentation https://www.openhab.org/addons/bindings/netatmo/#channels

How do you set the %unit%? I can’t find anything in the documentation about it.

When you add %unit% the item is updated using the default channel unit. This unit is provided by the binding. If you replace it with your own unit, it is automatically converted. See also this Units of Measurement blog post.

@Astra If you’re using %unit% with a restoreOnStartup persistence strategy you may run into this issue:

Thanks @wborn, is there going to be any sort of OH documentation explaining how %unit% works? I’m sure this will be very confusing to none technical folks. Does it work with OH1 bindings as well?

I found that it is also part of the openHAB documentation, see this paragraph: Units Of Measurement | openHAB

It requires bindings to send updates with a unit which is only possible with OH2 bindings.

Using %unit% in an item is not only restricted to items bound to binding channels. You can also use it with items that are updated by rules:

E.g. with item:

Number:Power LED_Power "LED [%.1f %unit%]"

You can get the item to automatically use the unit provided by rules:

LED_Power.postUpdate(1000|W)

or

LED_Power.postUpdate(1|kW)
1 Like

I have a query.
I have a sensor providing a measurement in m/s (SI)
I want to convert it to mph or km/h

BUT When I assign a unit to it OH assumes that it is km/h
How do It tell OH that the unit obtained is m/s and not km/h?

@vzorglub

You can add the desired unit to the label of your item or in the sitemap. The framework will do the conversion automatically. e.g.

demo.items:

Number:Speed testNumberSpeed

demo.sitemap:

sitemap demo label="My home automation" {
    Frame label="Speed" {
        Text item=testNumberSpeed label="Speed [%.1f %unit%]" icon="pressure"
        Text item=testNumberSpeed label="Speed [%.1f km/h]" icon="pressure"
        Text item=testNumberSpeed label="Speed [%.1f m/s]" icon="pressure"
        Text item=testNumberSpeed label="Speed [%.1f mph]" icon="pressure"
    }
}

It will look like this:

1 Like

@cweitkamp

Thanks, but I know that.
My problem is that the unit received is in m/s not km/h
OH assumes that the unit is km/h, which lead to incorrect conversions

So how do I tell OH that the unit for this item is m/s

I see. Where does the value come from? HTTP Request? Binding? Somewhere else?

HTTP request

Could something like this be implemented:

Number:Speed:ms SpeedItem

I am afraid that is currently not possible.

If your item is bind to a HTTP request you maybe can do the conversion in a JavaScript transformation. You have to convert the incoming value to the default value of your chosen unit system.

This is what I am doing, I was hoping to take advantage of the now built-in unit conversion.
Never mind.

But:

Number:Speed:ms SpeedItem

Good idea or not?

It’s not my job to decide that. :wink: Please open an issue for this feature request in the ESH repo.

I maybe have an idea to benefit from the built-in unit conversion. Instead of doing the math you can return the value as String combined with the source unit in the JavaScript transformation. e.g.

function(i) {
    var json = JSON.parse(i);
    return parseFloat(<SOURCETAG>) + " m/s";
})(input)

Done

Nice one! but still using a transform…

I admit I am not able to deal with this new “unit method” :thinking:.
Rules that used to work flowlessly, now have real difficulties in comparing values and additional variables have to be created do to math and comparisons.
Sombody can please help me to understand why this instruction is not triggering (it used to)?
I believe it could be related to units and/or some conversion that I am not doing.

if (Netatmo_Indoor_CO2.state >= 800 && Netatmo_Indoor_CO2.state < 1000)

With the definition:

Number Netatmo_Indoor_CO2 "Anidride carbonica [%d ppm]" <carbondioxide> { channel = "netatmo:NAMain:xxx:xxx:Co2" }

same with

Number.Dimensionless Netatmo_Indoor_CO2 "Anidride carbonica [%d ppm]" <carbondioxide> { channel = "netatmo:NAMain:xxx:xxx:Co2" }

I keep thinking that units are more a complication than an advantage :disappointed_relieved: .

Do this:

var CO2State = Netatmo_Indoor_CO2.state as Number
if (CO2State >= 800 && CO2State < 1000) { ...