how do I make the build-in MQTT broker work ?
-
I have a small MySensor network which is connected to MyController via a serial gateway.
The sensors seems to be read as expected and produce nice graphs.I have enabled MQTT as you can see from the log-file below
cat mycontroller.log 2018-04-29 20:53:58,336 INFO [main] [org.mycontroller.standalone.db.DataBaseUtils:117] Checking migration... 2018-04-29 20:53:58,980 INFO [main] [org.mycontroller.standalone.db.DataBaseUtils:168] Application information: [Version:1.2.0.Final, Database(type:H2 database embedded, version:1.4.194 (2017-03-10), schema version:1.04.01 - 2017 Oct 25), Built on:2018-02-23T10:26:25+0530, Git commit:a10694ff1bff40cfb9988cec48e6569ec51ee57b:master] 2018-04-29 20:53:59,238 WARN [main] [io.moquette.persistence.mapdb.MapDBPersistentStore:78] Using existing MapDB store file. Path=../conf/persistent_stores/moquette/moquette_store.mapdb 2018-04-29 20:53:59,332 WARN [main] [io.moquette.server.Server:186] Using default SSL context creator 2018-04-29 20:53:59,450 WARN [main] [io.netty.bootstrap.ServerBootstrap:146] Unknown channel option 'TCP_NODELAY' for channel '[id: 0x9685b6ea]' 2018-04-29 20:53:59,465 WARN [main] [io.netty.bootstrap.ServerBootstrap:146] Unknown channel option 'TCP_NODELAY' for channel '[id: 0xe0d895c8]' 2018-04-29 20:53:59,465 INFO [main] [org.mycontroller.standalone.mqttbroker.MoquetteMqttBroker:54] MQTT Broker started successfully. MqttBrokerSettings(enabled=true, sslEnabled=false, bindAddress=192.168.2.8, mqttPort=1883, mqttsPort=8883, websocketPort=7080, allowAnonymous=true, enabledOnBackend=true, sslKeystoreFile=null, sslKeystorePassword=null) 2018-04-29 20:54:00,074 INFO [main] [org.mycontroller.standalone.StartApp:215] TJWS server started successfully, HTTPS Enabled?:true, HTTP(S) Port: [8443] 2018-04-29 20:54:00,075 INFO [main] [org.mycontroller.standalone.StartApp:113] MyController.org server started in [1762] ms
And i try to subscribe to the MQTT -server with
mosquitto_sub -h 192.168.2.8 -t '#'
The command blocks as expected but nothing further happens.
Following "Status->Resource logs" I see that measurements is arriving at a steady pace.What am I doing wrong ?
Best Regard
StorePeter.
-
@storepeter You have connected your gateway on the serial port. You do not see any activities on MQTT.
If you want to convert your serial port data to MQTT you may use serial2mqtt or MySensors MQTT Gateway -
Thank you for your reply, it helped me get a little further, although there are still many blanks
When I first started playing with MySensors I made a MySensors-MQTT gateway on a Raspberry Pi as described here:
https://www.mysensors.org/build/raspberrybut somehow it could not see my sensors, so I was stuck for a few days.
Then I saw a comment somewhere on the MySensor forum that you need to have a controller, and then I noticed this comment "NOTE: No controller supports dynamic ID assignment through MQTT. All nodes must have MY_NODE_ID" on
https://www.mysensors.org/build/mqtt_gatewaywhich led to MyController. So I build a MySensor serial-gateway and was up and running in no time with MyController, I was (and still am) very impressed with what could be achieved this way with very limited effort. Hence I rethought my configuration, now wanting to have MyController be the back-bone also since it seemed to have build in MQTT-broker.
Now I just read:
https://forum.mycontroller.org/topic/15/republish-mysensors-messages-via-mqttThis is what I thought the MQTT functionallity in MyController was - I guess I was wrong, is it only intended to be a gateway from MQTT to MyController. I believe the other way could be really valuable with f.ex. node-red. Do I understand this right or is there something I have missed ?
Anyway - for now it seems that I had already solved my problem, the Raspberry pi had been supplying a MQTT stream as soon as MyController had numbered my sensors.
Is this a desireable setup, I read some where that you can only have one Gateway on a MySensors network, and now I have two ?
As you can see it is still MyController/MySensors playing with me, but soon I hope I will have some of my blanks filled in so it will be me playing with them.
If you can read Danish or use google translate, I have written about this on my blog and intend to document my progress there aswell
-
I just found this
https://github.com/mycontroller-org/mycontroller/issues/7I certainly would like to see this implemented, or perhaps just a way to export a given sensor to MQTT. If this is already possible I would like to know how, otherwise a button on each sensor (and node to export, all its sensors) where you could specify a MQTT name, would be really helpfull. think of it as a symbolic link
-
@storepeter said in how do I make the build-in MQTT broker work ?:
Thank you for your reply, it helped me get a little further, although there are still many blanks
When I first started playing with MySensors I made a MySensors-MQTT gateway on a Raspberry Pi as described here:
https://www.mysensors.org/build/raspberry
but somehow it could not see my sensors, so I was stuck for a few days.
Then I saw a comment somewhere on the MySensor forum that you need to have a controller, and then I noticed this comment "NOTE: No controller supports dynamic ID assignment through MQTT. All nodes must have MY_NODE_ID" on
https://www.mysensors.org/build/mqtt_gatewayMyController supports everything via MQTT. There is no restriction. However, you can see bit latency in the firmware update(OTA) via MQTT.
which led to MyController. So I build a MySensor serial-gateway and was up and running in no time with MyController, I was (and still am) very impressed with what could be achieved this way with very limited effort. Hence I rethought my configuration, now wanting to have MyController be the back-bone also since it seemed to have build in MQTT-broker.
Now I just read:
https://forum.mycontroller.org/topic/15/republish-mysensors-messages-via-mqtt
This is what I thought the MQTT functionallity in MyController was - I guess I was wrong, is it only intended to be a gateway from MQTT to MyController. I believe the other way could be really valuable with f.ex. node-red. Do I understand this right or is there something I have missed ?Initially we do not have support for serial to MQTT. I am afraid to introduce this feature in MyController. Hence I created a separate project. It is serial2mqtt. If you want to convert serial to MQTT. use this project.
Anyway - for now it seems that I had already solved my problem, the Raspberry pi had been supplying a MQTT stream as soon as MyController had numbered my sensors.
Is this a desireable setup, I read some where that you can only have one Gateway on a MySensors network, and now I have two ?Yes, you should have only one. Gateway id is Unique(
0
) If you have more than one gateway, you may end up with some issues.
But you can have more than one network. It means you can configure different frequency for each network. Somthing like displayed here.As you can see it is still MyController/MySensors playing with me, but soon I hope I will have some of my blanks filled in so it will be me playing with them.
If you can read Danish or use google translate, I have written about this on my blog and intend to document my progress there aswell
http://peter.lorenzen.us/homeautomation/mysensors+1
-
@storepeter said in how do I make the build-in MQTT broker work ?:
I just found this
https://github.com/mycontroller-org/mycontroller/issues/7
I certainly would like to see this implemented, or perhaps just a way to export a given sensor to MQTT. If this is already possible I would like to know how, otherwise a button on each sensor (and node to export, all its sensors) where you could specify a MQTT name, would be really helpfull. think of it as a symbolic linkThis feature has been implemented on serial2mqtt
-
Thanks again, every day I feel a little more in control.
To have only one gateway I have eliminated the serial-gateway. I am now using the Raspberry Pi as a MQTT gateway, and MyController is setup to use the RPI as MySensor-MQTT gateway. All Sensors get discovered and everything looks fine.
So I am happy - this is exactly what I was looking for
There is one minor difference - when using the serial gateway all my repeaters were interconnected with lines, now they are all islands. Before I believe that only non-repeater showed as unconnected. I kind of liked that distinction - Why is this so ?
Thanks for great project and great support
/StorePeter
-
@storepeter said in how do I make the build-in MQTT broker work ?:
There is one minor difference - when using the serial gateway all my repeaters were interconnected with lines, now they are all islands. Before I believe that only non-repeater showed as unconnected. I kind of liked that distinction - Why is this so ?
There is no difference in MyController side for MQTT or Serial. On gateway, page select the gateway and execute
Discover
.
Discover
job will be executed 30 minutes once I guess(default).Your MQTT gateway RF may be weaker than serial gateway RF. When enabling
ack
for your gateway might resolve this issue. If the message failed to send, MyController retries N(in this image 5 times) times in the interval of 1 second(1000 ms).