Serial Gateway and MQTT Broker

  • @jkandasa Perfect!

  • Hardware Contributor

  • @FotoFieber Thanks for the suggestion, I got that working. I have had to change MyController to read an MQTT gateway. Problem now is MyController can't read the MQTT format of this script. Any suggestions or tips ?
    MyController does such a great job with handling MySensors' data, it would be a pity to loose that functionality.

  • Hardware Contributor

    The script uses the serial protocol and should be compatible with the mysesnosrs mqtt-gateway. Are the pub/sub-topics set correct?

  • @FotoFieber MyController is getting the MQTT msg, but doesn't like it's format, i've had continuous error msg like below:
    2017-02-16 18:17:34,657 ERROR [Thread-4] [org.mycontroller.standalone.provider.mysensors.MySensorsProviderBridge:60] Unable to process this rawMessage:RawMessage(gatewayId=2, data=2;0;1;0;23;36, subData=mysensors/1/out/, isTxMessage=false, networkType=MY_SENSORS)
    org.mycontroller.standalone.message.RawMessageException: Unknown message format, Topic:mysensors/1/out/, PayLoad:2;0;1;0;23;36
    at org.mycontroller.standalone.provider.mysensors.MySensorsRawMessage.updateMQTTMessage( ~[mycontroller-dist-standalone-0.0.3.Alpha2-single.jar:0.0.3.Alpha2]

    MyController is set up with the correct topic, as seen in above Topic:/mysensors/1/out/ (i've also tried without the ending /).

  • Hardware Contributor

    2;0;1;0;23;36 Is a correct message according to the serial API. I don't know anything about your controller...sorry

    Maybe the controller needs the ; translated to / in the topic?

    Have you tried to switch pub/sub topic?

  • Plugin Developer

    @Frank-C Current approach of MyController on MQTT see only payload on message. Other data(nodeId, sensorIds, etc) from topic. Kindly create a request on MyController issue page. I will address this. If we address this I am not going to create separate service to parse serial-to-real-mqtt service type.

  • @jkandasa Thanks for the follow up. I can see MyController is modifying the serial message into a customized MQTT msg (as you have said).
    MyController works great with the serial so it would be good to keep that as is, and if we had an independent service to publish to a separate MQTT broker would be very helpful?

  • Plugin Developer

    @Frank-C cool, we will go with independent service.

  • @jkandasa has the independent service been created? I would really love to see this feature. Im using Home Assistant for overall home automation. But I want to manage MySensors with MyController due to the better features to handle MySensor Nodes.

  • Plugin Developer

    @talhatec Still I am working on this feature. I will update you once it gets ready.

  • Plugin Developer

    @talhatec Thank you for your patience
    Finally the first version of serial2mqtt adapter available and released for public. Kindly report issues if you find any on issues page

  • @jkandasa Thanks very very much!

    Awesome work!

    :clap: :clap: :clap:

  • @jkandasa Thank you very much, will give it a go over the weekend.

  • @jkandasa The serial2MQTT adapter worked for a while, but then it started to fail. Looking at the logs, its not receiving the data from serial properly

    2017-08-07 18:04:00,942 ERROR [Thread-1] [org.mycontroller.serial2mqtt.gateway.MessageMonitorThread:66] Exception on processing [RawMessage(gatewayId=null, data=%ヘ보ᅭ￲▒ᅪ゙ノ<*▒oᄚ볘ロ¦▒0;255;3;0;9;TSF:MSG:READ,254-254-0,s=255,c=3,t=1,pt=0,l=0,sg=0:, subData=null, isTxMessage=false, networkType=MY_SENSORS, timestamp=1502125439421)],
    java.lang.NumberFormatException: For input string: "%ヘ보ᅭ￲▒ᅪ゙ノ<*▒oᄚ볘ロ¦▒0"
            at java.lang.NumberFormatException.forInputString(
            at java.lang.Integer.parseInt(
            at java.lang.Integer.valueOf(
            at org.mycontroller.serial2mqtt.gateway.MessageEngine.postOnMqtt(
            at org.mycontroller.serial2mqtt.gateway.MessageMonitorThread.processRawMessage(

  • @jkandasa Not sure what the issue is, but the adapter seems to be working fine now. Ill leave it running for a day and see if the data issue reappears. I was trying to get HomeAssistant and myController to work off the same MQTT topics. maybe thats what cause the data issue.

  • Plugin Developer

    @talhatec Are you seeing this error often?

  • @jkandasa It seems to be stable now. Think that it was a one off issue. Ive now got both HomeAssistant and MyController working on the same MQTT in/out topics.

    However, when a sensor calls back to the controller, both HomeAssistant and myController send out replies, and due to this, i think the messages clash, and the controllers endup sending it multiple times.

    Have to think of a way to make only one respond to requests.

  • Plugin Developer


    However, when a sensor calls back to the controller, both HomeAssistant and myController send out replies, and due to this, i think the messages clash, and the controllers endup sending it multiple times.

    I do not know your preference about, which controller wants to response for your sensors request. Suppose you want MyController only on listen mode, you have to change MQTT Topic publish to some dummy topic on MyController gateway settings.


Log in to reply

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.