Danielhiversen / home_assistant_airthings_cloud

Airthings cloud
Apache License 2.0
32 stars 6 forks source link

Radon units are incorrect: Airthings Dashboard shows 1 pCi/L but HA component shows Bq/m3 #13

Closed strikeir13 closed 3 years ago

strikeir13 commented 3 years ago

I'm located in USA and the radon units on my Airthings Dashboard are pCi/L. image

I'm not sure if the displayed units are different for different countries, but the units are incorrect for me (though the numerical value is correct). Per https://www.ncbi.nlm.nih.gov/books/NBK230646/, "1 pCi/L is equal to 37 Bq/m3" so maybe a simple conversion could be added based on location, sourced either from Home Assistant or perhaps based on the units selected in the Airthings Dashboard (I don't know what's available).

avocadosalsa commented 3 years ago

I just dumped the result from the API and it appears that it does provide the unit in the response:

...
"currentSensorValues": [
  {
    "type": "radonShortTermAvg",
    "value": 5.19,
    "providedUnit": "pci",
    "preferredUnit": "pci",
    "isAlert": true,
    "thresholds": [
      2.7,
      4
    ]
  },
...

Right now this componenet is hardcoded as "radonshorttermavg": ["Bq/m³", None], but I could not figure out in the Home Assistant developer documentation how you are supposed to properly set the values for metric/imperial such that Home Assistant is able to do the conversions based on what the user has selected for the frontend. I think a kludge for the moment is to just set the unit to whatever is returned from the Airthings API and it will potentially not be in sync with the metric/imperial setting in Home Assistant.

Danielhiversen commented 3 years ago

Fixed by https://github.com/Danielhiversen/home_assistant_airthings_cloud/pull/15