Mysensors binding 2.4: cant get mqtt gateway online

Hello, im trying to get mysensors binding to work in openHAB with mqtt gateway. I can get it to work with ethernet or serial gateway but i need mqtt gateway. Hardware is properly setup. I know this because i can connect to mqtt gateway with mycontroller and see all connected nodes and sensors. When i look at the mosquitto broker i can see the messages sent by the gateway. But my mqtt gateway thing stays offline in openHAB paperUi. I guess there is a problem with my mqtt.cfg or mqtt-eventbus.cfg. there isnt alot of documentation out there. I did find an example of how the config files should look in openHAB 2.2 & 2.3 but im running 2.4 and appearently the same .cfg doesnt work. I’ve been breaking my head over this for the last 3 days but cant find anything on the forums to solve my problem (it gets very confusing, considering the various approaches: mqtt binding1 vs mqtt binding2 vs mysensors binding). Does anyone have the mqtt gateway running in openhab 2.4 using the mysensors binding? Im really lost, any help would be much appreciated. Thanks

Yes, just install the new mqtt binding as well

Yes, i have allready tried it. First without mqtt binding, then with mqtt binding installed. I made a mqtt broker thing (wich is online) but still cant get the mqtt gateway thing to come online. I must be overlooking some detail :unamused::frowning:

There was a thread a couple of days ago about the same problem.
Look it up
I experimented with the mysensor binding but it creates thing for each sensor which doesn’t make sense.
So I use the mqtt binding directly via a node-red topic “translator”

Do you mean this post: [SOLVED] Can't install mysensors 2.4 binding?

It was mine. Problem here was mysensors binding didnt show up in paperUi. But turned out i forgot to enable a feature

Is it possible to discover sensors with the mqtt binding?

No, you can’t

It seems like the MQTT-gateway thing doesn’t connect to mosquitto, I should mention i have the espMiLight binding running wich allso goes over mqtt (wich does connect to mosquitto). When i look in the mosquitto logs i can see the espMiLight bridge connect from IP of openhab but i never see MySensors bridge connect to mosquitto:


[13:15:53] openhabian@openHABianPi:~$ mosquitto -p 1883 -v
1548159358: mosquitto version 1.4.10 (build date Wed, 17 Oct 2018 19:03:03 +0200                                      ) starting
1548159358: Using default config.
1548159358: Opening ipv4 listen socket on port 1883.
1548159358: Opening ipv6 listen socket on port 1883.
1548159358: New connection from 192.168.1.4 on port 1883.
1548159358: New client connected from 192.168.1.4 as mysensors-1 (c1, k15, u'ope                                      nhabian').
1548159358: Sending CONNACK to mysensors-1 (0, 0)
1548159358: Received PUBLISH from mysensors-1 (d0, q0, r0, m0, 'mygateway1-out/0                                      /255/0/0/18', ... (5 bytes))
1548159358: Received SUBSCRIBE from mysensors-1
1548159358:     mygateway1-in/+/+/+/+/+ (QoS 0)
1548159358: mysensors-1 0 mygateway1-in/+/+/+/+/+
1548159358: Sending SUBACK to mysensors-1
1548159359: Received PUBLISH from mysensors-1 (d0, q0, r0, m0, 'mygateway1-out/1                                      07/3/1/0/0', ... (2 bytes))
1548159359: Received PUBLISH from mysensors-1 (d0, q0, r0, m0, 'mygateway1-out/1                                      07/2/1/0/0', ... (4 bytes))
1548159359: Received PUBLISH from mysensors-1 (d0, q0, r0, m0, 'mygateway1-out/1                                      07/1/1/0/1', ... (4 bytes))
1548159361: New connection from 192.168.1.2 on port 1883.
1548159361: New client connected from 192.168.1.2 as espMilightHub:001 (c1, k15,                                       u'openhabian').
1548159361: Sending CONNACK to espMilightHub:001 (0, 0)
1548159361: Received SUBSCRIBE from espMilightHub:001
1548159361:     milight/states/# (QoS 1)
1548159361: espMilightHub:001 1 milight/states/#
1548159361: Sending SUBACK to espMilightHub:001
1548159363: New connection from 192.168.1.5 on port 1883.
1548159363: New client connected from 192.168.1.5 as milight-hub-8661470 (c1, k1                                      5, u'openhabian').

192.168.1.2 => ip openhab server
192.168.1.4 => ip mqtt gateway
192.168.1.5 => ip milight hub
If i am right there should be 2 more lines like this:


 New connection from 192.168.1.2 on port 1883.
New client connected from 192.168.1.2 as mysensors:gateway (c1, k15,                                       u'openhabian').

but these lines never show up in mosquitto log:white_frowning_face:
These are the logs i get when trying to add a mqtt gateway from paperUI:

2019-01-22 13:54:57.181 [TRACE] [sors.factory.MySensorsHandlerFactory] - Creating handler for thing: mysensors:bridge-mqtt:bd653924

2019-01-22 13:54:57.195 [DEBUG] [nsors.handler.MySensorsBridgeHandler] - Initialization of the MySensors bridge

==> /var/log/openhab2/events.log <==

2019-01-22 13:54:57.196 [hingStatusInfoChangedEvent] - 'mysensors:bridge-mqtt:bd653924' changed from UNINITIALIZED to INITIALIZING

==> /var/log/openhab2/openhab.log <==

2019-01-22 13:54:57.203 [DEBUG] [ensors.factory.MySensorsCacheFactory] - Cache file: given_ids.cached exist.

2019-01-22 13:54:57.208 [DEBUG] [ensors.factory.MySensorsCacheFactory] - Cache (given_ids) content: [0, 11, 107]

2019-01-22 13:54:57.212 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - Enabling connection watchdog

2019-01-22 13:54:57.216 [TRACE] [sensors.internal.event.EventRegister] - Adding listener org.openhab.binding.mysensors.internal.gateway.MySensorsGateway@5be142 to org.openhab.binding.mysensors.internal.event.EventRegister@646dd1

2019-01-22 13:54:57.219 [TRACE] [sensors.internal.event.EventRegister] - Adding listener org.openhab.binding.mysensors.handler.MySensorsBridgeHandler@10cfe20 to org.openhab.binding.mysensors.internal.event.EventRegister@646dd1

2019-01-22 13:54:57.225 [TRACE] [nsors.handler.MySensorsBridgeHandler] - Registering MySensorsDiscoveryService for bridge 'bd653924'

2019-01-22 13:54:57.224 [ERROR] [rotocol.mqtt.MySensorsMqttConnection] - No connection to broker: mosquitto

2019-01-22 13:54:57.232 [TRACE] [nternal.event.MySensorsEventRegister] - Broadcasting event org.openhab.binding.mysensors.internal.protocol.mqtt.MySensorsMqttConnection@16f7c2 to: org.openhab.binding.mysensors.internal.gateway.MySensorsGateway@5be142

2019-01-22 13:54:57.236 [TRACE] [nternal.event.MySensorsEventRegister] - Broadcasting event MySensorsNode [nodeId=0, childNumber=0, chidldList={}] to: org.openhab.binding.mysensors.internal.gateway.MySensorsGateway@5be142

2019-01-22 13:54:57.239 [TRACE] [nternal.event.MySensorsEventRegister] - Broadcasting event MySensorsNode [nodeId=0, childNumber=0, chidldList={}] to: org.openhab.binding.mysensors.handler.MySensorsBridgeHandler@10cfe20

2019-01-22 13:54:57.243 [TRACE] [nternal.event.MySensorsEventRegister] - Broadcasting event MySensorsNode [nodeId=11, childNumber=0, chidldList={}] to: org.openhab.binding.mysensors.internal.gateway.MySensorsGateway@5be142

2019-01-22 13:54:57.247 [TRACE] [nternal.event.MySensorsEventRegister] - Broadcasting event MySensorsNode [nodeId=11, childNumber=0, chidldList={}] to: org.openhab.binding.mysensors.handler.MySensorsBridgeHandler@10cfe20

2019-01-22 13:54:57.251 [TRACE] [nternal.event.MySensorsEventRegister] - Broadcasting event MySensorsNode [nodeId=107, childNumber=0, chidldList={}] to: org.openhab.binding.mysensors.internal.gateway.MySensorsGateway@5be142

2019-01-22 13:54:57.253 [DEBUG] [org.openhab.binding.mysensors       ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={service.id=518, service.bundleid=263, service.scope=singleton} - org.openhab.binding.mysensors

2019-01-22 13:54:57.255 [TRACE] [nternal.event.MySensorsEventRegister] - Broadcasting event MySensorsNode [nodeId=107, childNumber=0, chidldList={}] to: org.openhab.binding.mysensors.handler.MySensorsBridgeHandler@10cfe20

2019-01-22 13:54:57.258 [TRACE] [nternal.event.MySensorsEventRegister] - Broadcasting event org.openhab.binding.mysensors.internal.protocol.mqtt.MySensorsMqttConnection@16f7c2 to: org.openhab.binding.mysensors.handler.MySensorsBridgeHandler@10cfe20

==> /var/log/openhab2/events.log <==

2019-01-22 13:54:57.269 [hingStatusInfoChangedEvent] - 'mysensors:bridge-mqtt:bd653924' changed from INITIALIZING to OFFLINE

==> /var/log/openhab2/openhab.log <==

2019-01-22 13:54:57.275 [DEBUG] [ensors.factory.MySensorsCacheFactory] - Writing on cache given_ids, content: [0,11,107]

2019-01-22 13:54:57.279 [DEBUG] [.discovery.MySensorsDiscoveryService] - Starting MySensors discovery scan

2019-01-22 13:54:57.282 [ERROR] [rotocol.mqtt.MySensorsMqttConnection] - Failed connecting to bridge...next retry in 10 seconds (Retry No.:0)

2019-01-22 13:54:57.282 [TRACE] [sensors.internal.event.EventRegister] - Adding listener org.openhab.binding.mysensors.discovery.MySensorsDiscoveryService@1e34cba to org.openhab.binding.mysensors.internal.event.EventRegister@646dd1

2019-01-22 13:54:57.285 [DEBUG] [nsors.handler.MySensorsBridgeHandler] - Initialization of the MySensors bridge DONE!

For some reason openhab cant connect the mqtt gateway thing to mosquitto, it can however connect the espMiLight hub to mosquitto no problem.

The mqtt gateway itself is happely spewing data wich arrives at the mosquitto broker:

[14:05:04] openhabian@openHABianPi:~$ mosquitto_sub -u openhabian -P y -p 1883 -v -t 'mygateway1-out/#'
mygateway1-out/107/3/1/0/0 28
mygateway1-out/107/0/1/0/0 91
mygateway1-out/107/2/1/0/0 20.1
mygateway1-out/107/1/1/0/1 45.4
mygateway1-out/107/2/1/0/0 20.6
mygateway1-out/107/1/1/0/1 43.2

I have serial binding and mqtt binding v2 installed. I have both mqtt.cfg and org.eclipse.smarthome.mqtt.cfg configured as follows:

#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
mqtt:mosquitto.url=tcp://localhost:1883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
mqtt:mosquitto.clientId=openHab

# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
#mqtt:mosquitto.allowLongerClientIds=false

# Optional. User id to authenticate with the broker.
mqtt:mosquitto.user=openhabian

# Optional. Password to authenticate with the broker.
mqtt:mosquitto.pwd=y

# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
mqtt:mosquitto.qos=1

# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
#mqtt:mosquitto.retain=true

# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#mqtt:mosquitto.async=false

# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#mqtt:mosquitto.lwt=<last will definition>

I’ve been at this for 4 days now and i really want to pull my hair out

I am having the same issue. My mqtt gateway is happily sending data to mosquitto, and I can get that into openhab through a “Generic MQTT Thing” within the MQTT Thing Binding, but my Openhab MQTT Gateway thing remains offline.

Did you configeure the mqtt thing via files or via paper UI? because i cant even get this to work (via conf in files).

I started with something different then mysensors. I want to read a topic “milight/updates/0x5820/rgb_cct/0 {“state”:“ON”}” and appoint it to an item but i’m stuck. If i get this working i could allso apply it to mysensors.

things file

Bridge espmilighthub:esp8266Bridge:001 [ADDR="tcp://192.168.1.2:1883", MQTT_USERNAME="openhabian", MQTT_PASSWORD="y"]
{
        Thing espmilighthub:topic:milight {
                Type number : zone0 "test" [ stateTopic="milight/updates/0x5820/rgb_cct/0" ]
        }
}

Items file

Number zone0  "Level [%d]" { channel="espmilighthub:topic:milight:zone0"}

Maybe you can give me a nudge in the right direction?

PS: I sent a message to the developer of the milight binding to ask for help, but he hasnt been online for the last 5 days (think he might be on vacation). If i find a solution i will post it here.

I had feedback from the binding developer. Seems that when using the openhab integrated mqtt broker the mqtt gateway comes online and everything works as expected. I still have to try it when i get the chance.

Hi Jimmy
Did you get this working in the end? I am trying to get it going as well with mysensors.
Any pointers would be greatly received.
Cheers

Hi crumpy,

I gave it up a while ago because my nodes radios are not of high enough quality for fota, wich was the whole point (for me) of using an mqtt gateway. I did get the mqtt gw running with the embedded broker in openhab (see new mqtt binding) but not with mosquitto. Maybe this is fixed now since its been a while since i looked into it.

How are you all connecting the microcontroller? I’m using a mega256 via usb, and I’m wondering if the mysensors mqtt method will run over serial or only tcp?

Sorry for the late response, I gave up on this and use the ethernet GW instead. Running on an Uno and w5100.