Getting MySensors MQTT Gateway working on OpenHAB 2.2 (Stable)
-
Did that, MQTT bridge stuck at "initializing". Not the full answer yet, but thanks @timo for your effort!
Openhab.log when I checked the Services - MQTT in Paper UI
2018-06-08 00:59:19.162 [ERROR] [rotocol.mqtt.MySensorsMqttConnection] - MQTT connection offline - Reason unknown 2018-06-08 00:59:19.221 [WARN ] [me.config.core.internal.ConfigMapper] - Could not set field value for field 'port': For input string: "1883.0" java.lang.NumberFormatException: For input string: "1883.0" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:?] at java.lang.Integer.parseInt(Integer.java:580) [?:?] at java.lang.Integer.valueOf(Integer.java:766) [?:?] at org.eclipse.smarthome.config.core.internal.ConfigMapper.objectConvert(ConfigMapper.java:159) [98:org.eclipse.smarthome.config.core:0.10.0.oh230] at org.eclipse.smarthome.config.core.internal.ConfigMapper.as(ConfigMapper.java:98) [98:org.eclipse.smarthome.config.core:0.10.0.oh230] at org.eclipse.smarthome.config.core.Configuration.as(Configuration.java:54) [98:org.eclipse.smarthome.config.core:0.10.0.oh230] at org.eclipse.smarthome.io.transport.mqtt.internal.MqttBrokerConnectionServiceInstance.modified(MqttBrokerConnectionServiceInstance.java:77) [207:org.eclipse.smarthome.io.transport.mqtt:0.10.0.oh230] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?] at org.apache.felix.scr.impl.inject.BaseMethod.invokeMethod(BaseMethod.java:229) [41:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.inject.BaseMethod.access$500(BaseMethod.java:39) [41:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke(BaseMethod.java:650) [41:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.inject.BaseMethod.invoke(BaseMethod.java:506) [41:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:307) [41:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:299) [41:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeModifiedMethod(SingleComponentManager.java:772) [41:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.modify(SingleComponentManager.java:727) [41:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManager.java:645) [41:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManager.java:609) [41:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.configurationUpdated(ConfigurableComponentHolder.java:426) [41:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.RegionConfigurationSupport.configurationEvent(RegionConfigurationSupport.java:284) [41:org.apache.felix.scr:2.0.12] at org.apache.felix.scr.impl.manager.RegionConfigurationSupport$1.configurationEvent(RegionConfigurationSupport.java:89) [41:org.apache.felix.scr:2.0.12] at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.sendEvent(ConfigurationManager.java:2090) [8:org.apache.felix.configadmin:1.8.16] at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.run(ConfigurationManager.java:2058) [8:org.apache.felix.configadmin:1.8.16] at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141) [8:org.apache.felix.configadmin:1.8.16] at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109) [8:org.apache.felix.configadmin:1.8.16] at java.lang.Thread.run(Thread.java:748) [?:?] 2018-06-08 00:59:19.340 [WARN ] [.MqttBrokerConnectionServiceInstance] - Ignore existing broker connection configuration for: mosquitto``` -
@masmat please check your MQTT configuration. You're receiving an exception because it's trying to set "1883.0" for the value port.
-
How close is this for 2.3? Worth a try? or should I hold? Thanks for the work so far on it!
-
How close is this for 2.3? Worth a try? or should I hold? Thanks for the work so far on it!
@crankycoder Unfortunately there are still issues with the mqtt implementation. I reverted back to 2.2 yesterday as all my fiddling didn't help.
-
my setup is still just using the direct mqtt subscription so i will hold off.
is there any discovery working (in 2.2 that is) how about once you configure the things. do you get all the properties of that item from when it presents?
-
my setup is still just using the direct mqtt subscription so i will hold off.
is there any discovery working (in 2.2 that is) how about once you configure the things. do you get all the properties of that item from when it presents?
@crankycoder in 2.2 with appropriate binding mysensors is working pretty well. All variables are presented with mysensors lib 2.2.
I only updated openhab to 2.3 as this release was presented on my debian system. But I didn't get 2.3 working with mysensors mqtt. -
I did an upgrade the other week from 1.8 to 2.2. Then right about the time I had some stuff working 2.3 came out. So I figured since I have to do all the learning curve anyways I might as well stick with 2.3. The variables being presented in mysensors would be HUGE for me. But hopefully it's not too far out.
-
@jogant There already is a working version (2.4 SNAPSHOT) available on the marketplace and on my server. Please let me know if you expierence any problems.
@timo unfortunately this also does not work for me. I followed your manual very well but I always get errors. It starts after installing feature:install esh-io-transport-mqtt and mysensors binding:
16:59:57.772 [ERROR] [protocol.mqtt.MySensorsMqttConnection] - MQTT connection offline - Reason unknown 16:59:57.806 [INFO ] [o.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.96.8' with clientid paho1135997459230242 and file store '/var/lib/openhab2/mqtt/192.168.96.8' 16:59:57.867 [ERROR] [protocol.mqtt.MySensorsMqttConnection] - MQTT connection offline - {} org.eclipse.paho.client.mqttv3.MqttException: MqttException at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38) [229:org.eclipse.paho.client.mqttv3:1.0.2] at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:604) [229:org.eclipse.paho.client.mqttv3:1.0.2] at java.lang.Thread.run(Thread.java:748) [?:?] Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:210) ~[?:?] at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[?:?] at sun.security.ssl.InputRecord.readFully(InputRecord.java:465) ~[?:?] at sun.security.ssl.InputRecord.read(InputRecord.java:503) ~[?:?] at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983) ~[?:?] at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385) ~[?:?] at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413) ~[?:?] at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397) ~[?:?] at org.eclipse.paho.client.mqttv3.internal.SSLNetworkModule.start(SSLNetworkModule.java:89) ~[?:?] at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:590) ~[?:?] ... 1 moreand reconection starts every 10 seconds.
It must be interference with mqtt1 bindung that I use for eventbus.
The mqtt-bridge remains Offline.
What is wrong? -
@timo unfortunately this also does not work for me. I followed your manual very well but I always get errors. It starts after installing feature:install esh-io-transport-mqtt and mysensors binding:
16:59:57.772 [ERROR] [protocol.mqtt.MySensorsMqttConnection] - MQTT connection offline - Reason unknown 16:59:57.806 [INFO ] [o.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.96.8' with clientid paho1135997459230242 and file store '/var/lib/openhab2/mqtt/192.168.96.8' 16:59:57.867 [ERROR] [protocol.mqtt.MySensorsMqttConnection] - MQTT connection offline - {} org.eclipse.paho.client.mqttv3.MqttException: MqttException at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38) [229:org.eclipse.paho.client.mqttv3:1.0.2] at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:604) [229:org.eclipse.paho.client.mqttv3:1.0.2] at java.lang.Thread.run(Thread.java:748) [?:?] Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:210) ~[?:?] at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[?:?] at sun.security.ssl.InputRecord.readFully(InputRecord.java:465) ~[?:?] at sun.security.ssl.InputRecord.read(InputRecord.java:503) ~[?:?] at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983) ~[?:?] at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385) ~[?:?] at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413) ~[?:?] at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397) ~[?:?] at org.eclipse.paho.client.mqttv3.internal.SSLNetworkModule.start(SSLNetworkModule.java:89) ~[?:?] at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:590) ~[?:?] ... 1 moreand reconection starts every 10 seconds.
It must be interference with mqtt1 bindung that I use for eventbus.
The mqtt-bridge remains Offline.
What is wrong?@jogant Indeed this looks like an error in your configuration. I suspect the MQTT configuration. Did you change the MQTT configuration according my posting above? I've also added a text to the Wiki. The name and content of the MQTT configuration differs between OpenHAB 2.2 and 2.3.
-
@jogant Indeed this looks like an error in your configuration. I suspect the MQTT configuration. Did you change the MQTT configuration according my posting above? I've also added a text to the Wiki. The name and content of the MQTT configuration differs between OpenHAB 2.2 and 2.3.
@timo with 2.2 I had two configurations which were very similar.
I have one mosquitto mqtt broker on localhost, version 1.5.
The mqtt1 binding is for my mqtt-eventbus connection is called mosquitto and the config file (mqtt.cfg) is as follows:mosquitto.url=tcp://192.168.96.8:1883 mosquitto.retain=false mosquitto.clientId=openhab mosquitto.user=user mosquitto.pwd=pwdWith OH2.2 this configuration works. It also works with 2.3 as I can see all openhab events on my mosquitto.
My mysonsors binding is configured by org.eclipse.smarthome.mqttbroker.cfg config file which looks as follows:name=mosquittomys host=192.168.96.8 port=1883 retain=false username=username password=password clientId=openhabMysI also tried without authentication and also without clientId, all to no succuess.
I cleaned /var/lib/openhab2/cache/ folder and /var/lib/openhab2/tmp/ folder.
I looked at /var/lib/openhab2/config folder for resulting runtime configuration, but all looks fine. Do you have any further idea? -
@jogant Indeed this looks like an error in your configuration. I suspect the MQTT configuration. Did you change the MQTT configuration according my posting above? I've also added a text to the Wiki. The name and content of the MQTT configuration differs between OpenHAB 2.2 and 2.3.
@timo I found the fault in my configuration: it was the missing secure=false config flag in the org.eclipse.smarthome.mqttbroker.cfg config file. I have no idea what happens when the flag is missing but without it one doesn't achieve a valid connection.
name=mosquittomys host=192.168.96.8 port=1883 secure=false <-- important !So now I have a working 2.3 installation! Thanks alot for your support.
-
@timo I found the fault in my configuration: it was the missing secure=false config flag in the org.eclipse.smarthome.mqttbroker.cfg config file. I have no idea what happens when the flag is missing but without it one doesn't achieve a valid connection.
name=mosquittomys host=192.168.96.8 port=1883 secure=false <-- important !So now I have a working 2.3 installation! Thanks alot for your support.
-
I'm still unsuccesful.
Do I need to reinstall all the files as well? I didn't find a new set of instructions.In my /etc/openhab2/services-folder I have:
mqtt-eventbus.cfg containing justbroker=mosquittoand org.eclipse.smarthome.mqttbroker.cfg:
name=mosquitto host=127.0.0.1 secure=false port=1883 secure=false username=XXXX password=YYYYY retain=false clientId=openhabMysopenhab.log everything mysensors related:
2018-07-09 06:40:36.782 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '127.0.0.1' with clientid paho175068223000 and file store '/var/lib/openhab2/mqtt/127.0.0.1' 2018-07-09 06:40:37.050 [DEBUG] [org.openhab.binding.mysensors ] - BundleEvent STARTING - org.openhab.binding.mysensors 2018-07-09 06:40:37.075 [DEBUG] [org.openhab.binding.mysensors ] - BundleEvent STARTED - org.openhab.binding.mysensors 2018-07-09 06:40:37.206 [DEBUG] [org.openhab.binding.mysensors ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={service.id=119, service.bundleid=13, service.scope=bundle, component.name=org.openhab.binding.mysensors.factory.MySensorsHandlerFactory, component.id=17} - org.openhab.binding.mysensors 2018-07-09 06:42:36.466 [WARN ] [lipse.smarthome.io.net.exec.ExecUtil] - Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "arping" (in directory "."): error=2, Tiedostoa tai hakemistoa ei ole) 2018-07-09 06:42:36.685 [INFO ] [ternal.dhcp.DHCPPacketListenerServer] - DHCP request packet listener online 2018-07-09 06:42:37.484 [DEBUG] [nsors.handler.MySensorsBridgeHandler] - Initialization of the MySensors bridge 2018-07-09 06:42:38.136 [DEBUG] [ensors.factory.MySensorsCacheFactory] - Cache file: given_ids.cached exist. 2018-07-09 06:42:38.178 [DEBUG] [ensors.factory.MySensorsCacheFactory] - Cache (given_ids) content: [0, 1, 99, 4, 5] 2018-07-09 06:42:38.608 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - Enabling connection watchdog 2018-07-09 06:42:38.830 [DEBUG] [org.openhab.binding.mysensors ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={service.id=281, service.bundleid=13, service.scope=singleton} - org.openhab.binding.mysensors 2018-07-09 06:42:38.897 [DEBUG] [.discovery.MySensorsDiscoveryService] - Starting MySensors discovery scan 2018-07-09 06:42:38.926 [DEBUG] [nsors.handler.MySensorsBridgeHandler] - Initialization of the MySensors bridge DONE!Anyone spot what's still wrong?
P.S. I remember seeing someone got MyS gateway to log to a different file. Does anyone know how to implement that in the ./configure -command? Or how can I do that?
-
I'm still unsuccesful.
Do I need to reinstall all the files as well? I didn't find a new set of instructions.In my /etc/openhab2/services-folder I have:
mqtt-eventbus.cfg containing justbroker=mosquittoand org.eclipse.smarthome.mqttbroker.cfg:
name=mosquitto host=127.0.0.1 secure=false port=1883 secure=false username=XXXX password=YYYYY retain=false clientId=openhabMysopenhab.log everything mysensors related:
2018-07-09 06:40:36.782 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '127.0.0.1' with clientid paho175068223000 and file store '/var/lib/openhab2/mqtt/127.0.0.1' 2018-07-09 06:40:37.050 [DEBUG] [org.openhab.binding.mysensors ] - BundleEvent STARTING - org.openhab.binding.mysensors 2018-07-09 06:40:37.075 [DEBUG] [org.openhab.binding.mysensors ] - BundleEvent STARTED - org.openhab.binding.mysensors 2018-07-09 06:40:37.206 [DEBUG] [org.openhab.binding.mysensors ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={service.id=119, service.bundleid=13, service.scope=bundle, component.name=org.openhab.binding.mysensors.factory.MySensorsHandlerFactory, component.id=17} - org.openhab.binding.mysensors 2018-07-09 06:42:36.466 [WARN ] [lipse.smarthome.io.net.exec.ExecUtil] - Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "arping" (in directory "."): error=2, Tiedostoa tai hakemistoa ei ole) 2018-07-09 06:42:36.685 [INFO ] [ternal.dhcp.DHCPPacketListenerServer] - DHCP request packet listener online 2018-07-09 06:42:37.484 [DEBUG] [nsors.handler.MySensorsBridgeHandler] - Initialization of the MySensors bridge 2018-07-09 06:42:38.136 [DEBUG] [ensors.factory.MySensorsCacheFactory] - Cache file: given_ids.cached exist. 2018-07-09 06:42:38.178 [DEBUG] [ensors.factory.MySensorsCacheFactory] - Cache (given_ids) content: [0, 1, 99, 4, 5] 2018-07-09 06:42:38.608 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - Enabling connection watchdog 2018-07-09 06:42:38.830 [DEBUG] [org.openhab.binding.mysensors ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={service.id=281, service.bundleid=13, service.scope=singleton} - org.openhab.binding.mysensors 2018-07-09 06:42:38.897 [DEBUG] [.discovery.MySensorsDiscoveryService] - Starting MySensors discovery scan 2018-07-09 06:42:38.926 [DEBUG] [nsors.handler.MySensorsBridgeHandler] - Initialization of the MySensors bridge DONE!Anyone spot what's still wrong?
P.S. I remember seeing someone got MyS gateway to log to a different file. Does anyone know how to implement that in the ./configure -command? Or how can I do that?
@masmat two things come to my mind: I have two different broker-names for eventbus connection and mysensors connection. For eventbus binding you need classic mqtt1 binding with its own configuration like this:
mosquitto.url=tcp://127.0.0.1:1883 mosquitto.retain=false mosquitto.clientId=openhab mosquitto.user=user mosquitto.pwd=pwdAnd second: can you show your mysensors bridge configuration? Not shure but debug log looks like an ethernet bridge and not a mqtt bridge.
-
Not sure how to answer some of your questions...but here goes.
configuration:sudo ./configure --my-transport=nrf24 --my-rf24-irq-pin=15 --my-signing-debug --my-signing=password --my-signing-password=XXXXXXXX --my-gateway=mqtt --my-controller-ip-address=127.0.0.1 --my-mqtt-user=YYYY --my-mqtt-password=ZZZZZ --my-mqtt-publish-topic-prefix=mysensors-out --my-mqtt-subscribe-topic-prefix=mysensors-in --my-mqtt-client-id=mygateway1 --my-leds-err-pin=12 --my-leds-rx-pin=16 --my-leds-tx-pin=18I'm not sure what "eventbus"-binding is. Something I need to install in Paper UI?
Is the configuration file mqtt-eventbus.cfg or something else? Should I try to install it? I have not installed the MQTT binding in OpenHab because at least originally the instructions said not to. -
Not sure how to answer some of your questions...but here goes.
configuration:sudo ./configure --my-transport=nrf24 --my-rf24-irq-pin=15 --my-signing-debug --my-signing=password --my-signing-password=XXXXXXXX --my-gateway=mqtt --my-controller-ip-address=127.0.0.1 --my-mqtt-user=YYYY --my-mqtt-password=ZZZZZ --my-mqtt-publish-topic-prefix=mysensors-out --my-mqtt-subscribe-topic-prefix=mysensors-in --my-mqtt-client-id=mygateway1 --my-leds-err-pin=12 --my-leds-rx-pin=16 --my-leds-tx-pin=18I'm not sure what "eventbus"-binding is. Something I need to install in Paper UI?
Is the configuration file mqtt-eventbus.cfg or something else? Should I try to install it? I have not installed the MQTT binding in OpenHab because at least originally the instructions said not to.@masmat I just wanted to understand your configuration. So I read through whole thread and saw your problems began with upgrade to OH2.3.
I mentioned eventbus as you wrote something about eventbus.cfg.
You need eventbus only if you want to send all oh events to mqtt broker.
I wanted to see your mqtt bridge configuration. You can either configure dynamicly via paper ui or you set it up via things file. The later is what I did. So here is my things file with bridge configuration.Bridge mysensors:bridge-mqtt:gateway [ brokerName="mosquittomys", topicPublish="mysensors1/in", topicSubscribe="mysensors1/out", startupCheckEnabled=true ] { }Here the brokername has to be the same as in mqttbroker.cfg. Fix topic names to match your mysensors gateway.
Hope this is of any help. -
This post is deleted!
-
@masmat I just wanted to understand your configuration. So I read through whole thread and saw your problems began with upgrade to OH2.3.
I mentioned eventbus as you wrote something about eventbus.cfg.
You need eventbus only if you want to send all oh events to mqtt broker.
I wanted to see your mqtt bridge configuration. You can either configure dynamicly via paper ui or you set it up via things file. The later is what I did. So here is my things file with bridge configuration.Bridge mysensors:bridge-mqtt:gateway [ brokerName="mosquittomys", topicPublish="mysensors1/in", topicSubscribe="mysensors1/out", startupCheckEnabled=true ] { }Here the brokername has to be the same as in mqttbroker.cfg. Fix topic names to match your mysensors gateway.
Hope this is of any help.@jogant Finally had time to double check this:
Paper UI:Broker Name mosquitto Subscription Topic mygateway1-out Publish Topic mygateway1-in Send Delay 100 Startup check enabled Metric answer enabled Network sanity check enabled Interval to launch network sanity check 3 Attempts before disconnecting the bridge 3 Heartbeat disabled Attempts before disconnecting nodes 10EDIT: I noticed I have different topics in MQTT, corrected AND I did:
cd /usr/share/openhab2/addons/ wget http://www.oberfoell.com/openhab2/org.openhab.binding.mysensors-2.4.0-SNAPSHOT.jar <== THIS probably fixed it! chown for the same file rm org.openhab.binding.mysensors-2.3.0-SNAPSHOT.jarNow my MQTT Gw is ONLINE, in Paper UI I just selected the bridge for every individual Thing and now it works.
Hope this helps people strugling with this.