myscontroller with ethernet gateway



  • Hi everyone!

    I currently try to setup my first MySensors network.
    I have a sensor and an ethernet gateway sitting on a breadboard and I try to get the sensor data into my database with NodeRed.
    NodeRed is running in a docker container on my database server.
    But I am not able to get the NodeRed myscontroller to work.
    Here is my test flow:

    [
        {
            "id": "16a94524.a7f49b",
            "type": "tab",
            "label": "MySensors",
            "disabled": false,
            "info": ""
        },
        {
            "id": "5ee1d371.4bf144",
            "type": "myscontroller",
            "z": "16a94524.a7f49b",
            "database": "6211fee5.94057",
            "name": "",
            "handleid": true,
            "timeresponse": true,
            "timezone": "Europe/Berlin",
            "measurementsystem": "M",
            "mqttroot": "mys-out",
            "x": 870,
            "y": 180,
            "wires": [
                [
                    "8fd52d51.33df68",
                    "dfec2cf6.42e45"
                ]
            ]
        },
        {
            "id": "c9f3dd7.76aa4a",
            "type": "tcp in",
            "z": "16a94524.a7f49b",
            "name": "MySensors Gateway In",
            "server": "client",
            "host": "mysensors-gateway",
            "port": "5003",
            "datamode": "stream",
            "datatype": "utf8",
            "newline": "",
            "topic": "",
            "base64": false,
            "x": 280,
            "y": 180,
            "wires": [
                [
                    "dc2b7145.4ea57"
                ]
            ]
        },
        {
            "id": "dc2b7145.4ea57",
            "type": "mysdecode",
            "z": "16a94524.a7f49b",
            "database": "6211fee5.94057",
            "name": "decode",
            "mqtt": false,
            "enrich": true,
            "x": 460,
            "y": 180,
            "wires": [
                [
                    "5ee1d371.4bf144",
                    "d63bd8aa.d34ef8"
                ]
            ]
        },
        {
            "id": "9e6d49f6.34fef",
            "type": "tcp out",
            "z": "16a94524.a7f49b",
            "host": "mysensors-gateway",
            "port": "5003",
            "beserver": "reply",
            "base64": false,
            "end": false,
            "name": "MySensors Gateway Out",
            "x": 1490,
            "y": 180,
            "wires": []
        },
        {
            "id": "8fd52d51.33df68",
            "type": "mysencode",
            "z": "16a94524.a7f49b",
            "name": "encode",
            "mqtt": false,
            "mqtttopic": "",
            "x": 1260,
            "y": 180,
            "wires": [
                [
                    "9e6d49f6.34fef"
                ]
            ]
        },
        {
            "id": "d63bd8aa.d34ef8",
            "type": "mysdebug",
            "z": "16a94524.a7f49b",
            "name": "",
            "x": 670,
            "y": 300,
            "wires": [
                [
                    "4170e76.d577f98"
                ]
            ]
        },
        {
            "id": "4170e76.d577f98",
            "type": "debug",
            "z": "16a94524.a7f49b",
            "name": "request",
            "active": true,
            "tosidebar": true,
            "console": false,
            "tostatus": false,
            "complete": "payload",
            "targetType": "msg",
            "statusVal": "",
            "statusType": "auto",
            "x": 660,
            "y": 380,
            "wires": []
        },
        {
            "id": "dfec2cf6.42e45",
            "type": "mysdebug",
            "z": "16a94524.a7f49b",
            "name": "",
            "x": 1070,
            "y": 300,
            "wires": [
                [
                    "5653b23b.03664c"
                ]
            ]
        },
        {
            "id": "5653b23b.03664c",
            "type": "debug",
            "z": "16a94524.a7f49b",
            "name": "response",
            "active": true,
            "tosidebar": true,
            "console": false,
            "tostatus": false,
            "complete": "payload",
            "targetType": "msg",
            "statusVal": "",
            "statusType": "auto",
            "x": 1080,
            "y": 380,
            "wires": []
        },
        {
            "id": "6211fee5.94057",
            "type": "mysensorsdb",
            "name": "mysensorsnodedb",
            "file": "/data/mysensorsnode.db"
        }
    ]
    

    For me it looks like the controller receives messages from the gateway and response to them within the flow but the messages don't go to back to the gateway.

    I tested my setup with the MyController controller just to be sure my hardware works and everything worked instantly.

    I'm not very familiar with NodeRed so I guess I made some mistake. Can someone point me to the right direction?



  • @JohnDoe2991
    I'm wondering if you have to decode before going to myscontroller

    So like this

    [
        {
            "id": "16a94524.a7f49b",
            "type": "tab",
            "label": "MySensors",
            "disabled": false,
            "info": ""
        },
        {
            "id": "5ee1d371.4bf144",
            "type": "myscontroller",
            "z": "16a94524.a7f49b",
            "database": "6211fee5.94057",
            "name": "",
            "handleid": true,
            "timeresponse": true,
            "timezone": "Europe/Berlin",
            "measurementsystem": "M",
            "mqttroot": "mys-out",
            "x": 870,
            "y": 180,
            "wires": [
                [
                    "8fd52d51.33df68",
                    "dfec2cf6.42e45"
                ]
            ]
        },
        {
            "id": "c9f3dd7.76aa4a",
            "type": "tcp in",
            "z": "16a94524.a7f49b",
            "name": "MySensors Gateway In",
            "server": "client",
            "host": "mysensors-gateway",
            "port": "5003",
            "datamode": "stream",
            "datatype": "utf8",
            "newline": "",
            "topic": "",
            "base64": false,
            "x": 280,
            "y": 180,
            "wires": [
                [
                    "dc2b7145.4ea57"
                ]
            ]
        },
        {
            "id": "dc2b7145.4ea57",
            "type": "mysdecode",
            "z": "16a94524.a7f49b",
            "database": "6211fee5.94057",
            "name": "decode",
            "mqtt": false,
            "enrich": true,
            "x": 460,
            "y": 180,
            "wires": [
                [
                    "5ee1d371.4bf144",
                    "d63bd8aa.d34ef8"
                ]
            ]
        },
        {
            "id": "9e6d49f6.34fef",
            "type": "tcp out",
            "z": "16a94524.a7f49b",
            "host": "mysensors-gateway",
            "port": "5003",
            "beserver": "reply",
            "base64": false,
            "end": false,
            "name": "MySensors Gateway Out",
            "x": 1490,
            "y": 180,
            "wires": []
        },
        {
            "id": "8fd52d51.33df68",
            "type": "mysencode",
            "z": "16a94524.a7f49b",
            "name": "encode",
            "mqtt": false,
            "mqtttopic": "",
            "x": 1260,
            "y": 180,
            "wires": [
                [
                    "9e6d49f6.34fef"
                ]
            ]
        },
        {
            "id": "d63bd8aa.d34ef8",
            "type": "mysdebug",
            "z": "16a94524.a7f49b",
            "name": "",
            "x": 670,
            "y": 300,
            "wires": [
                [
                    "4170e76.d577f98"
                ]
            ]
        },
        {
            "id": "4170e76.d577f98",
            "type": "debug",
            "z": "16a94524.a7f49b",
            "name": "request",
            "active": true,
            "tosidebar": true,
            "console": false,
            "tostatus": false,
            "complete": "payload",
            "targetType": "msg",
            "statusVal": "",
            "statusType": "auto",
            "x": 660,
            "y": 380,
            "wires": []
        },
        {
            "id": "dfec2cf6.42e45",
            "type": "mysdebug",
            "z": "16a94524.a7f49b",
            "name": "",
            "x": 1070,
            "y": 300,
            "wires": [
                [
                    "5653b23b.03664c"
                ]
            ]
        },
        {
            "id": "5653b23b.03664c",
            "type": "debug",
            "z": "16a94524.a7f49b",
            "name": "response",
            "active": true,
            "tosidebar": true,
            "console": false,
            "tostatus": false,
            "complete": "payload",
            "targetType": "msg",
            "statusVal": "",
            "statusType": "auto",
            "x": 1080,
            "y": 380,
            "wires": []
        },
        {
            "id": "6211fee5.94057",
            "type": "mysensorsdb",
            "name": "mysensorsnodedb",
            "file": "/data/mysensorsnode.db"
        }
    ]
    


  • @electrik
    Thanks for the reply, I think I've figured it out now:
    If i connect the myscontroller directly with the TCP connections, it won't send any messages. More importantly it looks like the whole gateway stops working correctly then. I don't receive any messages from the TCP connection.
    I have to add an decode and encode on each side of the myscontroller and restart the gateway so it will work properly.

    I guess when I tried my first flow yesterday I connected the myscontroller directly to the TCP connections and crashed my gateway this way. I didn't noticed that and thats why my second flow with the decode and encode didn't work either.

    So, all in all, it was just a "Have you tried turning it off and on again?" problem.



  • Good to hear you solved it!



  • Well, I'm back again, because it broke again ... and I fixed it somehow again.
    I was playing around with my sensor to get it up and running the way I want it to and resetted its node id.
    It couldn't get a new node ID and I was back where I was yesterday.
    Deleted everything, rebuild the complete flow, restarted everything. Nothing helped. So I added debug messages everywhere and also had a look into the raw Serial protocol here: https://www.mysensors.org/download/serial_api_20
    It looks like you don't need the encode and decode, at least for me the encode after myscontroller totally destroyed the payload. Why did it work yesterday? I have no idea.
    The payload looked fine now without the decode and encode according to the protocol, but it still didn't work. I noticed that the incoming TCP payload always ended with a linefeed "\n", so I added a custom function between the myscontroller and tcp output to also add a linefeed to the outgoing payload and it's working again.


Log in to reply
 

Suggested Topics

49
Online

11.4k
Users

11.1k
Topics

112.7k
Posts