[SOLVED] Serial to MQTT conversion by Node-red



  • Hi
    I'm trying to connect my serial mysensors gateway to orange PC with domoticz
    Domoticz accept only USB-serial device, LAN and MQTT.
    Now I want to convert serial data to MQTT with node-red and use MQTT gateway in Domoticz

    My node red clipboard:
    alt text

    serial to mqtt code:

    var sensor = msg.payload.split(";");
    msg.topic = "MySensors" + "/" + sensor[0] + "/" + sensor[1] + "/" + sensor[2] + "/" + sensor[3] + "/" + sensor[4];
    msg.payload = sensor[5];
    return msg;
    

    Output MQTT text when the gateway initializing:

    object
    payload: "0 MCO:BGN:INIT GW,CP=RNNGA---,VER=2.2.0↵"
    port: "/dev/ttyS1"
    _msgid: "619c024c.85ed8c"
    topic: "MySensors/0/255/3/0/9"
    

    other messages same like this

    Button node

    object
    payload: "328523 TSF:MSG:READ,1-1-0,s=4,c=1,t=16,pt=1,l=1,sg=0:0↵"
    port: "/dev/ttyS1"
    _msgid: "11581f7a.7c16b1"
    topic: "MySensors/0/255/3/0/9"
    
    object
    payload: "0↵"
    port: "/dev/ttyS1"
    _msgid: "782972d9.6e0e3c"
    topic: "MySensors/1/4/1/0/16"
    

    But gateway receiving nothing
    Also serial gateway node not found

    What im doing wrong?



  • I don't have an answer for your question but maybe my python script could help You:
    https://github.com/mczerski/MySensorsSerial2MQTT



  • Lol. I just forgot to change the topic in my code from "MySensors" to "domoticz/out/MyMQTT"
    Now working fine


Log in to reply
 

Suggested Topics

  • 1
  • 1
  • 10
  • 6
  • 3
  • 5

52
Online

11.4k
Users

11.1k
Topics

112.7k
Posts