openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.71k forks source link

[Weather] APIXU forecast issue: the binding seems to not distinguish between current values and forecast values when looking up data from providers #5876

Closed tobiasisenberg closed 4 years ago

tobiasisenberg commented 5 years ago

Expected Behavior

If I request the forecast rain value Number:Length WeatherTodayPrecipitationDay "Rain [%s mm]" {weather="locationId=homeApiXU, forecast=1, type=precipitation, property=rain"} I would expect to get the respective value of how much rain is forecast for tomorrow.

Current Behavior

Currently I always get 0, regardless of how much rain is forecast.

Possible Solution

The reason for the missing value is that, for APIXU, the tag for the rain of the current day and for the forecast rain are different: for the current values, according to https://www.apixu.com/doc/current.aspx, the tag for lookup is precip_mm. This tag is also used in the binding in file org.openhab.binding.weather/src/main/java/org/openhab/binding/weather/internal/model/Precipitation.java:

    @ProviderMappings({ @Provider(name = ProviderName.FORECASTIO, property = "precipIntensity"),
            @Provider(name = ProviderName.OPENWEATHERMAP, property = "rain.3h", converter = ConverterType.DOUBLE_3H),
            @Provider(name = ProviderName.OPENWEATHERMAP, property = "rain"),
            @Provider(name = ProviderName.WORLDWEATHERONLINE, property = "precipMM"),
            @Provider(name = ProviderName.HAMWEATHER, property = "precipMM"),
            @Provider(name = ProviderName.METEOBLUE, property = "precipitation_amount"),
            @Provider(name = ProviderName.APIXU, property = "precip_mm"),
            @Provider(name = ProviderName.WEATHERBIT, property = "percip") })
    private Double rain;

Yet according to https://www.apixu.com/doc/forecast.aspx the correct tag for the forecast rain values would be totalprecip_mm which seems to be nowhere to be used in the binding. I am not fully aware of how the binding actually does the lookup, yet it seems to me that, since the correct tag for the forecast is not used, that it does not distinguishes between tags to be used for a forecast and tags to be used for the current conditions, in any of the weather services.

As a side note, it seems weird that the actual coverage of the different values is not documented for the different data services. One has to look up the source code to learn, for example, that for APIXU there is no snow coverage at all. Maybe it would be worth to document, at least, into which source file to look to check if a value is covered or not, for a given service.

Steps to Reproduce (for bugs)

  1. Configure weather binding
  2. Ask for current and forecast rain from APIXU
  3. Observe that for forecast rain the value is always 0

Context

Your Environment

jmahmens commented 4 years ago

The Binding provides this 'precip' values for current and forcast but not on same channel: forcast day 0: {weather="locationId=XXX, forecast=0, type=precipitation, property=total"} This could be used for an item. This works for me on OH 2.5M1 on Raspian

tobiasisenberg commented 4 years ago

Indeed. This works. Yet still it is a bit counter-intuitive since I would expect the property=rain to work even for a forecast. Anyway, I guess this solves my problem. Maybe this is then not a bug, after all, but only an issue that could be better documented. I'll close the issue for now.