Can't get OpenHAB2 to see my MQTT messages
-
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?
-
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.
-
Hi! Can you post your arduino sketches as well??
Thanks!
-
This helped me out a lot, thanks!
-
@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)
Suggested Topics
-
OpenHAB 2.1 keeps showing light level as 0 with BH1750 and V_LEVEL
Troubleshooting • 9 Jul 2017, 20:52 • George Laynes 11 Jul 2017, 18:41 -
MySensors MQTT 'dialect' optionally Homie
General Discussion • 5 May 2021, 13:46 • Peter Loeffler 18 May 2021, 13:36 -
Openhab2 + MySensors MQTTClientGateway + discovery
Development • 22 Sept 2016, 15:30 • CrankyCoder 22 Sept 2016, 18:47 -
ESP8266 crashes while starting up and receiving a message from node
General Discussion • 17 Jan 2018, 19:45 • Abdu Sahin 18 Jan 2018, 22:36 -
Change color of RGB led strip over MQTT?
OpenHAB • 6 Jan 2017, 04:24 • augusthalverson 6 Jan 2017, 04:30 -
Raspberry PI + MQTT (Mosquitto) + Serial Gateway
General Discussion • 14 Feb 2015, 06:12 • catcher 2 Mar 2017, 17:58 -
vThing - CO2 Monitor - Dual Beam - Wifi
OpenHardware.io • 21 Jun 2016, 03:47 • openhardware.io 22 Jun 2016, 16:05