OpenWeatherMap Binding Bug in 4.3.4: Forecast Visibility Channels Receive Cloudiness % Instead of Distance

I’m running OH 4.3.3 on a Pi running openhabian.

I’m still seeing the issue discussed in this closed thread: Errors after Upgrade to OH4 (unit conversion and icon file)

Title: OpenWeatherMap Binding Bug in 4.3.4: Forecast Visibility Channels Receive Cloudiness % Instead of Distance

openHAB Version: 4.3.4 (openHABian, Raspberry Pi, Debian 12.10 bookworm)
Binding: OpenWeatherMap Binding (version 4.3.4)
Configuration: Managed via Main UI

Issue: The OpenWeatherMap Binding sends cloudiness percentages (e.g., '80 %') to forecast visibility channels (forecastHours01#visibility, forecastHours02#visibility), causing errors, while the current visibility channel (current#visibility) correctly receives distance ('10 km'). Debug logs confirm the binding misassigns data for forecast visibility channels.

Debug Logs (set via log:set DEBUG org.openhab.binding.openweathermap):


2025-04-21 14:03:00.865 [DEBUG] [handler.OpenWeatherMapOneCallHandler] - OneCallHandler: updateChannel openweathermap:onecall:b9170c9f74:local:current#visibility, groupID current
2025-04-21 14:03:00.867 [DEBUG] [handler.OpenWeatherMapOneCallHandler] - Update channel 'visibility' of group 'current' with new state '10 km'.
2025-04-21 14:03:00.936 [DEBUG] [handler.OpenWeatherMapOneCallHandler] - OneCallHandler: updateChannel openweathermap:onecall:b9170c9f74:local:forecastHours01#visibility, groupID forecastHours01
2025-04-21 14:03:00.940 [DEBUG] [handler.OpenWeatherMapOneCallHandler] - Update channel 'visibility' of group 'forecastHours01' with new state '80 %'.
2025-04-21 14:03:00.956 [WARN ] [penhab.core.library.items.NumberItem] - Failed to update item 'One_Call_API_Weather_and_Forecast_Visibility' because '80 %' could not be converted to the item unit 'm'
2025-04-21 14:03:01.005 [DEBUG] [handler.OpenWeatherMapOneCallHandler] - OneCallHandler: updateChannel openweathermap:onecall:b9170c9f74:local:forecastHours02#visibility, groupID forecastHours02
2025-04-21 14:03:01.006 [DEBUG] [handler.OpenWeatherMapOneCallHandler] - Update channel 'visibility' of group 'forecastHours02' with new state '80 %'.
2025-04-21 14:03:01.008 [WARN ] [penhab.core.library.items.NumberItem] - Failed to update item 'One_Call_API_Weather_and_Forecast_Visibility02' because '80 %' could not be converted to the item unit 'm'

With a little help from Grok, I used a curl command to query the API and see what it is providing to the binding.


curl "https://api.openweathermap.org/data/3.0/onecall?lat=xx.093914214693438&lon=-yy.33740282058717&appid=myauthenticationcode&units=metric"

In the JSON response, visibility is:


{
  "current": {
    "dt": 1745192139,
    "visibility": 10000,
    "clouds": 75
  },
  "hourly": [
    {
      "dt": 1745190000,
      "visibility": 10000,
      "clouds": 80
    },
    {
      "dt": 1745193600,
      "visibility": 10000,
      "clouds": 75
    },
    {
      "dt": 1745197200,
      "visibility": 10000,
      "clouds": 63
    },
    {
      "dt": 1745200800,
      "visibility": 10000,
      "clouds": 51
    },
    {
      "dt": 1745204400,
      "visibility": 10000,
      "clouds": 35
    },
    {
      "dt": 1745208000,
      "visibility": 10000,
      "clouds": 35
    },
    {
      "dt": 1745211600,
      "visibility": 10000,
      "clouds": 37
    },
    {
      "dt": 1745215200,
      "visibility": 10000,
      "clouds": 47
    },
    {
      "dt": 1745218800,
      "visibility": 10000,
      "clouds": 52
    },
    {
      "dt": 1745222400,
      "visibility": 10000,
      "clouds": 68
    },
    {
      "dt": 1745226000,
      "visibility": 10000,
      "clouds": 78
    },
    {
      "dt": 1745229600,
      "visibility": 10000,
      "clouds": 79
    },
    {
      "dt": 1745233200,
      "visibility": 10000,
      "clouds": 73
    },
    {
      "dt": 1745236800,
      "visibility": 10000,
      "clouds": 63
    },
    {
      "dt": 1745240400,
      "visibility": 10000,
      "clouds": 5
    },
    {
      "dt": 1745244000,
      "visibility": 10000,
      "clouds": 12
    },
    {
      "dt": 1745247600,
      "visibility": 10000,
      "clouds": 19
    },
    {
      "dt": 1745251200,
      "visibility": 10000,
      "clouds": 26
    },
    {
      "dt": 1745254800,
      "visibility": 10000,
      "clouds": 34
    },
    {
      "dt": 1745258400,
      "visibility": 10000,
      "clouds": 39
    },
    {
      "dt": 1745262000,
      "visibility": 7098,
      "clouds": 31
    },
    {
      "dt": 1745265600,
      "visibility": 9167,
      "clouds": 31
    },
    {
      "dt": 1745269200,
      "visibility": 10000,
      "clouds": 34
    },
    {
      "dt": 1745272800,
      "visibility": 6850,
      "clouds": 31
    },
    {
      "dt": 1745276400,
      "visibility": 10000,
      "clouds": 32
    },
    {
      "dt": 1745280000,
      "visibility": 10000,
      "clouds": 36
    },
    {
      "dt": 1745283600,
      "visibility": 10000,
      "clouds": 41
    },
    {
      "dt": 1745287200,
      "visibility": 10000,
      "clouds": 19
    },
    {
      "dt": 1745290800,
      "visibility": 10000,
      "clouds": 13
    },
    {
      "dt": 1745294400,
      "visibility": 10000,
      "clouds": 10
    },
    {
      "dt": 1745298000,
      "visibility": 10000,
      "clouds": 8
    },
    {
      "dt": 1745301600,
      "visibility": 10000,
      "clouds": 6
    },
    {
      "dt": 1745305200,
      "visibility": 10000,
      "clouds": 4
    },
    {
      "dt": 1745308800,
      "visibility": 10000,
      "clouds": 6
    },
    {
      "dt": 1745312400,
      "visibility": 10000,
      "clouds": 10
    },
    {
      "dt": 1745316000,
      "visibility": 10000,
      "clouds": 15
    },
    {
      "dt": 1745319600,
      "visibility": 10000,
      "clouds": 20
    },
    {
      "dt": 1745323200,
      "visibility": 10000,
      "clouds": 23
    },
    {
      "dt": 1745326800,
      "visibility": 10000,
      "clouds": 40
    },
    {
      "dt": 1745330400,
      "visibility": 10000,
      "clouds": 35
    },
    {
      "dt": 1745334000,
      "visibility": 10000,
      "clouds": 32
    },
    {
      "dt": 1745337600,
      "visibility": 10000,
      "clouds": 32
    },
    {
      "dt": 1745341200,
      "visibility": 10000,
      "clouds": 40
    },
    {
      "dt": 1745344800,
      "visibility": 10000,
      "clouds": 50
    },
    {
      "dt": 1745348400,
      "visibility": 10000,
      "clouds": 100
    },
    {
      "dt": 1745352000,
      "visibility": 10000,
      "clouds": 100
    },
    {
      "dt": 1745355600,
      "visibility": 10000,
      "clouds": 100
    },
    {
      "dt": 1745359200,
      "visibility": 10000,
      "clouds": 100
    }
  ]
}

So the API is providing distance (in most cases 10000 which is meters because the API call requested metric units. But somehow the binding is sending the cloudiness % to the visibility channels for the forecasts. The current visibility is handled correctly.

Any suggestions? Happy to help troubleshoot this.

Hi George,

could it be that it actually shows the value of precip-probability and not cloudiness? I think there is a break; missing in the corresponding switch statements in the handler(s) and thus it falls through:

I can try to fix this in the evening, if you confirm.

PR has been merged and this should be fixed in the next release → [openweathermap] Fix visibility channels by boehan · Pull Request #18597 · openhab/openhab-addons · GitHub

(obviously, this has never worked for OneCall API, which was implemented almost 5 years ago…)

Thanks. I will look forward to the release.

I’m seeing an issue here: Openweathermap duplicate channels error - could it be related to this update? Did this fix make it into 4.3.5?

Yes, this is probably related. There already is an issue created:

And it seems it is also in the latest 4.3.x release, which probably makes fixing the upgrade-instructions a bit trickier…
But apart from that, re-adding the thing should fix it.

I updated to OH 4.3.5 and the issue is resolved! Thanks!