Comments about "My home automation projects built with MQTT and Node Red" topic

@PeteKnight
Hi
This is a Tasmota RF Receiver working on 315 / 433 MHz

17:12:14 MQT: tele/sonoff33/RESULT = {"RfReceived":{"Data":"5545C0","Bits":24,"Protocol":1,"Pulse":450}}

I tried ready made Functions but I failed.

Here are My RF Remotes sending

object
topic: "tele/sonoff33/RESULT"
payload: "{"RfReceived":{"Data":"5545C0","Bits":24,"Protocol":1,"Pulse":450}}"
qos: 0 

After json function

payload: object
RfReceived: object
Data: "5545C0"
Bits: 24
Protocol: 1
Pulse: 450
qos: 0
retain: false

Tasmota Sonoff work OK with injected nodes but I need a function to match the RF code.

Thanks.

Hi @Ze_Pico
Presumably, the Sonoff sends different “Data” values if it receives an On or an Off signal?
and your Tasmota node just needs an “ON” or “OFF” payload?
I’ll assume that the “5545C0” data value is an On signal.

Put this in your function node and give it a whirl…

if (msg.data=="5545C0")
{
    msg.payload ="ON"
}

if (msg.data=="XXXXXX") // Your Off value in here...
{
    msg.payload ="OFF"
}

return msg;

Pete.

I tried this before but no result.

if (msg.data=="5545C0")  {  msg.payload ="ON" }
if (msg.data=="554530")  { msg.payload ="OFF" }
return msg;

I am receiving same o/p as the function is not present

My json is adj to
always convert to JS object

Okay, I looked a bit closer and the value that we need is actually nested in the payload, so it’s actually msg.payload.RfReceived.Data

I tried referencing it directly with if (msg.payload.RfReceived.Data=="5545C0") but it didn’t like that. It seems that the solution is to assign the value to a variable then compare against that…

var RF = msg.payload.RfReceived.Data;
node.status({text:RF});

if (RF=="5545C0")  {  msg.payload ="ON" }
if (RF=="554530")  { msg.payload ="OFF" }
return msg;

Pete.

1 Like

YES it works.
I Have two more questions for you.

1 Like

Oh, just to add, I found this handy tip in the documentation the other day…

When you hover over any element, a set of buttons appear on the right:

* : copies the path to the selected element to your clipboard. In this example, it will copy `payload.Phone[2].type` . This allows you to quickly determine how to access a property in a Change or Function node.
* : copies the value of the element to your clipboard as a JSON string. Note that the sidebar truncates Arrays and Buffers over a certain length. Copying the value of such a property will copy the truncated version.
* : pins the selected element so it is always displayed. When another message is received from the same Debug node, it is automatically expanded to show all pinned elements.

https://nodered.org/docs/user-guide/messages

It’s a handy way to work-out how to reference data nested within arrays etc.

Pete.

Fire away…

1-For alexa “Outside Light” you use white light temperature for countdown timer, am I correct ?

2- is it possible to use more than a blynk device with different Auth.

last and not least what is the easiest way to clone my PI SD card ? :smile:

thanks Pete

I think I actually used thermostat temperature (it’s something that I set-up as an example and have since deleted). I made a comment that negative and excessively high values are allowed, so you’d need to do some common sense rules to disallow negative values and silly time durations.

I assume that should read “…than one Blynk device…” ?
Yes, just create a new connection with the new Auth code. I give the connection the same name as the name in Blynk. Just make sure to select the correct connection when you add a new Blynk node, otherwise you’ll quickly get very confused about why things aren’t working!

I turn the Pi off, pop out the card and back it up to my HDD with Win32DiskManager.
I frequently back-up my Node-Red flows using Export/Clipboard and saving them as .txt files. You can also copy the flows file using WinSCP.

@Scargill has discussed his approach quite a few times in his blog:
https://tech.scargill.net/?s=backup

Pete.

I tried it before and again today but didn’t work, it cannot see the image .
I think it is Ext 4 formatted.

also I don’t know how to run the @Scargill script . :thinking:

I don’t think it always adds an .img file extension, so you may need to remove the filter from the open file dialogue box to find the backup files. Win32DiskManager certainly works correctly with the Pi and Windows, I restored a backup file with it only yesterday (after I did something very stupid!).

“The Script” that @Scargill refers to sometimes in his blog is a great tool, but is only used for a fresh install, so you don’t need to run it (there is a step-by-step guide here though…
https://tech.scargill.net/the-script-step-by-step/ ).

If you want to run a regular shell script then take a look at this guide:
http://www.circuitbasics.com/how-to-write-and-run-a-shell-script-on-the-raspberry-pi/

Pete.

sorry, a stupid question it is Win32DiskManager or Win32DiskImager

Sorry, my mistake, should be IMAGER.

Pete.

1 Like

Thanks a lot Pete. I saw a you-tube video on Win32DiskImager and now it is OK.
I manage to copy a 8 GB PI SD image on a 32 GB SD card.
Now everything is running smoothly .

1 Like

@PeteKnight

Salut Pete
Is there a better interpretation for this flow (a simplified version) ?

I need a “Countdown function” so I can see the remaining time on blynk LCD.

Clipboard copy.

[
    {
        "id": "6367c3d6.b0177c",
        "type": "mqtt in",
        "z": "bc3b6538.ad0c48",
        "name": "PIR  @ pin D1",
        "topic": "cmnd/sonoff34/PIR/POWER2",
        "qos": "1",
        "broker": "8a72da15.bf29b8",
        "x": 250,
        "y": 600,
        "wires": [
            [
                "494cfb77.d9ccc4",
                "67a2744.4069f8c"
            ]
        ],
        "outputLabels": [
            "ON / OFF"
        ]
    },
    {
        "id": "9712ba88.f25298",
        "type": "trigger",
        "z": "bc3b6538.ad0c48",
        "op1": "1",
        "op2": "0",
        "op1type": "str",
        "op2type": "str",
        "duration": "3",
        "extend": true,
        "units": "min",
        "reset": "Auto",
        "bytopic": "all",
        "name": "",
        "x": 610,
        "y": 600,
        "wires": [
            [
                "f03a60ed.f0863"
            ]
        ],
        "outputLabels": [
            "1/0"
        ]
    },
    {
        "id": "b4ddff7b.d38d",
        "type": "mqtt out",
        "z": "bc3b6538.ad0c48",
        "name": "LIGHT Relay @ pin D6",
        "topic": "cmnd/sonoff34/POWER",
        "qos": "1",
        "retain": "true",
        "broker": "8a72da15.bf29b8",
        "x": 1220,
        "y": 600,
        "wires": []
    },
    {
        "id": "67a2744.4069f8c",
        "type": "switch",
        "z": "bc3b6538.ad0c48",
        "name": "ON",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "ON",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 430,
        "y": 600,
        "wires": [
            [
                "9712ba88.f25298"
            ]
        ]
    },
    {
        "id": "4f27669.d202598",
        "type": "function",
        "z": "bc3b6538.ad0c48",
        "name": "Override",
        "func": "var over=global.get('overrideMain');\nif (msg.topic.includes(\"OVERRIDE\") || msg.topic.includes(\"alexa\")) {\n    if (msg.payload==\"Auto\"){\n        over=\"AUTO\";\n        global.set('overrideMain',over);\n        node.status({fill:\"blue\",shape:\"dot\",text:\"Override: \"+over}); \n        return msg;\n    } else {\n        if (msg.payload==\"1\") {\n            over=\"ON\";\n            node.status({fill:\"yellow\",shape:\"dot\",text:\"Override: \"+over});\n            msg.payload=\"ON\"\n        }\n        if (msg.payload==\"0\") {\n            over=\"OFF\";\n            node.status({fill:\"grey\",shape:\"dot\",text:\"Override: \"+over});\n            msg.payload=\"OFF\"\n        }\n    global.set('overrideMain',over);\n    return msg;\n    }\n} else {\n    if (over==\"ON\") msg.payload=\"1\";\n    if (over==\"OFF\") msg.payload=\"0\";\n    return msg;\n}",
        "outputs": 1,
        "noerr": 0,
        "x": 980,
        "y": 600,
        "wires": [
            [
                "b4ddff7b.d38d",
                "d981f2c4.da54f",
                "334bd5ad.1d3a9a"
            ]
        ]
    },
    {
        "id": "494cfb77.d9ccc4",
        "type": "function",
        "z": "bc3b6538.ad0c48",
        "name": "PIR",
        "func": "if (msg.payload==\"ON\") node.status({fill:\"yellow\",shape:\"ring\",text:msg.payload});\nelse node.status({fill:\"grey\",shape:\"ring\",text:msg.payload});    \nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 310,
        "y": 680,
        "wires": [
            [
                "d6d6c320.3b94"
            ]
        ]
    },
    {
        "id": "d981f2c4.da54f",
        "type": "debug",
        "z": "bc3b6538.ad0c48",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "x": 1210,
        "y": 660,
        "wires": []
    },
    {
        "id": "22699b.4547a666",
        "type": "ui_button",
        "z": "bc3b6538.ad0c48",
        "name": "OFF",
        "group": "73ce4f22.05854",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": true,
        "label": "OFF",
        "color": "",
        "bgcolor": "",
        "icon": "",
        "payload": "0",
        "payloadType": "str",
        "topic": "MAIN/OVERRIDE/",
        "x": 690,
        "y": 300,
        "wires": [
            [
                "4f27669.d202598",
                "b286bb02.436018"
            ]
        ]
    },
    {
        "id": "7727ade9.1d25f4",
        "type": "ui_button",
        "z": "bc3b6538.ad0c48",
        "name": "ON",
        "group": "73ce4f22.05854",
        "order": 2,
        "width": "3",
        "height": "1",
        "passthru": true,
        "label": "ON",
        "color": "",
        "bgcolor": "",
        "icon": "",
        "payload": "1",
        "payloadType": "str",
        "topic": "MAIN/OVERRIDE/",
        "x": 690,
        "y": 260,
        "wires": [
            [
                "4f27669.d202598"
            ]
        ]
    },
    {
        "id": "93e292b1.7b363",
        "type": "ui_button",
        "z": "bc3b6538.ad0c48",
        "name": "AUTO",
        "group": "73ce4f22.05854",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": true,
        "label": "AUTO",
        "color": "",
        "bgcolor": "",
        "icon": "",
        "payload": "Auto",
        "payloadType": "str",
        "topic": "MAIN/OVERRIDE/",
        "x": 690,
        "y": 340,
        "wires": [
            [
                "4f27669.d202598",
                "9712ba88.f25298",
                "2a16eb9a.9d1d84"
            ]
        ]
    },
    {
        "id": "803b78b6.3b58f8",
        "type": "ui_audio",
        "z": "bc3b6538.ad0c48",
        "name": "",
        "group": "73ce4f22.05854",
        "voice": "en-GB",
        "always": true,
        "x": 1220,
        "y": 700,
        "wires": []
    },
    {
        "id": "47ab51ee.edf15",
        "type": "Sonoff device",
        "z": "bc3b6538.ad0c48",
        "mode": "0",
        "broker": "8a72da15.bf29b8",
        "device": "sonoff34",
        "name": "Tasmota sonoff-34",
        "onValue": "ON",
        "offValue": "OFF",
        "cmdPrefix": "cmnd",
        "statPrefix": "stat",
        "telePrefix": "tele",
        "x": 1170,
        "y": 300,
        "wires": [
            []
        ]
    },
    {
        "id": "f2c8bb00.2c8fd8",
        "type": "inject",
        "z": "bc3b6538.ad0c48",
        "name": "ON",
        "topic": "",
        "payload": "ON",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 250,
        "y": 260,
        "wires": [
            [
                "7727ade9.1d25f4",
                "dbc3c1cc.e3062"
            ]
        ]
    },
    {
        "id": "6b40b1cb.73071",
        "type": "inject",
        "z": "bc3b6538.ad0c48",
        "name": "OFF",
        "topic": "",
        "payload": "OFF",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 250,
        "y": 300,
        "wires": [
            [
                "22699b.4547a666",
                "dbc3c1cc.e3062"
            ]
        ]
    },
    {
        "id": "825f08a8.6a1848",
        "type": "inject",
        "z": "bc3b6538.ad0c48",
        "name": "AUTO",
        "topic": "",
        "payload": "AUTO",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 250,
        "y": 340,
        "wires": [
            [
                "93e292b1.7b363",
                "dbc3c1cc.e3062"
            ]
        ]
    },
    {
        "id": "d14328e4.7184a8",
        "type": "blynk-ws-in-write",
        "z": "bc3b6538.ad0c48",
        "name": "PB-ON",
        "pin": "1",
        "pin_all": 0,
        "client": "554f52d0.f2beac",
        "x": 230,
        "y": 80,
        "wires": [
            [
                "30fb5265.91086e"
            ]
        ]
    },
    {
        "id": "30fb5265.91086e",
        "type": "change",
        "z": "bc3b6538.ad0c48",
        "name": "Change from 1 to ON",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "1",
                "fromt": "str",
                "to": "ON",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 440,
        "y": 100,
        "wires": [
            [
                "1fb6c432.e8d51c"
            ]
        ]
    },
    {
        "id": "1fb6c432.e8d51c",
        "type": "switch",
        "z": "bc3b6538.ad0c48",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "ON",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "OFF",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "AUTO",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 3,
        "x": 670,
        "y": 140,
        "wires": [
            [
                "dbc3c1cc.e3062",
                "7727ade9.1d25f4"
            ],
            [
                "22699b.4547a666",
                "dbc3c1cc.e3062"
            ],
            [
                "93e292b1.7b363",
                "dbc3c1cc.e3062"
            ]
        ]
    },
    {
        "id": "91b07712.6efb08",
        "type": "blynk-ws-out-write",
        "z": "bc3b6538.ad0c48",
        "name": "LED PIR",
        "pin": "4",
        "pinmode": 0,
        "client": "554f52d0.f2beac",
        "x": 760,
        "y": 680,
        "wires": []
    },
    {
        "id": "d6d6c320.3b94",
        "type": "change",
        "z": "bc3b6538.ad0c48",
        "name": "Change from ON/OFF to 255/0",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "ON",
                "fromt": "str",
                "to": "255",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "OFF",
                "fromt": "str",
                "to": "0",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 530,
        "y": 680,
        "wires": [
            [
                "91b07712.6efb08"
            ]
        ]
    },
    {
        "id": "18811f83.8514d",
        "type": "blynk-ws-in-write",
        "z": "bc3b6538.ad0c48",
        "name": "PB-AUTO",
        "pin": "3",
        "pin_all": 0,
        "client": "554f52d0.f2beac",
        "x": 240,
        "y": 200,
        "wires": [
            [
                "8bc458cb.3dc628"
            ]
        ]
    },
    {
        "id": "8bc458cb.3dc628",
        "type": "change",
        "z": "bc3b6538.ad0c48",
        "name": "Change 1 to AUTO",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "1",
                "fromt": "str",
                "to": "AUTO",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 430,
        "y": 180,
        "wires": [
            [
                "1fb6c432.e8d51c"
            ]
        ]
    },
    {
        "id": "78115651.ceaf68",
        "type": "blynk-ws-in-write",
        "z": "bc3b6538.ad0c48",
        "name": "PB-OFF",
        "pin": "2",
        "pin_all": 0,
        "client": "554f52d0.f2beac",
        "x": 240,
        "y": 140,
        "wires": [
            [
                "5a8254b6.78f15c"
            ]
        ]
    },
    {
        "id": "5a8254b6.78f15c",
        "type": "change",
        "z": "bc3b6538.ad0c48",
        "name": "Change from 1 to OFF",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "1",
                "fromt": "str",
                "to": "OFF",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 440,
        "y": 140,
        "wires": [
            [
                "1fb6c432.e8d51c"
            ]
        ]
    },
    {
        "id": "76bfb561.69da1c",
        "type": "blynk-ws-out-write",
        "z": "bc3b6538.ad0c48",
        "name": "ON",
        "pin": "1",
        "pinmode": 0,
        "client": "554f52d0.f2beac",
        "x": 1190,
        "y": 80,
        "wires": []
    },
    {
        "id": "dbc3c1cc.e3062",
        "type": "function",
        "z": "bc3b6538.ad0c48",
        "name": "ON/OFF/AUTO Override",
        "func": "   if (msg.payload==\"ON\") {\n        over=\"ON\";\n        global.set('overrideMain',over);\n        node.status({fill:\"yellow\",shape:\"dot\",text:\"Blynk Override: \"+over});\n//        msg.payload=\"ON\"\n    return [{'payload': '1' }, {'payload': '0' }, {'payload': '0' }]; \n    }\n    if (msg.payload==\"OFF\") {\n        over=\"OFF\";\n        node.status({fill:\"grey\",shape:\"dot\",text:\"Blynk Override: \"+over});\n//        msg.payload=\"OFF\"\n    return [{'payload': '0' }, {'payload': '1' }, {'payload': '0' }]; \n    }\n    if (msg.payload==\"AUTO\"){\n        over=\"AUTO\";\n        node.status({fill:\"blue\",shape:\"dot\",text:\"Blynk Override: \"+over}); \n    return [{'payload': '0' }, {'payload': '0' }, {'payload': '1' }]; \n    }\n//return msg;\n\n\nif (msg.command ==\"TurnOnRequest\")\n{\n//    node.status({ text: \"ON\" });  \n    node.status({fill:\"yellow\",shape:\"dot\",text:\"Alexa Override: ON\"});\n    return [ {'payload': '1' }, {'payload': '0' }, {'payload': '0' }]; \n}\nif (msg.command ==\"TurnOffRequest\")\n{\n//    node.status({ text: 'OFF' });\n    node.status({fill:\"grey\",shape:\"dot\",text:\"Alexa Override: OFF\"});\n    return [ {'payload': '0' }, {'payload': '1' }, {'payload': '0' }];\n}\n\n\nvar RF = msg.payload.RfReceived.Data;\nnode.status({text:RF});\n    if (RF==\"5545C0\")  { \n        node.status({fill:\"yellow\",shape:\"dot\",text:\"RF ON \" + RF})\n        return [{'payload': '1' }, {'payload': '0' }, {'payload': '0' }]; \n    }\n    if (RF== \"554530\") { \n        node.status({fill:\"grey\",shape:\"dot\",text:\"RF OFF \" + RF}); \n        return [{'payload': '0' }, {'payload': '1' }, {'payload': '0' }];\n    }   \n    if (RF== \"55450C\")  {\n        node.status({fill:\"blue\",shape:\"dot\",text:\"RF AUTO \"+ RF}); \n        return [{'payload': '0' }, {'payload': '0' }, {'payload': '1' }]; \n    }   \n//return msg;    \n   \n",
        "outputs": 3,
        "noerr": 0,
        "x": 930,
        "y": 140,
        "wires": [
            [
                "76bfb561.69da1c"
            ],
            [
                "a2ea3fa0.860f4",
                "b286bb02.436018"
            ],
            [
                "a5ce3d36.9ba9f"
            ]
        ]
    },
    {
        "id": "a2ea3fa0.860f4",
        "type": "blynk-ws-out-write",
        "z": "bc3b6538.ad0c48",
        "name": "OFF",
        "pin": "2",
        "pinmode": 0,
        "client": "554f52d0.f2beac",
        "x": 1190,
        "y": 140,
        "wires": []
    },
    {
        "id": "a5ce3d36.9ba9f",
        "type": "blynk-ws-out-write",
        "z": "bc3b6538.ad0c48",
        "name": "AUTO",
        "pin": "3",
        "pinmode": 0,
        "client": "554f52d0.f2beac",
        "x": 1190,
        "y": 200,
        "wires": []
    },
    {
        "id": "66f39b21.8fbab4",
        "type": "alexa-home",
        "z": "bc3b6538.ad0c48",
        "conf": "198887d9.6c0cc8",
        "device": "35277",
        "acknoledge": true,
        "name": "Room",
        "topic": "sonoff34/PIR/alexa",
        "x": 230,
        "y": 400,
        "wires": [
            [
                "4f27669.d202598",
                "dbc3c1cc.e3062"
            ]
        ]
    },
    {
        "id": "4d7d5e0d.24bc2",
        "type": "mqtt in",
        "z": "bc3b6538.ad0c48",
        "name": "RF @ pin D7",
        "topic": "tele/sonoff34/RESULT",
        "qos": "1",
        "broker": "8a72da15.bf29b8",
        "x": 250,
        "y": 500,
        "wires": [
            [
                "9bf73c71.30c8c"
            ]
        ]
    },
    {
        "id": "9bf73c71.30c8c",
        "type": "json",
        "z": "bc3b6538.ad0c48",
        "name": "",
        "property": "payload",
        "action": "obj",
        "pretty": false,
        "x": 450,
        "y": 500,
        "wires": [
            [
                "dbc3c1cc.e3062",
                "44b33006.f419c"
            ]
        ]
    },
    {
        "id": "44b33006.f419c",
        "type": "function",
        "z": "bc3b6538.ad0c48",
        "name": "Data to ON/OFF/AUTO",
        "func": "var RF = msg.payload.RfReceived.Data;\nnode.status({text:RF});\n\n    if (RF==\"5545C0\")  { \n        node.status({fill:\"yellow\",shape:\"dot\",text:\"RF ON \" + RF})\n        return [ {'payload': \"ON\" },  null ,  null  ];\n    }\n    if (RF== \"554530\") { \n        node.status({fill:\"grey\",shape:\"dot\",text:\"RF OFF \" + RF}); \n        return [   null , {'payload': \"OFF\" },   null  ];\n    }   \n    if (RF== \"55450C\")  {\n        node.status({fill:\"blue\",shape:\"dot\",text:\"RF AUTO \"+ RF}); \n        return [   null ,   null , {'payload': \"AUTO\" } ];\n    }   \nreturn [   null ,   null ,   null ];\n//return msg;    \n   \n",
        "outputs": 3,
        "noerr": 0,
        "x": 670,
        "y": 500,
        "wires": [
            [
                "7727ade9.1d25f4"
            ],
            [
                "22699b.4547a666",
                "b286bb02.436018"
            ],
            [
                "93e292b1.7b363"
            ]
        ],
        "outputLabels": [
            "ON",
            "OFF",
            "AUTO"
        ]
    },
    {
        "id": "d0c8b977.e0ecb8",
        "type": "comment",
        "z": "bc3b6538.ad0c48",
        "name": "BLYNK",
        "info": "",
        "x": 70,
        "y": 140,
        "wires": []
    },
    {
        "id": "b71a0915.67ef48",
        "type": "comment",
        "z": "bc3b6538.ad0c48",
        "name": "RF 315",
        "info": "",
        "x": 70,
        "y": 500,
        "wires": []
    },
    {
        "id": "a9de0e0f.48367",
        "type": "comment",
        "z": "bc3b6538.ad0c48",
        "name": "UI",
        "info": "",
        "x": 70,
        "y": 300,
        "wires": []
    },
    {
        "id": "de1073da.e8551",
        "type": "comment",
        "z": "bc3b6538.ad0c48",
        "name": "Alexa",
        "info": "",
        "x": 70,
        "y": 400,
        "wires": []
    },
    {
        "id": "6f040b89.9b41b4",
        "type": "comment",
        "z": "bc3b6538.ad0c48",
        "name": "PIR",
        "info": "",
        "x": 70,
        "y": 600,
        "wires": []
    },
    {
        "id": "f03a60ed.f0863",
        "type": "function",
        "z": "bc3b6538.ad0c48",
        "name": "CountDown",
        "func": "\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 790,
        "y": 600,
        "wires": [
            [
                "4f27669.d202598"
            ]
        ]
    },
    {
        "id": "20af90de.0afc9",
        "type": "blynk-ws-out-lcd",
        "z": "bc3b6538.ad0c48",
        "name": "",
        "pin": "7",
        "client": "554f52d0.f2beac",
        "x": 990,
        "y": 520,
        "wires": []
    },
    {
        "id": "97b7693e.ca1318",
        "type": "blynk-ws-out-write",
        "z": "bc3b6538.ad0c48",
        "name": "LED output",
        "pin": "5",
        "pinmode": 0,
        "client": "554f52d0.f2beac",
        "x": 1190,
        "y": 480,
        "wires": []
    },
    {
        "id": "845ed4e2.8bbad8",
        "type": "change",
        "z": "bc3b6538.ad0c48",
        "name": "Change from ON/OFF to 255/0",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "ON",
                "fromt": "str",
                "to": "255",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "OFF",
                "fromt": "str",
                "to": "0",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1110,
        "y": 420,
        "wires": [
            [
                "97b7693e.ca1318"
            ]
        ]
    },
    {
        "id": "69a8593.a61daa8",
        "type": "mqtt in",
        "z": "bc3b6538.ad0c48",
        "name": "",
        "topic": "stat/sonoff34/POWER",
        "qos": "1",
        "broker": "8a72da15.bf29b8",
        "x": 1100,
        "y": 360,
        "wires": [
            [
                "845ed4e2.8bbad8"
            ]
        ]
    },
    {
        "id": "2a16eb9a.9d1d84",
        "type": "change",
        "z": "bc3b6538.ad0c48",
        "name": "Send ON",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "Auto",
                "fromt": "str",
                "to": "ON",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 880,
        "y": 340,
        "wires": [
            []
        ]
    },
    {
        "id": "b286bb02.436018",
        "type": "function",
        "z": "bc3b6538.ad0c48",
        "name": "Reset",
        "func": "msg.payload ='Auto';\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 870,
        "y": 300,
        "wires": [
            [
                "9712ba88.f25298"
            ]
        ]
    },
    {
        "id": "334bd5ad.1d3a9a",
        "type": "change",
        "z": "bc3b6538.ad0c48",
        "name": "change",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "1",
                "fromt": "str",
                "to": "Motion",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "0",
                "fromt": "str",
                "to": " ",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1000,
        "y": 700,
        "wires": [
            [
                "bb80c38a.700dc",
                "803b78b6.3b58f8"
            ]
        ]
    },
    {
        "id": "bb80c38a.700dc",
        "type": "googlehome-notify",
        "z": "bc3b6538.ad0c48",
        "server": "8884b30e.ec758",
        "name": "Google Home",
        "x": 1200,
        "y": 760,
        "wires": []
    },
    {
        "id": "8a72da15.bf29b8",
        "type": "mqtt-broker",
        "z": "",
        "name": "Mosquito",
        "broker": "192.168.xxx.xxx",
        "port": "1883",
        "clientid": "Sonoff33",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "1",
        "birthRetain": "true",
        "birthPayload": "",
        "closeTopic": "",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    },
    {
        "id": "73ce4f22.05854",
        "type": "ui_group",
        "z": "",
        "name": "HALL",
        "tab": "a5b4907f.531a6",
        "disp": true,
        "width": "3",
        "collapse": false
    },
    {
        "id": "554f52d0.f2beac",
        "type": "blynk-ws-client",
        "z": "",
        "name": "PIR",
        "path": "ws://xxx.xxx.xxx.xxx/websockets",
        "key": "fa615fd8abd5444d9cce9a9aa6ec9a4b",
        "dbg_all": false,
        "dbg_read": false,
        "dbg_write": false,
        "dbg_notify": false,
        "dbg_mail": false,
        "dbg_prop": false,
        "dbg_sync": false,
        "dbg_bridge": false,
        "dbg_low": false,
        "dbg_pins": "",
        "multi_cmd": false,
        "proxy_type": "no",
        "proxy_url": ""
    },
    {
        "id": "198887d9.6c0cc8",
        "type": "alexa-home-conf",
        "z": "",
        "username": "xxx"
    },
    {
        "id": "8884b30e.ec758",
        "type": "googlehome-config-node",
        "z": "",
        "ipaddress": "192.168.xxx.xxx",
        "name": "",
        "language": "en"
    },
    {
        "id": "a5b4907f.531a6",
        "type": "ui_tab",
        "z": "bc3b6538.ad0c48",
        "name": "Sonoff",
        "icon": "dashboard",
        "order": 1
    }
]

Hi @Ze_Pico, I’m making some fairly substantial changes to my Node-Red setup in Spain at the moment (in between doing some plastering, painting and electrical work), so I’m not going to import your flow into my system at this stage, as I don’t want to risk breaking anything.

Considering what it is you’re trying to achieve, including the integration into numerous other systems, the flow looks well structured and straight forward. It looks like you’ve made quite a bit of progress!

It might be worth you re-reading this post:

Especially the bit about how I did the countdown timer and how the remaining time in minutes and seconds is calculated and outputted to a widget to display the remaining time. I used a switch widget for that, but you could use a labelled display if it works better for you.

Pete.

If you duplicate your SD Card there is no risk breaking anything :smile:

nothing hurry, I can wait until you finish all your works and have time to test it.

I tested your flow 3 weeks ago & it was working fine.
what I didn’t like, that you use Alexa temperature (deg) to set the timer (sec).

mean while I will try to complete it by myself .
I usually try the easiest way as you are an expert in Java Script.
Thanks.

:rofl::rofl::rofl:

@PeteKnight
I am trying to understand why topics are split moved or closed?

I’m planning to add some more articles to the MQTT home automation thread but and it had got a bit messy, so I’d asked @Gunner to move the comments into a different thread.
I want to try and make it easy (and not too off-putting) for Node-Red virgins to follow the thread and hopefully have a go for themselves.

This thread should be a useful resource for people who want to get into a bit more detail. Two different target audiences, hence two different threads.

Pete.