Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. OpenHAB
  4. Can't get OpenHAB2 to see my MQTT messages
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

Can't get OpenHAB2 to see my MQTT messages

Scheduled Pinned Locked Moved OpenHAB
openhab2mqttmosquittoopenhab
5 Posts 4 Posters 13.5k Views 7 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • micahM Offline
    micahM Offline
    micah
    wrote on last edited by micah
    #1

    So, I thought I finally had everything setup properly, but alas something is still not working.

    Overview

    • MySensors.org 2.0 (downloaded about 3 days ago)
    • OpenHAB 2 (installed yesterday)
    • Raspberry Pi (Rasbian 1.9, updated)
    • Mosquitto (whatever the current version is)

    Devices

    • Sensor with a temperature and humidity sensor
    • I'm using the GatewayW5100MQTTClient on an Arduino Uno with a W5100 shield
    • Raspberry Pi 2 B, which is handling the MQTT broker and OpenHAB

    Status

    • Uno+Sensors+Radio is working properly
    • Gateway+Radio+Ethernet is working properly
    • Mosquitto is working properly
    • openHAB 2 is setup, but it doesn't display the sensor results

    As you can see my Arduino side of things is working properly, here is a sample of the messages I receive on my Raspberry Pi when I type mosquitto_sub -v -t 'mygateway1-out/#'

    mygateway1-out/2/1/1/0/0 19.8
    mygateway1-out/2/0/1/0/1 21.2
    

    I'm hoping someone can help me troubleshoot the following code snippets to figure out what's wrong, I'm pretty sure the issue in between OpenHAB 2 and Mosquitto.

    So here goes.

    OpenHAB: Sitemap

    sitemap belmont label="Main Menu"{
    	Frame {
    		Group item=gSF label="Attic" icon="secondfloor"
    		Group item=gFF label="First Floor" icon="firstfloor"
    		Group item=gGF label="Ground Floor" icon="groundfloor"
    		Group item=gC label="Basement" icon="cellar"	
    		Group item=Garden icon="garden" 
    	}
    	Frame label="Basement Monitor" {
    		Text item=BasementMonitor_Temp01
    		Text item=BasementMonitor_Hum01
        }
    }
    

    OpenHAB: Items

    Group All
    
    // Sensor Types
    Group gTemperature (All) // Contains all temperature sensors
    Group gHumidity (All) // Contains all humidity sensors
    
    // Floor Mappings
    Group gSF           "Attic"   		<secondfloor>
    Group gFF           "First Floor"   <firstfloor>
    Group gGF           "Ground Floor"  <groundfloor>
    Group gC            "Basement"      <cellar>
    Group Garden        "Garden"        <garden>
    
    // Room Mappings
    Group SF_Play       "Play Room"     <corridor>      (gSF)
    Group SF_Office		"Office"   		<office>     	(gSF)
    
    Group GF_Living     "Living Room"   <video>     	(gGF)
    Group GF_Dining     "Dining Room"   <video>     	(gGF)
    Group GF_Kitchen    "Kitchen"       <kitchen>   	(gGF)
    Group GF_Corridor   "Corridor"      <corridor>  	(gGF)
    
    Group FF_Bath       "Bathroom"      <bath>      	(gFF)
    Group FF_Kate       "Kate's Room"   <girl1>    		(gFF)
    Group FF_Jake       "Jake's Room"   <boy1>      	(gFF)
    Group FF_Bed        "Master Bedroom"   	<bedroom>   (gFF)
    Group FF_Corridor   "Corridor"      <corridor>  	(gFF)
    
    Group gC_Furnace    "Furnace Room"  <corridor>     	(gC)
    
    Number  BasementMonitor_Temp01  "Temperature [%.1f °C]"  		<temperature>   (gC_Furnace, gTemperature)   {mqtt="<[MyMQTT-2:mygateway1-out/2/1/1/0/0:state:default]"}
    Number  BasementMonitor_Hum01   "Humidity [%.1f %%]"     		<temperature>   (gC_Furnace, gHumidity)      {mqtt="<[MyMQTT-2:mygateway1-out/2/0/1/0/1:state:default]"}
    

    OpenHAB: mqtt.cfg

    openhab.url=tcp://localhost:1883
    openhab.clientId=MyMQTT-2
    

    OpenHAB: mqtt-persistance.cfg

    broker=openhab
    

    OpenHAB: mqtt-eventbus.cfg

    broker=openhab
    stateSubscribeTopic=MyMQTT-2/stateUpdates/${item}/state
    commandSubscribeTopic=MyMQTT-2/commandUpdates/${item}/command
    

    Help

    What am I doing wrong?

    1 Reply Last reply
    0
    • micahM Offline
      micahM Offline
      micah
      wrote on last edited by
      #2

      VICTORY!!!!

      Apparently I just needed to bang my head against the keyboard and randomly try combinations until it worked.

      So to hopefully help other people I'll post how I got it to work.

      OpenHAB: Items

      Number  BasementMonitor_Temp01  "Temperature [%.1f °C]"  		<temperature>   (gC_Furnace, gTemperature)   {mqtt="<[mysensors:mygateway1-out/2/1/1/0/0:state:default]"}
      Number  BasementMonitor_Hum01   "Humidity [%.1f %%]"     		<temperature>   (gC_Furnace, gHumidity)      {mqtt="<[mysensors:mygateway1-out/2/0/1/0/1:state:default]"}
      

      OpenHAB: mqtt.cfg

      mysensors.url=tcp://localhost:1883
      mysensors.clientId=openHAB
      

      OpenHAB: mqtt-persistance.cfg

      broker=mysensors
      

      OpenHAB: mqtt-eventbus.cfg

      broker=mysensors
      stateSubscribeTopic=MyMQTT/stateUpdates/${item}/state
      commandSubscribeTopic=MyMQTT/commandUpdates/${item}/command
      

      Arduino: GatewayW5100MQTTClient

      #define MY_MQTT_CLIENT_ID "mysensors-1"
      #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
      #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
      

      So to summarize here are the key parts (I think):

      • Broker = mysensors
      • clientId = openHAB
      • pattern for items = {mqtt="<[mysensors:mygateway1-out/2/0/1/0/1:state:default]"}

      I'm still not sure if the second and third line in the mqtt-eventbus.cfg is correct. I don't have MyMQTT anywhere else, so I think I may try different combinations to see what works.

      D 1 Reply Last reply
      0
      • laihozL Offline
        laihozL Offline
        laihoz
        wrote on last edited by
        #3

        Hi! Can you post your arduino sketches as well??

        Thanks!

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          Qu3Uk
          wrote on last edited by
          #4

          This helped me out a lot, thanks!

          1 Reply Last reply
          1
          • micahM micah

            VICTORY!!!!

            Apparently I just needed to bang my head against the keyboard and randomly try combinations until it worked.

            So to hopefully help other people I'll post how I got it to work.

            OpenHAB: Items

            Number  BasementMonitor_Temp01  "Temperature [%.1f °C]"  		<temperature>   (gC_Furnace, gTemperature)   {mqtt="<[mysensors:mygateway1-out/2/1/1/0/0:state:default]"}
            Number  BasementMonitor_Hum01   "Humidity [%.1f %%]"     		<temperature>   (gC_Furnace, gHumidity)      {mqtt="<[mysensors:mygateway1-out/2/0/1/0/1:state:default]"}
            

            OpenHAB: mqtt.cfg

            mysensors.url=tcp://localhost:1883
            mysensors.clientId=openHAB
            

            OpenHAB: mqtt-persistance.cfg

            broker=mysensors
            

            OpenHAB: mqtt-eventbus.cfg

            broker=mysensors
            stateSubscribeTopic=MyMQTT/stateUpdates/${item}/state
            commandSubscribeTopic=MyMQTT/commandUpdates/${item}/command
            

            Arduino: GatewayW5100MQTTClient

            #define MY_MQTT_CLIENT_ID "mysensors-1"
            #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
            #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
            

            So to summarize here are the key parts (I think):

            • Broker = mysensors
            • clientId = openHAB
            • pattern for items = {mqtt="<[mysensors:mygateway1-out/2/0/1/0/1:state:default]"}

            I'm still not sure if the second and third line in the mqtt-eventbus.cfg is correct. I don't have MyMQTT anywhere else, so I think I may try different combinations to see what works.

            D Offline
            D Offline
            dakipro
            wrote on last edited by
            #5

            @micah said in Can't get OpenHAB2 to see my MQTT messages:

            I'm still not sure if the second and third line in the mqtt-eventbus.cfg is correct. I don't have MyMQTT anywhere else, so I think I may try different combinations to see what works.

            MyMQTT should be replaced with brokername (mysensors in this example). openhab will then publish the event to the mqtt broker on its topics (useful if you use f.eks. node-red for openhab rules)

            C: OpenHAB2 with node-red on linux laptop
            GW: Arduino Nano - W5100 Ethernet, Nrf24l01+ 2,4Ghz mqtt
            GW: Arduino Mega, RFLink 433Mhz

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            5

            Online

            11.7k

            Users

            11.2k

            Topics

            113.0k

            Posts


            Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • OpenHardware.io
            • Categories
            • Recent
            • Tags
            • Popular