Weather binding with OpenWeatherMap API

@cweitkamp
If you read my earlier posts, you will see I have upgraded to the latest snapshot of OH2.4 … :wink:
(Just to be clear, I am using: 2.4.0-SNAPSHOT Build#1378, Binding=market:binding-4126092 - 1.0)

I have deleted the OpenWeather “Current Weather” thing, but that did not help, do I also have to remove and re-instate the API thing as well ??

Please indicate how you want me to generate the log?

Cheers

EDIT: Deleting the OpenWeather API thing, as well as the Current Weather thing did not help …

No, it my hint did not work we have to take a look at the logs. Recreating the API thing will change nothing.

Please go into the Karaf console and enable DEBUG logging for the binding (org.eclipse.smarthome.binding.openweathermap). Restart OH2 or restart the binding or just recreate the thing. Copy and paste the resulting log here. Otherwise send it to me via PM.

@cweitkamp
Hmm, I have an issue with logs they seemed to have stopped with this latest snapshot:

/_/                        2.4.0-SNAPSHOT
                           Build #1378   

Hit ‘’ for a list of available commands
and ‘[cmd] --help’ for help on a specific command.
Hit ‘’ or type ‘system:shutdown’ or ‘logout’ to shutdown openHAB.

openhab> log:get
Command not found: log:get
openhab> log:tail
Command not found: log:tail
openhab>

To be honest, that does not look very good. What is in your openhab.log?

@cweitkamp
Things are not looking good, I get lot’s of:

2018-10-08 08:38:38.411 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing ‘openhab-package-standard’: No matching features for openhab-package-standard/0.0.0
2018-10-08 08:38:38.413 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing ‘openhab-ui-homebuilder, openhab-persistence-rrd4j, openhab-ui-basic, openhab-misc-market, openhab-action-mqtt, openhab-ui-habpanel, openhab-ui-paper, openhab-binding-mqtt1’: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=system; type=karaf.feature; version=“[4.1.5,4.1.5]”; filter:=“(&(osgi.identity=system)(type=karaf.feature)(version>=4.1.5)(version<=4.1.5))”

and I have problems connecting to my MQTT broker as well …

2018-06-03 13:47:17.618 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker
connection
org.eclipse.paho.client.mqttv3.MqttException: Unable to connect to server
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.jav
a:79) [202:org.openhab.io.transport.mqtt:1.12.0]
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:
650) [202:org.openhab.io.transport.mqtt:1.12.0]
at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:?]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:?]

    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)

~[?:?]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:?]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:?]
at java.net.Socket.connect(Socket.java:589) ~[?:?]
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.jav
a:70) ~[?:?]
… 2 more
2018-06-02 15:01:15.371 [ERROR] [org.apache.felix.configadmin ] - Cannot use configurat
ion org.openhab.mqtt for [org.openhab.core.scriptengine.action.ActionService, org.osgi.service
.cm.ManagedService, id=317, bundle=200/mvn:org.openhab.action/org.openhab.action.mqtt/1.12.0]:
No visibility to configuration bound to mvn:org.openhab.io/org.openhab.io.transport.mqtt/1.12
.0
2018-06-02 19:12:08.352 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initiali
zation completed.
2018-06-02 19:12:08.353 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker
connection ‘mosquitto’
2018-06-02 19:12:08.376 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker
connection

In PaperUI, I don’t have any MQTT binding at all since the upgrade …

@cweitkamp
Any comments?

Am I meant to be using the plugin from eclipse or from you? Can you link what I should be running …

@cweitkamp
After removing the eclipse binding and things, installing the latest jar file from the original thread, and re-adding the things, I still get this error:

2018-10-16 14:13:13.604 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing ‘openhab-package-standard’: No matching features for openhab-package-standard/0.0.0
2018-10-16 14:13:13.607 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing ‘openhab-ui-homebuilder, openhab-persistence-rrd4j, openhab-ui-basic, openhab-misc-market, openhab-action-mqtt, openhab-ui-habpanel, openhab-ui-paper, openhab-binding-mqtt1’: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=system; type=karaf.feature; version=“[4.1.5,4.1.5]”; filter:=“(&(osgi.identity=system)(type=karaf.feature)(version>=4.1.5)(version<=4.1.5))”

Is my openhab version wrong

Dear Bernard,

I really like to help you but to be hones, I have no idea whats wrong with your setup. If I should make an educated guess I would tend to a complete reinstall of OH2. I am sorry.

Best,

Christoph

@cweitkamp

Thanks, but I already had done a re-install …

Question: Is it best to add the conf/* files manually after a re-install, or do “restore” with a previous backup file (from 2.3.0) The restore backs up the userdata directory as well, if data in there is from the older version, then added to the new version 2.4.0 … maybe that is upsetting things?

In general yes, but in your case I would restore it only partial. Extract the backup file in a different location and only restore things, items and rules.

@cweitkamp
Hi, I got it working with a complete re-install of the latest snapshot, and manually placing my files (items,sitemaps) etc back in place … it seems the snapshot from 4 Nov- 18 was broke…

I installed the latest 2.4.0 mqtt bindings, but it does not work …
I have told the mqtt-eventbus.cfg file the name of my broker:

name of the broker as it is defined in the openhab.cfg. If this property is not available, no event bus MQTT binding will be created.
broker=mosquitto

But that name has to be in openhab.cfg pointing to my broker, but for the life of me, I can’t find that file anywhere, anyone know where it lives … I can’t see it under conf or /etc

Use the 1.x version of the mqtt binding, see MQTT - big issues since upgrading to 2.4.0 Snapshot

Thanks, I did that … now works.

Regarding the weather, I have linked my item to the Temperature, but I still don’t get anything displayed …

The link is:

openweathermap:weather:api:local:current#temperature

and the item is:

Number:Temperature CurrentTemperature "Current temperature [%.1f C]" &lt;temperature&gt; { channel="openweathermap:weather:api:local:current#temperature" }

EDIT: Removed openweather things for the umteenth times, and re-instated … now works :slight_smile:

If I want to publish the openweather temperature is this correct:

Number:Temperature CurrentTemperature "Current temperature [%.1f %unit%]" &lt;temperature&gt; { channel="openweathermap:weather:api:local:current#temperature" }
Number CurrentTemperature {mqtt="&gt;[mosquitto:/Garden/Aeroponics/AirTemp:command:*:default]"}

No, you can’t have two items with the same name!
But you can have two bindings in the same item!

Number:Temperature CurrentTemperature "Current temperature [%.1f %unit%]" <temperature> { channel="openweathermap:weather:api:local:current#temperature", mqtt=">[mosquitto:/Garden/Aeroponics/AirTemp:state:*:default]" }

Note that I changed the command to state in the mqtt binding so that the number gets published on a state change.

@vzorglub
Hmm, ok, but when I do that and restart openhab, the UI just locks up, a page refresh updates some readings, but not the regular fast updating I am used to …

I wonder if the temperature reading is blasting away at a great rate, rather than only when it changes …
(what does “state” mean in this case anyway …?)

It’s all in the docs:

https://www.openhab.org/addons/bindings/mqtt1/

Describes what the message content contains: a status update or command. Allowed values are ‘state’ or ‘command’.

It is usually faster to take a look at the docs than to wait hours for an answer in the forum.

1 Like

It had seen that documentation, but I did not “understand” it, thus the request to the forum, as I had a sneeking suspicion that was what forum’s were for … :slight_smile:

@bmentink,
The MQTT binding can do two things publish and subcribe to topics.
When using the outbound (publish) syntax broker:topic:trigger:value:transform
the trigger part can be either command or state

Now on a normal binding, only the command like in item.sendCommand() would be executed to send a value to your “thing” in the real world.
The MQTT binding can also react on a state change (When the value of the item changes or gets updates)

In your case, the value gets updated from the first binding (openweathermap). The value changes and does send a command to the item. So we need the MQTT binding, in your case, to send a value when the state changes so we use the syntax broker:topic:state:*:default (Whenever the state changes or gets updated) the binding will send that state over mqtt on the topic the the broker.

Does that make sense?

Yep, that makes sense … thanks.
Still not sure why the UI locks up when I add that line though …