Getting MySensors MQTT Gateway working on OpenHAB 2.2 (Stable)

  • Here are step by step instructions for taking a vanilla OpenHabian 2.2 and adding MQTT Gateway and MySensors to it. This may change, but at the date of this post and with the versions / snapshots below, this currently works:

    Pre-requisites / configuation:

    GatewayW1500MQTTClient I have setup as follows:

    #define MY_RADIO_NRF24
    #define MY_RF24_PA_LEVEL RF24_PA_MIN // ONLY FOR nrf24L01+ Enhanced, it reduces the output of the nrf24L01 otherwise rfaxis power amp overloads and starts corrupting messages
    #define MY_RF24_CHANNEL (109) // 0-126: Note specifying a channel >= 108 clears most of the wifi interference.

    // Security (Signing)
    #define MY_SIGNING_SOFT
    //For the software backed signing backend, an unconnected analog pin is required on boards that does not provide a hardware based random generator unit to set a
    //random seed for the pseudo-random generator. It is important that the pin is floating, or the output of the pseudo-random generator will be predictable, and thus compromise the signatures.

    #define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin
    #define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin
    #define MY_DEFAULT_TX_LED_PIN 9 // the PCB, on board L


    // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
    //#define MY_W5100_SPI_EN 4

    // Enable Soft SPI for NRF radio (note different radio wiring is required)
    // The W5100 ethernet module seems to have a hard time co-operate with
    // radio on the same spi bus.
    #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
    #define MY_SOFTSPI
    #define MY_SOFT_SPI_SCK_PIN A0
    #define MY_SOFT_SPI_MISO_PIN A2
    #define MY_SOFT_SPI_MOSI_PIN A1

    // When W5100 is connected we have to move CE/CSN pins for NRF radio
    #ifndef MY_RF24_CE_PIN
    #define MY_RF24_CE_PIN 5
    #ifndef MY_RF24_CS_PIN
    #define MY_RF24_CS_PIN 6

    #define MY_MAC_ADDRESS 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX <--- CHANGE TO YOUR MAC ADDRESS

    // Static ip setup, otherwise if not defined, dhcp is used
    //#define MY_IP_ADDRESS 192,168,178,87
    //#define MY_IP_SUBNET_ADDRESS 255,255,255,0
    //#define MY_IP_GATEWAY_ADDRESS 192,168,178,1

    // MQTT broker ip address or url. Define one or the other.

    // The MQTT broker port to to open
    #define MY_PORT 1883

    // Enable these if your MQTT broker requires usenrame/password

    // Set MQTT client id
    #define MY_MQTT_CLIENT_ID "mysensors-1"

    // Set this node's subscribe and publish topic prefix
    #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
    #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"


    1. Boot Raspberry pi from SD Card connected to ethernet (if you have any wifi connectivity problems, parts of the installation fail, and you get an incomplete install, that doesn't necessarily fail to complete, hence use ethernet till built)

    2. After about 2-3 mins, connect to the Pi with: ssh openhabian@IP_ADDRESS (password: openhabian) and you will see the install in progress

    3. Watch until installation has finished (approx 25mins depending on connection speed), the last entry will be "First time setup successfully finished". There should be no errors (except: sed: -e expression #1, char 5: unterminated address regex), if you're getting other errors, retry it (you need to make up the SD Card with the image again), if errors are randomly happening, suspect the SD Card.

    4. Ctrl-C and type sudo reboot

    5. Verify Installation: After about 5 mins you should be able to connect to: http://IP_ADDRESS:8080, select Standard Setup and wait until PaperUI and HABPanel have appeared
      Also: http://IP_ADDRESS:9001 should show no errors

    6. ssh openhabian@IP_ADDRESS
      sudo openhabian-config
      Change openhab-cli password:

      System Settings / Change Passwords / openHAB Console: and set to something, we'll need this when logging into openhab-cli, we'll call this password_openhab-cli

      Add Mosquitto:

      Optional Components / Mosquitto, set password to something (we'll call this password_mosquitto), needs to match the one in your MySensors gateway and the one in the next step.


    7. Configuring MQTT:

    cd /srv/openhab2-conf/services
    nano org.eclipse.smarthome.mqtt.cfg   (or use your favorite editor)


    mosquitto.pwd=YOUR_PASSWORD_GOES_HERE   (This is password_mosquitto referenced previously)
    (NOTE: We don't add clientId here, it causes problems and prevents both OpenHab and MySensors connecting due to multiple id's (persistance in use errors).  Allowing the id's to be auto and uniquely assigned, will prevent this clash)

    save the file and exit

    nano mqtt-eventbus.cfg



    save the file and exit

    sudo chown openhab:openhabian org.eclipse.smarthome.mqtt.cfg mqtt-eventbus.cfg

    Remove the backup files:

    cd /var/lib/openhab2/config/org/openhab
    rm mqtt-eventbus.config
    cd ../eclipse/smarthome
    rm mqtt.config
    sudo reboot

    Power cycle or switch on your already configured MySensors MQTT Gateway

    1. ssh openhabian@IP_ADDRESS
      After a few minutes, visit: http://IP_ADDRESS:9001
      You should have no errors.

    2. Installing MySensors:
      openhab-cli console
      (if password prompt doesn’t appear after a while, ctrl-c and try again, it can take a while or timeout the first few times after installation, this is password_openhab-cli)

    feature:install openhab-transport-serial
    feature:install esh-io-transport-mqtt
    cd /srv/openhab2-addons
    sudo chown openhab:openhabian org.openhab.binding.mysensors-2.3.0-SNAPSHOT.jar
    openhab-cli console
    Check the features and services we need are active:
    feature:list | grep openhab-transport-serial	(Should say Started)
    feature:list | grep esh-io-transport-mqtt	(Should say Started)
    bundle:list | grep MySensors			(Should say Active)
    bundle:list | grep nrjavaserial			(Should say Active)
    sudo reboot
    1. ssh openhabian@IP_ADDRESS
      After a few minutes, visit: http://IP_ADDRESS:9001
      You should have no errors.

    Check mosquitto is running and gateway is connected:

    cd /var/log/mosquitto
    tail -f mosquitto.log
       526088756: mosquitto version 1.4.10 (build date Fri, 22 Dec 2017 08:19:25 +0000) starting
       1526088756: Config loaded from /etc/mosquitto/mosquitto.conf.
       1526088756: Opening ipv4 listen socket on port 1883.
       1526088756: Opening ipv6 listen socket on port 1883.
       1526088764: New connection from on port 1883.
       1526088764: New client connected from as mysensors-1 (c1, k15, u'openhabian'). <-- This is the MySensors MQTT Gateway connecting)
       1526088783: New connection from on port 1883.						<-- This is the MQTT Service on the Raspberry Pi Connecting
       (If you're not seeing the above, power cycle the MySensors MQTT Gateway)
    1. Adding MySensors Binding in PaperUI:
      Visit: http://IP_ADDRESS:8080 and click on PaperUI
    Choose Inbox / + / MySensors Binding / MySensors MQTT Gateway
       Enable: "Enabled the startup check"
       Enable: "Enabled network sanity check"
       (all other settings remain at the default, but you might want to change Imperial/Metric for your preference)
       Click the "Blue" Checkmark at the top to save.
    Choose Configuration / Things (you may have to reload the page)
       MySensors MQTT Gateway should be ONLINE, if not, check your Gateway is configured correctly.
    sudo reboot
    1. After a few minutes, visit: http://IP_ADDRESS:9001
      You should have no errors.
      Visit: http://IP_ADDRESS:8080 and click on PaperUI
      Visit Configuration / Things, MySensors MQTT Gateway should still be ONLINE

      ssh openhabian@IP_ADDRESS

      Check mosquitto is running and gateway is connected:
      cd /var/log/mosquitto
      tail mosquitto.log

      It should look like this:

    1526089285: mosquitto version 1.4.10 (build date Fri, 22 Dec 2017 08:19:25 +0000) starting
    1526089285: Config loaded from /etc/mosquitto/mosquitto.conf.
    1526089285: Opening ipv4 listen socket on port 1883.
    1526089285: Opening ipv6 listen socket on port 1883.
    1526089294: New connection from on port 1883.
    1526089294: New client connected from as mysensors-1 (c1, k15, u'openhabian').
    1526089312: New connection from on port 1883.

    CONGRATULATIONS, gateway and mysensors are now setup

    1. Now you want to add some mysensors things into PaperUI. Easiest way is to power cycle the sensor, this should result in the sensor appear in the Inbox in PaperUI. For example, I built an RGB Light, when I power cycle it, I see in the Inbox:
      MySensors Device (1;1) RGB Light Sensor: mysensors:rgbLight:a6e1bcda:rgblight_1_1

      Click on the Blue checkmark, and click "Add As Thing"
      Go to Configuration / Things, and you should see the MySensors Device(1;1) show up
      Click the bolded title of the sensor (MySensors Device (1;1) and check the blue circles you want to see the data for one by one. Each one pops up a "Link Channel" message, change item to "Create new item" and select "Link"

      That newly added item will now show up in Configuration / Items and also in "Control" so you can change it's status

    2. If you're new to this, checkout HABPanel, use PaperUI to setup items, but HABPanel to present a UI for use.

  • Great instructions, thanks!
    My problems started yesterday with my OpenHab2 updating to 2.3.0.

    I'm using Rpi Zero W / DietPi - conf to MQTT gw. Mosquitto and mysgw service work OK. Everything else doesn't.
    My problems briefly from the logs:

    1527624943: New client connected from as mygateway1 (c1, k15, u'masi').
    1527626485: New connection from on port 1883.
    1527626485: New client connected from as mosqsub/3760-DietPi (c1, k60, u'masi').
    1527626499: Socket error on client mosqsub/3760-DietPi, disconnecting.

    OpenHab (edited):

    2018-05-29 23:17:17.655 [DEBUG] [org.openhab.binding.mysensors       ] - BundleEvent STARTING - org.openhab.binding.mysensors
    2018-05-29 23:17:17.880 [DEBUG] [org.openhab.binding.mysensors       ] - BundleEvent STARTED - org.openhab.binding.mysensors
    2018-05-29 23:17:18.019 [DEBUG] [org.openhab.binding.mysensors       ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={, service.bundleid=13, service.scope=bundle,,} - org.openhab.binding.mysensors
    2018-05-29 23:19:24.908 [WARN ] [] - Execution failed (Exit value: -559038737. Caused by Cannot run program "arping" (in directory "."): error=2, Tiedostoa tai hakemistoa ei ole)
    2018-05-29 23:19:25.184 [INFO ] [ternal.dhcp.DHCPPacketListenerServer] - DHCP request packet listener online
    2018-05-29 23:19:25.985 [DEBUG] [nsors.handler.MySensorsBridgeHandler] - Initialization of the MySensors bridge
    2018-05-29 23:19:26.257 [DEBUG] [ensors.factory.MySensorsCacheFactory] - Cache file: given_ids.cached exist.
    2018-05-29 23:19:26.315 [DEBUG] [ensors.factory.MySensorsCacheFactory] - Cache (given_ids) content: [0, 1, 99, 4, 5]
    2018-05-29 23:19:26.594 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - Enabling connection watchdog
    2018-05-29 23:19:26.795 [ERROR] [rotocol.mqtt.MySensorsMqttConnection] - No connection to broker: mosquitto
    2018-05-29 23:19:26.834 [DEBUG] [org.openhab.binding.mysensors       ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={, service.bundleid=13, service.scope=singleton} - org.openhab.binding.mysensors
    2018-05-29 23:19:26.925 [DEBUG] [.discovery.MySensorsDiscoveryService] - Starting MySensors discovery scan
    2018-05-29 23:19:27.032 [INFO ] [ateway.MySensorsNetworkSanityChecker] - Network Sanity Checker thread stopped
    2018-05-29 23:19:27.191 [DEBUG] [ensors.factory.MySensorsCacheFactory] - Writing on cache given_ids, content: [0,1,99,4,5]
    2018-05-29 23:19:27.242 [DEBUG] [nsors.handler.MySensorsBridgeHandler] - Initialization of the MySensors bridge DONE!
    2018-05-29 23:19:27.250 [ERROR] [rotocol.mqtt.MySensorsMqttConnection] - Failed connecting to retry in 10 seconds (Retry No.:0)

    I've gone through your steps, Mysensors MQTT gateway remain offline.
    What I'm wondering (since the directory structure is different), what is the total content of file: mqtt-eventbus.cfg? Can you post?


  • Hey,

    same Problem here. After upgrading to OpenHAB 2.3 i receive the same errors in my /var/log/openhab2/openhab.log

    2018-05-31 16:28:42.776 [ERROR] [rotocol.mqtt.MySensorsMqttConnection] - No connection to broker: mosquitto
    2018-05-31 16:28:42.918 [ERROR] [rotocol.mqtt.MySensorsMqttConnection] - Failed connecting to retry in 10 seconds (Retry No.:0)

  • Hero Member

    @andre_m87 & @MasMat : I have the same problem here. Looks like a change in the OpenHAB MQTT implementation.
    I'm working on it.

  • Hero Member

    @andre_m87 & @MasMat : I found a solution and indeed the MQTT implementation in OH2 (ESH) changed. This was a hard nut to crack, so it took me a while.

    Here are the steps you need to do:

    1. Rename: org.eclipse.smarthome.mqtt.cfg to org.eclipse.smarthome.mqttbroker.cfg
    2. Change the content to:

    If you're using a secure connection (SSL): change secure to true and use the correct port.

    Another intersting feature in OpenHAB 2.3 is the embedded broker, so there is no need to have a separate MQTT server up and running.

  • @timo unfortunately this solution doesn't work for me.
    After update oh to version 2.3 I don't get mqtt to work. Prior I used mqtt for mysensors and for eventbus. I configured two broker connections and set up a mysensors-mqtt-bridge via things-file. In the broker all events from openhab arrived and all mysensors-messages arrived in openhab.
    After update mysensors doesn't work at all, allthough I followed your instructions. If I setup mqtt1 binding I can see eventbus messages in mqtt broker but my mysensors-mqtt-gateway remains initializing.

    What I'm doing wrong?

  • Hero Member

    @jogant Yeah. 😞 There are still some problems with 2.3 to fix. The binding works fine within the development IDE, but only there. I'm still looking into it.

  • 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( ~[?:?]
    	at java.lang.Integer.parseInt( [?:?]
    	at java.lang.Integer.valueOf( [?:?]
    	at org.eclipse.smarthome.config.core.internal.ConfigMapper.objectConvert( [98:org.eclipse.smarthome.config.core:0.10.0.oh230]
    	at [98:org.eclipse.smarthome.config.core:0.10.0.oh230]
    	at [98:org.eclipse.smarthome.config.core:0.10.0.oh230]
    	at []
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke( ~[?:?]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke( ~[?:?]
    	at java.lang.reflect.Method.invoke( ~[?:?]
    	at org.apache.felix.scr.impl.inject.BaseMethod.invokeMethod( [41:org.apache.felix.scr:2.0.12]
    	at org.apache.felix.scr.impl.inject.BaseMethod.access$500( [41:org.apache.felix.scr:2.0.12]
    	at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke( [41:org.apache.felix.scr:2.0.12]
    	at org.apache.felix.scr.impl.inject.BaseMethod.invoke( [41:org.apache.felix.scr:2.0.12]
    	at org.apache.felix.scr.impl.inject.ActivateMethod.invoke( [41:org.apache.felix.scr:2.0.12]
    	at org.apache.felix.scr.impl.inject.ActivateMethod.invoke( [41:org.apache.felix.scr:2.0.12]
    	at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeModifiedMethod( [41:org.apache.felix.scr:2.0.12]
    	at org.apache.felix.scr.impl.manager.SingleComponentManager.modify( [41:org.apache.felix.scr:2.0.12]
    	at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure( [41:org.apache.felix.scr:2.0.12]
    	at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure( [41:org.apache.felix.scr:2.0.12]
    	at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.configurationUpdated( [41:org.apache.felix.scr:2.0.12]
    	at org.apache.felix.scr.impl.manager.RegionConfigurationSupport.configurationEvent( [41:org.apache.felix.scr:2.0.12]
    	at org.apache.felix.scr.impl.manager.RegionConfigurationSupport$1.configurationEvent( [41:org.apache.felix.scr:2.0.12]
    	at$FireConfigurationEvent.sendEvent( [8:org.apache.felix.configadmin:1.8.16]
    	at$ [8:org.apache.felix.configadmin:1.8.16]
    	at [8:org.apache.felix.configadmin:1.8.16]
    	at [8:org.apache.felix.configadmin:1.8.16]
    	at [?:?]
    2018-06-08 00:59:19.340 [WARN ] [.MqttBrokerConnectionServiceInstance] - Ignore existing broker connection configuration for: mosquitto```

  • Hero Member

    @masmat please check your MQTT configuration. You're receiving an exception because it's trying to set "1883.0" for the value port.

  • @timo I did. I can't figure out where it's finding that .0 it adds to the 1883 port I have in the cfg-file

  • 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?

  • @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.

  • @TimO : are there any news concerning compatibility to version 2.3?
    Thanks for your work!

  • Hero Member

    @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 '' with clientid paho1135997459230242 and file store '/var/lib/openhab2/mqtt/'
    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( [229:org.eclipse.paho.client.mqttv3:1.0.2]
            at org.eclipse.paho.client.mqttv3.internal.ClientComms$ [229:org.eclipse.paho.client.mqttv3:1.0.2]
            at [?:?]
    Caused by: Connection reset
            at ~[?:?]
            at ~[?:?]
            at ~[?:?]
            at ~[?:?]
            at ~[?:?]
            at ~[?:?]
            at ~[?:?]
            at ~[?:?]
            at org.eclipse.paho.client.mqttv3.internal.SSLNetworkModule.start( ~[?:?]
            at org.eclipse.paho.client.mqttv3.internal.ClientComms$ ~[?:?]
            ... 1 more

    and 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?

  • Hero Member

    @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:


    With 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:


    I 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?

  • @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.

    secure=false  <-- important !

    So now I have a working 2.3 installation! Thanks alot for your support.

  • Hero Member

    @jogant Good catch! I'm glad it's working now! 🙂

  • 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 just


    and org.eclipse.smarthome.mqttbroker.cfg:


    openhab.log everything mysensors related:

    2018-07-09 06:40:36.782 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '' with clientid paho175068223000 and file store '/var/lib/openhab2/mqtt/'
    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.bundleid=13, service.scope=bundle,,} - org.openhab.binding.mysensors
    2018-07-09 06:42:36.466 [WARN ] [] - Execution failed (Exit value: -559038737. Caused by 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.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:


    And 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.

    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= --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=18

    I'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",
                                            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!

  • @jogant Finally had time to double check this:
    Paper UI:

    Broker Name 
    Subscription Topic 
    Publish Topic 
    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 10

    EDIT: I noticed I have different topics in MQTT, corrected AND I did:

    cd /usr/share/openhab2/addons/
    wget   <== THIS probably  fixed it!
    chown for the same file
    rm org.openhab.binding.mysensors-2.3.0-SNAPSHOT.jar

    Now 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.

  • Hi

    I want to set this up, but have openHAB already setup and running MQTT using the binding installed in paperui, whereas you say dont use that?

    Suggestions? With devices already working well on MQTT currently i want to follow this great, but dont wish to break what i have already working?


  • @TimO Thanks for the excellent work with the binding.

    I have just got this all running on OH2.3 using mosquito and mqtt mysensors using a Mega 2560. I am migration from a Vera to openHab and have around 20+ mysensors nodes from 1 to 8 devices on each. So this is a significant task. Anyway I am also newish to OH so have a few questions if I may.

    • Is it better to go via MQTT or Ethernet Bridge - on Vera I am using Ethernet my new Gateway using the Mega (as pro mini not enough ram to run security) can be either so is there a preference for either of these?
    • Is it worth using PaperUI vs Items files for configuration. I am leaning to items files as I am working with Persistance and some complex rules for device control. I have the binding learning nodes during a reboot in PaperUI these are working but I am confused how to build everything outside of the json DB files or even if I should?
    • Can MYSController be used somehow in this configuration either MQTT or Ethernet for OTA. At the moment I run this on a PC and connect to the Ethernet gateway do my updates and then let Vera have the gateway back. Is there a better way to link this using openHab?

    Sorry for the questions but if you never ask you never learn - thanks.

  • @itbeyond As always your mileage will vary depending on experience and goals.
    Disclaimer: I only have a couple of MYS-sensors and a small OpenHAB installation for sensing and remote light control. OpenHAB is a complex system so it takes time to master. Fortunately it also has great support and I really like it for its flexiblity, power and structure.

    • MQTT or ethernet bridge? I've tried both but never got MQTT to work. Based on the questions in the MYS forums I believe it is easier to use the ethernet connection. I find it easier to troubleshoot. You can start with the ethernet bridge to ensure everything works. Then you can easily switch to the MQTT setup if there are advantages for you. But unless you have other applications that also listen to the MYS messages, I can't really see any obvious reasons to use MQTT. (Of course, it may give you a warm, fuzzy feeling of having an all-MQTT sensor network.)

    • Definitely go for config files. Autodiscovery is neat but there are many things you can't do in PaperUI or that are very difficult to do there. In config files you can also add comments to explain to your future self why you did something.
      You can try autodiscovery and PaperUI first if you like and then move to config files. Then you may want to check out the OpenHAB forums on how to manually clear the cache. Sometimes the OH cache is a bit too clever for itself.

    • As I understand it, OTA is not supported by any MQTT controller. It is also not supported by OpenHAB. If you use the ethernet bridge you can keep your current ways of working - sensing and control in OpenHAB and update OTA via MYSController. If I'm not mistaken you only have to configure the MYS gw to accept at least two connections.

    You seem to know your way around OH already, but I will add a few general comments for beginners, based on my own experience with OpenHAB (as a non-developer):

    • First step is to set up backup and restore. Then test that it really works the way you intended.
    • Use the production release of OpenHAB unless you really need the bleeding edge. It can be very time consuming to revert from a beta/snapshot release to the production release.
    • Spend some time setting up OpenHAB and software around it so you can easily edit the config files. I use Openhabian which automatically shares all interesting files using Samba. It is then trivial to connect from my desktop and edit with my favourite editor. (MS Code has great support for OpenHAB config files.)
    • Spend some time on how to properly backup and restore OpenHAB so you can experiment freely and still easily revert if it crashes.
    • The OH forum is your friend. It is even more true than for MYS.
      E.g. check out the advice on how to name (and not name) your config files, things and items.
      and the OH patterns that provides beatiful solutions for many "impossible" problems.
    • Did I mention backup and restore? At least archive your config directory regularely.


  • @fredswed thanks for your comments. I have gone with Ethernet gateway as it works well and at this stage I do not need MQTT - maybe if I play with node-red or something down the track but for the moment happy with Ethernet - it just works. I did have MQTT working but the MYSController connection is a possible problem.

    I have also gone to the config files directly and have worked out the bridge setup in the things file and have a few test items running.

    Yes backups - done that and have my system backing up to a local NAS box.
    Cheers David

  • I need a fresh set of eyes on my problem.
    Gateway is online, but things are not discovered. I have tried adding them manually (my syntax could be wrong), but it doesn't help.

    There are no errors in mysgw.log-file.
    Mosquitto mysensors-out:

    mysensors-out/1/14/1/0/23 35
    mysensors-out/1/15/1/0/0 49
    mysensors-out/1/14/1/0/23 35
    mysensors-out/1/15/1/0/0 49
    mysensors-out/1/14/1/0/23 35
    mysensors-out/1/15/1/0/0 49
    mysensors-out/1/14/1/0/23 35
    mysensors-out/1/15/1/0/0 49


    Bridge mysensors:bridge-mqtt:mygateway1 [brokerName="mosquitto",
                                          startupCheckEnabled=true ]
        /** define things connected to that bridge here */
      temperature BoilerTemp [nodeID=1, childId=15]
      motion PukuhLiike [nodeID=1, childId=3]


    Number BoilerTemp "Lämminvesivaraaja [%.1f °C]" <heating> {channel="mysensors:temperature:mygateway1:temperature_1_15:temp"}
    Contact PukuhLiike "Pukuhuone Liike" <motion> {channel="mysensors:motion:mygateway1:motion_1_3:tripped"}

    OpenHab2 frontail:

    2018-08-13 22:34:03.284 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '' with clientid paho111686078117 and file store '/var/lib/openhab2/mqtt/'
    2018-08-13 22:34:05.499 [INFO ] [er.internal.HomeBuilderDashboardTile] - Started Home Builder at /homebuilder
    2018-08-13 22:34:11.928 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to 'Europe/Helsinki'.
    2018-08-13 22:34:11.999 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to 'fi'.
    2018-08-13 22:34:20.211 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at
    2018-08-13 22:34:20.317 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at
    2018-08-13 22:35:16.502 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'default.items'
    2018-08-13 22:35:34.984 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
    2018-08-13 22:35:38.657 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mys.things'
    2018-08-13 22:35:39.245 [.ItemChannelLinkAddedEvent] - Link 'PukuhLiike-mysensors:motion:mygateway1:motion_1_3:tripped' has been added.
    2018-08-13 22:35:39.309 [.ItemChannelLinkAddedEvent] - Link 'BoilerTemp-mysensors:temperature:mygateway1:temperature_1_15:temp' has been added.
    2018-08-13 22:36:14.848 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
    2018-08-13 22:36:18.741 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
    2018-08-13 22:36:22.407 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
    2018-08-13 22:36:25.610 [hingStatusInfoChangedEvent] - 'mysensors:bridge-mqtt:mygateway1' changed from UNINITIALIZED to INITIALIZING
    2018-08-13 22:36:26.660 [hingStatusInfoChangedEvent] - 'mysensors:temperature:mygateway1:BoilerTemp' changed from UNINITIALIZED to UNINITIALIZED (BRIDGE_UNINITIALIZED)
    2018-08-13 22:36:26.861 [hingStatusInfoChangedEvent] - 'mysensors:motion:mygateway1:PukuhLiike' changed from UNINITIALIZED to UNINITIALIZED (BRIDGE_UNINITIALIZED)
    2018-08-13 22:36:27.453 [hingStatusInfoChangedEvent] - 'mysensors:bridge-mqtt:mygateway1' changed from INITIALIZING to ONLINE
    2018-08-13 22:36:27.546 [INFO ] [rotocol.mqtt.MySensorsMqttConnection] - Successfully connected to MySensors Bridge.
    2018-08-13 22:36:28.075 [hingStatusInfoChangedEvent] - 'mysensors:temperature:mygateway1:BoilerTemp' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to UNINITIALIZED (HANDLER_CONFIGURATION_PENDING)
    2018-08-13 22:36:28.120 [hingStatusInfoChangedEvent] - 'mysensors:motion:mygateway1:PukuhLiike' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to UNINITIALIZED (HANDLER_CONFIGURATION_PENDING)

    In my addons I have the 2.4.0 Snapshot.


    EDIT: After a week of trying things. This worked:
    No autodiscovery, but this switches my sensors ONLINE (even ones that are not powered up 😞 ), but it's not updating the values.

  • Hero Member

    @masmat said in Getting MySensors MQTT Gateway working on OpenHAB 2.2 (Stable):

    No autodiscovery, but this switches my sensors ONLINE (even ones that are not powered up ), but it's not updating the values.

    Autodiscovery should work. 😕
    Does the temperature thing in OH2 get updates? Is it working?

    The sensors will show up ONLINE if the connection to the broker is established, because the sensors are just a topic. There is at the moment no implementation to check if the sensors/things are really available. This could be done, but it is not implemented yet.

  • @timo Before I did the re-install of everything autodiscovery was working, but now it isn't. Current sys: RpiZeroW, Openhabian 2.3.0-1release, mosquitto.
    The temperature is not updating in OH2. But the mysensors-out topic does show the gateway sending the values out. OH2 is not listening for some reason...

    Re-install some (which?) parts or bindings? Openhab2 mqtt-binding?