Davis weather via IP

If any current users of the Davis weather binding would like to try out a new version enabling IP communication, please try this jar from this PR.

The author has decided not to complete the changes, but if someone can confirm it’s working, we can push the PR to completion…

Thanks!

Having Davis Vantage Pro2 Plus with Wireless Weather Envoy (IP).
Tried to download and install this jar binding file.

Have OpenHAB 2.4 snapshot installed on RPi.

Stopped OH
Copied provided jar file into following folder /usr/share/openhab2/addons
changed permissions to openhab:openhab
Started OH

Can you correct if I missing something in order to make this binding working and I could verify it with my weather station?

That sounds like it should work, assuming you set up the config for the binding.

Yep, I’ve configured according this manual Davis Binding

My configuration file under services/davis.cfg is:

hostName=192.168.1.7
readResponseWaitTime=1000
refresh=10000

Karaf shows that Davis binding is active:

223 x Active   x  80 x 1.12.0.201805280013    x openHAB Davis Binding

OH2 is also not showing any errors when binding is started:

[DEBUG] [org.openhab.binding.davis           ] - BundleEvent STARTING - org.openhab.binding.davis
[DEBUG] [inding.davis.internal.DavisActivator] - Davis binding has been started.
[DEBUG] [org.openhab.binding.davis           ] - BundleEvent STARTED - org.openhab.binding.davis
[DEBUG] [org.openhab.binding.davis           ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={service.id=383, service.bundleid=223, service.scope=bundle, event.topics=openhab/*, service.pid=org.openhab.davis, component.name=org.openhab.binding.davis, component.id=236} - org.openhab.binding.davis
[TRACE] [.binding.davis.internal.DavisBinding] - update() method is called!
[DEBUG] [org.openhab.binding.davis           ] - ServiceEvent REGISTERED - {org.openhab.model.item.binding.BindingConfigReader, org.openhab.binding.davis.DavisBindingProvider}={service.id=382, service.bundleid=223, service.scope=bundle, component.name=org.openhab.binding.davis.genericbindingprovider, component.id=237} - org.openhab.binding.davis

From Davis binding log that’s it, no more log data, seems that it is not trying to connect to configured Davis host, since there should be another log entry when opening port (serial or IP) in case of success or failure.

I’am currently running OH 2.4.0-SNAPSHOT Build #1403 version.

Any ideas what else I could try?

What’s your configuration/sitemap?

I took configuration from example that was in Davis Binding manual.

Here is my davis.items file

Group           DavisWeather            "Current weather"       <sun_clouds>

Group           DavisStation            "Station data"          (DavisWeather)
Group           DavisInfo               "Info"                  (DavisWeather)
Group           DavisTemperature        "Temperature"           (DavisWeather)
Group           DavisHumidity           "Humidity"              (DavisWeather)
Group           DavisBarometer          "Barometer"             (DavisWeather)
Group           DavisWind               "Wind"                  (DavisWeather)
Group           DavisRain               "Rain"                  (DavisWeather)
Group           DavisSun                "Solar information"     (DavisWeather)

String StationType              "StationType: [%s]"             (DavisStation)  { davis="station_type" }

Number Receivers                "Receivers: [%.0f]"             (DavisStation)  { davis="receivers" }
Number TransmitterBattery       "Transmitter Battery [%.1f]"    (DavisStation)  { davis="transmitter_battery_status" }
Number ConsoleBattVoltage       "Console Battery [%.2f V]"      (DavisStation)  { davis="console_battery_voltage" }
String firmware_date            "Firmware Date: [%s]"           (DavisStation)  { davis="firmware_date" }
String firmware_version         "Firmware Version: [%s]"        (DavisStation)  { davis="firmware_version" }

DateTime Date           "Date [%1$tA, %1$td.%1$tm.%1$tY]"       (DavisInfo)     { davis="time" }

Number InsideTemp       "Inside Temp [%.1f °C ]"                (DavisTemperature)      { davis="inside_temp" }
Number OutsideTemp      "Outside Temp [%.1f °C ]"               (DavisTemperature)      { davis="outside_temp" }
Number DewPoint         "Dew Point [%.1f °C ]"                  (DavisTemperature)      { davis="dew_point" }
Number HeatIndex        "Heat Index [%.1f °C ]"                 (DavisTemperature)      { davis="heat_index" }
Number WindChill        "Wind Chill [%.1f °C ]"                 (DavisTemperature)      { davis="wind_chill" }
Number THSWIndex        "THSW Index[%.1f °C ]"                  (DavisTemperature)      { davis="thsw_index" }

Number InsideHumidity   "Inside Humidity [%.0f %% ]"            (DavisHumidity)         { davis="inside_humidity" }
Number OutsideHumidity  "Outside Humidity [%.0f %% ]"           (DavisHumidity)         { davis="outside_humidity" }

String BarTrend         "Barometer Trend [%s]"                  (DavisBarometer)        { davis="bar_trend" }
Number Barometer        "Barometer [%.0f hPa]"                  (DavisBarometer)        { davis="barometer" }

Number WindSpeed                "Wind Speed [%.1f km/h]"                        (DavisWind)     { davis="wind_speed" }
Number WindSpeed10minAvg        "Wind Speed 10min Avg [%.1f km/h]"              (DavisWind)     { davis="wind_speed_10min_avg" }
Number WindDirection            "Wind Direction [%.0f °]"                       (DavisWind)     { davis="wind_direction" }
Number WindSpeed10minHiRes      "Wind Speed 10min Avg HiRes [%.1f km/h]"        (DavisWind)     { davis="wind_speed_10min_avg_hires" }
Number WindSpeed2minHiRes       "Wind Speed 10min Avg HiRes [%.1f km/h]"        (DavisWind)     { davis="wind_speed_2min_avg_hires" }
Number WindSpeed10minGustHiRes  "Wind Speed 10min Avg HiRes [%.1f km/h]"        (DavisWind)     { davis="wind_speed_10min_gust_hires" }
Number WindDirectionGust        "Wind Direction Gust [%.0f °]"                  (DavisWind)     { davis="wind_direction_10min__gust" }

Number RainRate         "Rain Rate [%.1f mm/h ]"                (DavisRain)     { davis="rain_rate" }
Number Rain15min        "Rain Rate [%.1f mm/h ]"                (DavisRain)     { davis="last_15min_rain" }
Number Rainlast1h       "Rain Rate [%.1f mm/h ]"                (DavisRain)     { davis="last_hour_rain" }
Number Rainlast24h      "Rain Rate [%.1f mm/h ]"                (DavisRain)     { davis="last_24h_rain" }

Number UVIndex  "UV Index [%.1f ]"                              (DavisSun)      { davis="uv" }
Number Solar    "Solar Radiation [%.0f W/m²]"                   (DavisSun)      { davis="solar_radiation" }

Davis part of a .sitemap

    Frame label="Meteo" {
            Group item=DavisWeather
    }

If the updated binding were properly installed, you should see this message in the log:

ProperlyConfigured with hostName [hostname] with readResponseWaitTime on

No, I have not seen this message in a log files. The log I’ve attached previously is all I see currently.

For Davis binding I’ve set the TRACE log level through karaf console

log:set TRACE org.openhab.binding.davis

I try to install the binding but i received this error message:

2019-01-05 18:25:08.276 [ERROR] [org.openhab.binding.davis ] - [org.openhab.binding.davis(279)] The deactivate method has thrown an exception

at org.openhab.binding.davis.internal.DavisBinding.closePort(DavisBinding.java:191) [265:org.openhab.binding.davis:1.12.0.201805280013]

at org.openhab.binding.davis.internal.DavisBinding.deactivate(DavisBinding.java:71) [265:org.openhab.binding.davis:1.12.0.201805280013]

@namraccr
I’m currently trying to connect a Davis Weather Envoy to my openhab2.4 system. This is a totally fresh install.

I installed your jar in the following way:

  • systemctl stop openhab2
  • placing your jar in /usr/share/openhab2/addons
  • changed the permissions like @redalert
  • systemctl start openhab2

Then I ran into various problems which I found in the logs:
Unresolved requirement: Import-Package: gnu.io

  • fixed by “feature:install openhab-transport-serial” in karaf

Unresolved requirement: Import-Package: org.openhab.core.binding

  • fixed by “feature:install openhab-runtime-compat1x”

Now the binding seems to start successfully since there are no errors anymore.
I created a services/davis.cfg

hostName=192.168.111.77
readResponseWaitTime=1000
refresh=10000

An item file in items/davis.items with the exact content as in the bottom example of https://www.openhab.org/addons/bindings/davis1/

And a sitemap in sitemaps/test.sitemap with a Text element for each of the items of above.

When restarting openhab, the logs look like this (after everything has stopped):

2019-06-05 13:16:40.524 [INFO ] [ebuilder.internal.HomeBuilderServlet] - Started Home Builder at /homebuilder

2019-06-05 13:16:40.586 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel

2019-06-05 13:16:48.127 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'davis.items'

2019-06-05 13:16:51.284 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007

2019-06-05 13:16:52.245 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'test.sitemap'

2019-06-05 13:16:53.295 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.111.71:8080

2019-06-05 13:16:53.298 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.111.71:8443

2019-06-05 13:16:53.857 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui

2019-06-05 13:16:53.886 [DEBUG] [org.openhab.binding.davis           ] - BundleEvent STARTING - org.openhab.binding.davis

2019-06-05 13:16:53.893 [DEBUG] [inding.davis.internal.DavisActivator] - Davis binding has been started.

2019-06-05 13:16:53.898 [DEBUG] [org.openhab.binding.davis           ] - BundleEvent STARTED - org.openhab.binding.davis

2019-06-05 13:16:53.917 [DEBUG] [org.openhab.binding.davis           ] - ServiceEvent REGISTERED - {org.openhab.model.item.binding.BindingConfigReader, org.openhab.binding.davis.DavisBindingProvider}={service.id=341, service.bundleid=198, service.scope=bundle, component.name=org.openhab.binding.davis.genericbindingprovider, component.id=202} - org.openhab.binding.davis

2019-06-05 13:16:54.317 [DEBUG] [org.openhab.binding.davis           ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={service.id=354, service.bundleid=198, service.scope=bundle, event.topics=openhab/*, service.pid=org.openhab.davis, component.name=org.openhab.binding.davis, component.id=201} - org.openhab.binding.davis

2019-06-05 13:16:54.358 [TRACE] [.binding.davis.internal.DavisBinding] - update() method is called!

Do you have any idea on how to solve this?

Thanks & best regards
lukqw

Solve what? You just said the binding is starting successfully.
And your log snippet doesn’t show any problems.

Sorry!
It’s not working for me, I can’t get any values from the davis weather envoy.

Check the list of running bundles to verify the old davis binding is not running and the new one is.
You might also need to clear the cache, as your output seems to show no davis settings being found.

I think there are no davis settings being found because the config seems to be null @ line 163 in DavisBinding.java. Where should i place the davis.cfg file exactly? /etc/openhab2/services or somewhere else?

As the docs point out, it should be $OPENHAB_CONF/services/.
In windows this is runtime/conf/services/. No clue where it lands in other platforms.

Well I placed the config in /etc/openhab2/services/davis.cfg and it also seems to be loaded, because karaf console gives me the following output when I enter config:list:

Pid:            org.openhab.davis
BundleLocation: file:/usr/share/openhab2/addons/org.openhab.binding.davis-1.12.0-SNAPSHOT.jar
Properties:
   hostName = xxx.xxx.xxx.xxx
   readResponseWaitTime = 1000
   service.pid = org.openhab.davis

But it’s still not working as intended, I don’t get the message in the logs:

ProperlyConfigured with hostName [hostname] with readResponseWaitTime on

I also tried placing a config file with both, a port and Hostname, in the same directory and it also got loaded. But there is a thing I don’t understand which needs some sourcecode:

if (config != null) {
        // to override the default refresh interval one has to add a
        // parameter to openhab.cfg like <bindingName>:refresh=<intervalInMs>
        String refreshIntervalString = (String) config.get("refresh");
        if (StringUtils.isNotBlank(refreshIntervalString)) {
            refreshInterval = Long.parseLong(refreshIntervalString);
        }

        String newPort = (String) config.get("port"); //$NON-NLS-1$
        String newHostName = (String) config.get("hostName"); //$NON-NLS-1$

        if (StringUtils.isBlank(newPort) && StringUtils.isBlank(newHostName)) {
            logger.error("neither port neither hostname configured, no communication possible");
            setProperlyConfigured(false);
        } else {
            if (StringUtils.isNotBlank(newPort) && StringUtils.isNotBlank(newHostName)) {
                logger.warn(
                        "both properties port and hostname configured, only one should be set according communication type serial (port) or IP (hostname)");
            }

This is straight out of the DavisBinding.java. As you can see in the last ‘else’ block:

if the newPort is not blank and the hostName is also not blank - if both are provided - the warning should be logged. But it’s not getting logged!

Do you have any idea how I can check if the config is not null at the first if?

In current code, this is not possible. If I can steal a few minutes, I’ll make a version that spits out a debug message if the config is null.

Try this version.

I tried your version and then the previous one because now it just works.

I have no idea why it suddenly works and I think it has to do with my network because I just moved the setup to a new place.

Glad to hear it.

I’ll look into getting this merged.