anybody have node js flows

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bobbybeans
Normal user
Posts: 119
Joined: 26 Feb 2017, 17:30

anybody have node js flows

#1 Post by bobbybeans » 12 Sep 2017, 13:25

Hey guys
I currently have domoticz and all devices are espeasy
I am running the standard integration of switches where it issues commands via the button within the interface like http://192.168.x.x/gpio?cmd,12,1

I would like to transfer it all over to nodejs and mqtt. I have mosquitto running and working. domoticz has a mqtt gateway, node red is installed, all my esp easy firmware can support the mqtt. I have everything ready to go. My trouble is I cannot find many examples of flows for node red. Does anybody have any that they would be willing to share?

I found this website but no examples of domoticz https://flows.nodered.org/ and not many for swiches
I want to move over from it because I am experincing lag as I have rules in place via blocky which is nice but slow even on my rpi 3. This rpi is running on an external hdd so its not a limit of an SD card. It can take from the press of a button 1-2 seconds to turn on the light which it never used to do that ( I have a ton of devices on it)

another reason I want 1 switch to go from 1 to many not 1 to 1. I can again set that up in blocky rules but its limited and slow. I have my room lights that take about 15 seconds to turn on via blocky as its lit my led strips each on a defferent H801 around my room

any flows /examples of switches would be great

bobbybeans
Normal user
Posts: 119
Joined: 26 Feb 2017, 17:30

Re: anybody have node js flows

#2 Post by bobbybeans » 02 Oct 2017, 22:06

anybody? sorry just following up on this now as i have been so busy for the past 2 months. more like running around like a chicken with no head

jjansen
Normal user
Posts: 20
Joined: 17 Oct 2016, 14:20

Re: anybody have node js flows

#3 Post by jjansen » 04 Oct 2017, 21:07

Just an example:

Via MQTT a message with two different values is sent in the payload. The flow splits it in two in order to process it correctly in Domoticz.

Code: Select all

[
    {
        "id": "ff0dd54d.e3d958",
        "type": "mqtt in",
        "z": "11648062.13843",
        "name": "",
        "topic": "domoticz/in",
        "qos": "2",
        "broker": "8ffa53d7.2be8e",
        "x": 111.5,
        "y": 227,
        "wires": [
            [
                "51f7844.b1c9d7c",
                "3132e5d7.a3d19a"
            ]
        ]
    },
    {
        "id": "51f7844.b1c9d7c",
        "type": "json",
        "z": "11648062.13843",
        "name": "",
        "x": 259.5,
        "y": 227,
        "wires": [
            [
                "ed8d4908.eadd58"
            ]
        ]
    },
    {
        "id": "ed8d4908.eadd58",
        "type": "function",
        "z": "11648062.13843",
        "name": "",
        "func": "var newmsg = [];\n\nif (msg.payload.idx == 1390) {\n    var split = msg.payload.svalue.split(\";\")\n  newmsg.push({\n    svalue:split[1]\n  });\n\n   return newmsg;\n}\n",
        "outputs": "1",
        "noerr": 0,
        "x": 386,
        "y": 227,
        "wires": [
            [
                "12c5784b.ac0608"
            ]
        ]
    },
    {
        "id": "8881c7d7.3a54f8",
        "type": "mqtt out",
        "z": "11648062.13843",
        "name": "",
        "topic": "domoticz/in",
        "qos": "",
        "retain": "",
        "broker": "8ffa53d7.2be8e",
        "x": 746.5,
        "y": 208,
        "wires": []
    },
    {
        "id": "12c5784b.ac0608",
        "type": "change",
        "z": "11648062.13843",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload.idx",
                "pt": "msg",
                "to": "1389",
                "tot": "num"
            },
            {
                "t": "set",
                "p": "payload.nvalue",
                "pt": "msg",
                "to": "0",
                "tot": "num"
            },
            {
                "t": "move",
                "p": "svalue",
                "pt": "msg",
                "to": "payload.svalue",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 537.5,
        "y": 227,
        "wires": [
            [
                "658808f4.2b4dc8",
                "8881c7d7.3a54f8"
            ]
        ]
    },
    {
        "id": "8ffa53d7.2be8e",
        "type": "mqtt-broker",
        "z": "",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": ""
    }
]

bobbybeans
Normal user
Posts: 119
Joined: 26 Feb 2017, 17:30

Re: anybody have node js flows

#4 Post by bobbybeans » 09 Oct 2017, 12:45

thank you very much I shall give that a try :)

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests