Unit of sensor value "one" instead of "%" or "ppm"

Platform information:

  • Hardware: Raspberry Pi 3 Model B Plus Rev 1.3
  • OS: Openhabian
  • openHAB version: openHAB 3.3.0 - Release Build
  • Issue of the topic:

I am using openHab controlling and reading Homematic Devices since a while and recently I saw that one of my Homematic temperature/humidity sensor shows “one” as a unit istead of “%”. The strange thing is that another temp./humidity sensor is recognized correctly. I am pretty sure both showed “%” some weeks/month ago.

This one works fine:


This one does not:

I compared both items 1:1 and don’t see any differences.

Furthermore I have a MQTT air quality sensor which has “one” as a unit as well but it should be without any unit (or if possible it should get “ppm”).


Item configuration:

and

A couple of hints what to look for to get the correct unit back (for temp/humidity sensor) or set (for air quality sensor) would be awesome!

Best Regards
Rey

What is set in Metadata State Description?

1 Like

Nothing set - if I screenshotted the right area:

Sensor with right Unit:


Sensort with wrong / without Unit:

Or do I find the “Metadata State Description” somewhere else?

EDIT: Added the Screenshots of the channel configuration:
Working


and not working:

Seems that the working one has Numer:Dimensionless and the other one just has Number

EDIT2: I was able to give the air quality Sensor the Unit “ppm” by modifying the Channel configuration:

Unfortunately I do not have that option inside the channel configuration of the Sensors (at least not in the UI as it seems).


What may be interesting in addition is, that for the Sensor without proper Unit I need to click “show advanced” when I want to see the channel for humidity - otherwise it does not show up.

EDIT 3: The next strange observation is, that the Humidity with Unit “one” does not trigger any log events. I.e. when I filter “humidity” in the log, I only see value changes of the sensor with a unit, not the other one. But when I open the diagram for the humidity values without unit I can see that it changes over time.
Temperatur values are visible inside the log for both sensors by the way.

Dimensionless is, as the name says, dimensionless. There are a few dimensionless units, among them %, decibles, and ONE.

If you use a Number:Dimensionless Item, posting a number without units will default to ONE as the unit. You can tell OH to use one of the other units (%) in this case, by setting the State Description Metadata (see the “Add Metadata” section of the Item’s page) and set the pattern to something like %.0f % or maybe %.0f %% if that first one doesn’t work.

On OH 3.3, if an update is posted to a Number Item that has units, that Number Item will magically start to carry units and you should change the type of that Item to match the units and supply State Description metadata for that one. In OH 3.4 this behavior has been eliminated. If you have a Number Item, it will never carry units.

2 Likes

Awesome - thank you for that explanation. It worked.
That site does not contain any part for metadata Items | openHAB so I guess you meant this one in the concepts area: Items | openHAB?

The missing metadata entry does not explain why the item does not trigger a log-event, or does it?

I am not sure if I completely understood that … My takeaway right now is: I go through all my items with correct units and set up a State Description Metadata similar to the unit the items carries. E.g. if a temperature Item shows 21.5 °C, I need set up the metadata of that Item to %.1f °C. That is cause the Item without metadata “magically” shows the right unit but I need to tell the system explicitely what unit the item carries. Correct?

The syntax for metadata is missing from this page but you probably don’t need to refer to that page much if ever anyway because you are defining your Items through the UI. That page mostly covers the syntax of .items files.

This page does discuss Item metadata and even provides an example of the syntax for .items files.

But this is a case where the UI is mostly self documenting. Just click “Add metadata” on the Item you want to add metadata for and select the metadata you want to add. The forms presented either link to the docs you need to reference or document each field in place.

No. The only reason you wouldn’t see logs en events.log are:

  1. the Item is not changing
  2. there is a filter put in place to stop OH from logging the event

Also check the Item type. Number should not carry units (and in fact is prevented from that in 3.4). Number:X should carry units. You would do well to specify the state description for all those Items.

The Channel often will tell you what type of Item should be linked to the Channel (e.g. if it provides units for a temperature reading, it’ll tell you to link to a Number:Temperature Item.

If what ever is providing the update supplies units, in OH 3.3 it will apply those units no matter what type of Number Item it is.

To have the best results:

  1. Always match the type that the Channel says it should be linked to. If it just says Number, use Number. If it says Number:Temperature, use Number:Temperature.

  2. For those Items that are Number:X, you would do well to provide a State Description metadata to tell OH what units you really want to see. If the binding supplies °F, you can specify °C here and your Item will be converted to °C.

  • List item
1 Like

Alright, thanks again for all the information. I will do the homework today :slight_smile:

What I just saw this morning is that the humidity now has a value of 4900% – probably due to a “wrong” transformation from raw 49 to percent (same as in excel I guess). Is it enough to try to shift the decimal point? Or is there an other, deeper issue? If shifting is enough, how can I achieve it? Can I just write `%.0f %%/100’?

The value of the item is changing so the reason might be the second point. I am pretty sure that I never set up such a filter. Where do I need to look for that?

It depends on what exactly the Channel is delivering, what exactly the Item type is, and any transformations that may be involved.

No, you can’t just add /100.

/var/openhab/etc/log4j2.xml

It delivers the value for humidity as Number


whereas the one without any displaying issue delivers Number:Dimensionless

As I said above:

The Channel says Number so you should link it to a Number, not a Number:Dimensionless.

1 Like

Thank you for the patience - I read it but it didn’t think deep enough obviously. It works now with the State Description metadata set!!! :slight_smile: