Does the system switch Number:Temperature between imperial/metric in all bindings?

I had it in mind, yes. I need to get the v3 version aligned with the v2.5 version and get it on GitHub

Hi , Are you still working on the binding?

I am looking for an openhab compatible air quality monitor. As far as I can tell so far the Awair seems to bethe best option. If there is someone actively integrating it into openhab then thats a big plus for me.

Hi
Yes, the 2.5 version is working. I just need to update the 3.0 code and get it on GitHub. I just haven’t had time.

1 Like

Where do I get the 2.5 version and the documentation? I have test 3.0 version and will get to that later. Thanks M

At the moment I haven’t published it. I can send you the jar if you want. I’m not sure if I can send it you privately, no idea.

Hi, That would be great. Thanks.

You can send via Dropbox, Gdrive etc link. You can also attach it in a PM.

No rush. The Awair hasn’t arrived yet. :slight_smile:

M

For OH2.5 I got the data into Grafana for charting and gauges without using a binding. I still would like a binding to reduce the coding.

I enabled the local API option for the Awair using the app and then in openHAB setup HTTP caching and regex to extract the needed data.

eg cache http://192.168.1.6/air-data/latest

I posted a full tutorial here:

This is due to fact that not all units are recognized as “default” nor have imperial/metric variant. I believe that part of blame is org.openhab.core.internal.i18n.I18nProviderImpl and its unclear responsibility in combination with custom units.
See initialization of dimension map: openhab-core/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/i18n/I18nProviderImpl.java at 3.0.1 · openhab/openhab-core · GitHub.

But this is data coming from the binding, isn’t it? The binding knows (or is told) what units the measurement is in. The binding doesn’t care what units openHAB is using as default. Just issue a state update with the given units. If the OH framework wants to convert that, it can.

%unit% has no place here.

It doesn’t matter whether I include %unit% or not, the effect is the same.

%unit% is an error here.
The data coming from your binding cannot have a default unit - how could the system know what units your measurement is in, unless your binding tells it?
Supply a Quantity type, with unit, for use as a channel update, just as you had before.

Once again, it makes no difference whether I include %unit% or not - it never works.

As of right now, particulate matter and temperature have %unit%, the rest don’t, and no units show in PaperUI.

These look great to me, all ready to pass via a number or number:density channel.
What arrives at the Item, what does your events.log show? No point in worrying about PaperUI display until you know the content arrives at the Item.

What might be useful is showing the JSON version of a misbehaving Item, with its options, as seen by REST API

The events log says this:

2021-03-17 20:16:47.659 [vent.ItemStateChangedEvent] - AwairBedroom_LastReadingDate changed from 2021-03-17T20:07:01.000+0100 to 2021-03-17T20:16:44.000+0100
2021-03-17 20:16:47.686 [vent.ItemStateChangedEvent] - AwairBedroom_ParticulateMatterPM25 changed from 1 µg/m³ to 2 µg/m³
2021-03-17 20:16:47.723 [vent.ItemStateChangedEvent] - AwairBedroom_Temperature changed from 22.04 °C to 21.95 °C
2021-03-17 20:16:47.754 [vent.ItemStateChangedEvent] - AwairBedroom_Humidity changed from 32 % to 33 %
2021-03-17 20:16:47.768 [vent.ItemStateChangedEvent] - AwairBedroom_CarbonDioxidePpm changed from 648 ppm to 627 ppm
2021-03-17 20:16:47.778 [vent.ItemStateChangedEvent] - AwairBedroom_VolatileOrganicCompounds changed from 398 ppb to 395 ppb

Which looks good to me…

1 Like

Using the REST API, I see:

  {
    "link": "https://home.myopenhab.org:443/rest/items/AwairBedroom_ParticulateMatterPM25",
    "state": "3 µg/m³",
    "editable": true,
    "type": "Number:Density",
    "name": "AwairBedroom_ParticulateMatterPM25",
    "label": "Particulate matter (PM 2.5 µg/m3)",
    "tags": [],
    "groupNames": []
  },
  {
    "link": "https://home.myopenhab.org:443/rest/items/AwairBedroom_VolatileOrganicCompounds",
    "state": "388 ppb",
    "editable": true,
    "type": "Number:Dimensionless",
    "name": "AwairBedroom_VolatileOrganicCompounds",
    "label": "Volatile organic compounds (ppb)",
    "tags": [],
    "groupNames": []
  },
  {
    "link": "https://home.myopenhab.org:443/rest/items/AwairBedroom_Humidity",
    "state": "34 %",
    "editable": true,
    "type": "Number:Dimensionless",
    "name": "AwairBedroom_Humidity",
    "label": "Humidity",
    "category": "Humidity",
    "tags": [],
    "groupNames": []
  },
  {
    "link": "https://home.myopenhab.org:443/rest/items/AwairBedroom_Temperature",
    "state": "22.12 °C",
    "editable": true,
    "type": "Number:Temperature",
    "name": "AwairBedroom_Temperature",
    "label": "Temperature",
    "category": "Temperature",
    "tags": [],
    "groupNames": []
  },
  {
    "link": "https://home.myopenhab.org:443/rest/items/AwairBedroom_CarbonDioxidePpm",
    "state": "615 ppm",
    "editable": true,
    "type": "Number:Dimensionless",
    "name": "AwairBedroom_CarbonDioxidePpm",
    "label": "Carbon dioxide (ppm)",
    "category": "CarbonDioxide",
    "tags": [],
    "groupNames": []
  },

events.log
Okay, looks good, your binding has delivered Quantities as expected.

jsondb
So your binding suggested pattern has not arrived at the Item. (and there’s nothing else to tell PaperUI how to display).

That’s the end of my knowledge about how the XML hints are supposed to be passed through the channel, but that’s where the problem lies.

The only thing that looks unusual to me is the trailing /
Does it work with conventional
<state readOnly="true" pattern="%.1f %unit%"> </state>
?

What should appear in the JSON?

I’ll try it!

I forget exactly but there is a “pattern” element. No pattern, no units displayed. When you use the old fashioned [state presentation] embedded in an Item label, it gets populated from there. In this case, you want it populated from your bindings “hint”. Users would be able to override that and set their own pattern,but so far as I know when no pattern is defined in the Item your “hint” should be taken.

Edit - here we go, an OH2 example

{
  "link": "http://localhost:8080/rest/items/nmt_CurrentTemperature",
  "state": "4.12 °C",
  "stateDescription": {
    "pattern": "%.0f %unit%",
    "readOnly": true,
    "options": []
  },
  "editable": false,
  "type": "Number:Temperature",
  "name": "nmt_CurrentTemperature",
  "label": "Current temperature",
  "category": "thermometer",
  "tags": [],
  "groupNames": []
}

This is where the %unit% version is relevant, displaying the units the Item currently has (which most often will be system default if defined, or what the binding appended when updating)

1 Like

I modified the XML and took out any %unit% variables (although I notice that other addons use them a lot), and the result is weird. The first time, I got the unit in PaperUI for VOCs and CO2. The next time I built the addon, I got the unit for VOCs only. The next time, I got it only for PM 2.5 and nothing else, without having modified the definition of that channel at all.