# Controlling Tasmota switch with Node Red

**URL:** https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945
**Category:** General
**Created:** [16 December 2024 20:41 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945 "2024-12-16T20:41:34Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![OffGridNoob](https://avatars.discourse-cdn.com/v4/letter/o/41988e/32.png) [@OffGridNoob](https://discourse.nodered.org/u/OffGridNoob)
#### Post date: [16 December 2024 20:41 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/1 "2024-12-16T20:41:34Z")

</div>

I have NR running on a Cerbo GX device which is WiFi.

I have a Tasmota switch that is also WiFi.

I would like my NR flows to turn the Tasmota switch ON/OFF.

Do I need a third device to do this, or can I simply connect the Tasmota to the Cerbo GX WiFi (although the Cerbo GX is not a router)...

I'm guessing I'll need a router and maybe another device to run an MQTT broker or something?

Many thanks for any input.

---

<div class="post-metadata">

### Author: ![hominidae](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hominidae/32/4174_2.png) [@hominidae](https://discourse.nodered.org/u/hominidae)
#### Post date: [16 December 2024 22:00 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/2 "2024-12-16T22:00:44Z")

</div>

> [@OffGridNoob](#):
>
> I would like my NR flows to turn the Tasmota switch ON/OFF.

There are basically two ways to achieve this.

1. use the http-API of the tasmota device - connect directly from a http-node from NR or install a tasmota package.
2. the Cerbo GX also runs a broker. You **could** make use of that and configure the GX as the broker in your tasmota device. Then use mqtt-nodes to control your device via NR.

For simple use cases and a few devices, I'd recommend variant (1).  
For higher number of device, maybe in conjunction with a smart home EMS, like homeassistant, I recommend to use a separate device/server for a broker and EMS and not the GX.

---

<div class="post-metadata">

### Author: ![OffGridNoob](https://avatars.discourse-cdn.com/v4/letter/o/41988e/32.png) [@OffGridNoob](https://discourse.nodered.org/u/OffGridNoob)
#### Post date: [16 December 2024 22:17 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/3 "2024-12-16T22:17:58Z")

</div>

I'm sure glad I asked, many thanks!

So if I put in the Cerbo GX's WiFi into the Tasmota device, it will connect to that WiFi even though the Cerbo isn't a router? That's the part I was missing.

I will study up on the http-API of the device and the http-node on NR. Thanks again, glad I don't have to buy a router!

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [16 December 2024 22:26 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/4 "2024-12-16T22:26:59Z")

</div>

How do you connect to Node-red on the Cerbo - is it using WiFi or Ethernet?  
What device are you using to display the editor?

---

<div class="post-metadata">

### Author: ![OffGridNoob](https://avatars.discourse-cdn.com/v4/letter/o/41988e/32.png) [@OffGridNoob](https://discourse.nodered.org/u/OffGridNoob)
#### Post date: [16 December 2024 22:34 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/5 "2024-12-16T22:34:11Z")

</div>

The Cerbo GX actually runs Node Red.

Then the Cerbo also has WiFi, although it's not a router, so I'm hoping I can just connect that Tasmota device to the Cerbo WiFi and not have to involve a router for the Node Red to control it, which thanks to the info above, sounds like I can.

I also have ethernet plugged into the Cerbo which becomes fiber which runs 700 feet away to my cabin into a WiFi router and I use my computer over the LAN to connect to Node Red editor on the Cerbo. But the Tasmota device is actually next to the Cerbo to control what I need it to control so I can't use the router in my cabin for that.

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [16 December 2024 23:01 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/6 "2024-12-16T23:01:23Z")

</div>

> [@OffGridNoob](#):
>
> Then the Cerbo also has WiFi, although it's not a router, so I'm hoping I can just connect that Tasmota device to the Cerbo WiFi

It seems unlikely to me & I don't think that's what @hominidae was suggesting you can do. (Apologies if I misunderstand.)

If the Tasmota device is wifi only I think you will need some sort of router or access point nearby.

> [@OffGridNoob](#):
>
> I also have ethernet plugged into the Cerbo which becomes fiber

What device converts ethernet to fibre? How many ethernet ports does it have?

---

<div class="post-metadata">

### Author: ![OffGridNoob](https://avatars.discourse-cdn.com/v4/letter/o/41988e/32.png) [@OffGridNoob](https://discourse.nodered.org/u/OffGridNoob)
#### Post date: [16 December 2024 23:17 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/7 "2024-12-16T23:17:03Z")

</div>

The device is a fiber to ethernet converter, but it only has one port. The Tasmota device is WiFi only so if I misunderstood about the Cerbo connecting to the Tasmota directly then I will need to get another WiFi router anyway I suppose.

---

<div class="post-metadata">

### Author: ![hominidae](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hominidae/32/4174_2.png) [@hominidae](https://discourse.nodered.org/u/hominidae)
#### Post date: [17 December 2024 06:38 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/8 "2024-12-17T06:38:25Z")

</div>

> [@OffGridNoob](#):
>
> So if I put in the Cerbo GX's WiFi into the Tasmota device, it will connect to that WiFi even though the Cerbo isn't a router? That's the part I was missing.

> [@OffGridNoob](#):
>
> I also have ethernet plugged into the Cerbo which becomes fiber which runs 700 feet away to my cabin into a WiFi router and I use my computer over the LAN to connect to Node Red editor on the Cerbo. But the Tasmota device is actually next to the Cerbo to control what I need it to control so I can't use the router in my cabin for that.

...with thee main network connection of the Cerbo being ethernet/LAN, you can use the WiFi of the Cerbo to create an AccessPoint

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0dc30cc3b0143e41bfd2627ef867cf11525d9d65.png)

...it will not become a router nor will it form a bridge, like a regular AP would do ((I think), see: [7.&nbsp;Accessing the GX device](https://www.victronenergy.com/media/pg/Cerbo_GX/en/accessing-the-gx-device.html#UUID-12ee0e7e-a2db-4c34-1ab3-db19636edc37)  
The tasmota device then can connect to that AP...it should be receiving an IP via DHCP from either the Cerbo or your main Router, like your PC.  
I never tried this.  
Easier thing to do, as you have a LAN connection would be to add an AP with at least a two port LAN Switch. Simple ones are dead cheap...maybe a travel router, like models from [gli.net](https://www.gl-inet.com/products/) is a feasible option for you (Edit: some travel routers can be powered via USB and the GX has a dedicated USB PD port - normally used to power the separate touch screen)

---

<div class="post-metadata">

### Author: ![OffGridNoob](https://avatars.discourse-cdn.com/v4/letter/o/41988e/32.png) [@OffGridNoob](https://discourse.nodered.org/u/OffGridNoob)
#### Post date: [17 December 2024 09:43 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/9 "2024-12-17T09:43:51Z")

</div>

Thank you again. I will try this and report back.

---

<div class="post-metadata">

### Author: ![OffGridNoob](https://avatars.discourse-cdn.com/v4/letter/o/41988e/32.png) [@OffGridNoob](https://discourse.nodered.org/u/OffGridNoob)
#### Post date: [17 December 2024 23:13 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/10 "2024-12-17T23:13:18Z")

</div>

I was able to connect the Tasmota device to the access point wifi generated by the Cerbo GX with access point enabled.

I set the other LAN that I have been using to control the Tasmota device as the secondary wifi before doing this, in the hope that if I could not connect to it through the Cerbo's AP, that I could turn that AP off in the Cerbo and the Tasmota device would then switch back to the original WiFi I've been using.

Unfortunately the device just disappeared. I assume it WiFi connected successfully to the Cerbo's broadcasted access point, but then I was unable to reach the Tasmota device even after switching to the LAN connected to the Cerbo.

So I disabled the access point in the Cerbo, thinking the Tasmota device would switch back to the original WiFi router, but that didn't happen.

So I bought another WiFi router and I'll reset the Tasmota device and connect my Cerbo and Tasmota device together through the new router.

It was worth a shot anyway!

---

<div class="post-metadata">

### Author: ![WhiteLion](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whitelion/32/12266_2.png) [@WhiteLion](https://discourse.nodered.org/u/WhiteLion)
#### Post date: [19 December 2024 10:55 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/11 "2024-12-19T10:55:38Z")

</div>

I ve a flow with much stuff inside but I think its better to post only parts of it (to much other stuff for switches inside):

```auto
[
    {
        "id": "dad2ad8d29b5f57a",
        "type": "ui-led",
        "z": "ba1f4b99a9e664d8",
        "name": "Verbindung:",
        "group": "15ecf48a1d47cdcb",
        "order": 4,
        "width": "2",
        "height": "1",
        "label": "Verbindung:",
        "labelPlacement": "left",
        "labelAlignment": "flex-start",
        "states": [
            {
                "value": "false",
                "valueType": "bool",
                "color": "#ff0000"
            },
            {
                "value": "true",
                "valueType": "bool",
                "color": "#00ff00"
            }
        ],
        "allowColorForValueInMessage": false,
        "shape": "circle",
        "showBorder": true,
        "showGlow": true,
        "x": 1270,
        "y": 1380,
        "wires": []
    },
    {
        "id": "4921317e571d2772",
        "type": "ui_led",
        "z": "ba1f4b99a9e664d8",
        "order": 9,
        "group": "1631802e9c3c9572",
        "width": "3",
        "height": "1",
        "label": "Verbindung:",
        "labelPlacement": "left",
        "labelAlignment": "left",
        "colorForValue": [
            {
                "color": "#ff0000",
                "value": "false",
                "valueType": "bool"
            },
            {
                "color": "#008000",
                "value": "true",
                "valueType": "bool"
            }
        ],
        "allowColorForValueInMessage": false,
        "shape": "circle",
        "showGlow": true,
        "name": "isAwake",
        "x": 1260,
        "y": 1340,
        "wires": []
    },
    {
        "id": "81e3a6a72a2001b8",
        "type": "debug",
        "z": "ba1f4b99a9e664d8",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 1250,
        "y": 1300,
        "wires": []
    },
    {
        "id": "5b7425c7ea68d8c2",
        "type": "function",
        "z": "ba1f4b99a9e664d8",
        "name": "awaikStatus",
        "func": "msg.utsCurrent = parseInt(+new Date())||800;\nmsg.utsLastSensorMessage = flow.get(\"utsLastSensorMessage_t\")||500;\n\nmsg.lastSeenSecodsPassed = msg.utsCurrent - msg.utsLastSensorMessage;\nif (msg.lastSeenSecodsPassed > 60000)\n{\n msg.payload = false;\n return msg;\n}\nelse\n{\n msg.payload = true;\n return msg;\n}\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1070,
        "y": 1340,
        "wires": [
            [
                "4921317e571d2772",
                "81e3a6a72a2001b8",
                "dad2ad8d29b5f57a"
            ]
        ]
    },
    {
        "id": "085f83cc440f8925",
        "type": "inject",
        "z": "ba1f4b99a9e664d8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": true,
        "onceDelay": "20",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 1070,
        "y": 1300,
        "wires": [
            [
                "5b7425c7ea68d8c2"
            ]
        ]
    },
    {
        "id": "919c269fc9fb07f7",
        "type": "debug",
        "z": "ba1f4b99a9e664d8",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 970,
        "y": 1260,
        "wires": []
    },
    {
        "id": "46b84c72ade60c76",
        "type": "function",
        "z": "ba1f4b99a9e664d8",
        "name": "isSensorId",
        "func": "let Id = flow.get('SensorId')||\"empty\";\n//let mqttBlocktime = flow.get(\"MttBlocktime\"); //|| (parseInt(+new Date()) + 2000);\nlet utsNow = parseInt(+new Date());\n\nif(msg.topic.match(Id) && msg.topic.match(\"RESULT\"))\n{\n if(IsJsonString(msg.payload)) \n {\n msg.payload = JSON.parse(msg.payload);\n if(msg.payload.hasOwnProperty(\"Button1\")) \n {\n if(msg.payload.Button1.hasOwnProperty(\"Action\"))\n {\n let RelayState = flow.get(\"relayStatus\");\n //if (mqttBlocktime > utsNow) return null;\n let pl = {};\n //pl.mqttBlocktime = mqttBlocktime;\n pl.utsNow = utsNow;\n pl.topic = msg.topic;\n pl.payload = {};\n pl.payload.Id = Id;\n if (msg.payload.Button1.Action === \"SINGLE\" && RelayState === false ) \n { pl.payload.Relay = \"On\"; }\n else if (msg.payload.Button1.Action === \"SINGLE\" && RelayState === true ) \n { pl.payload.Relay = \"Off\"; } \n else if (msg.payload.Button1.Action !== \"SINGLE\") \n { pl.payload.ButtonPresses = msg.payload.Button1.Action; } \n else\n { return [null, null]; }\n return [pl, null];\n }\n }\n if(msg.payload.hasOwnProperty(\"POWER\"))\n {\n // return null;\n //if (mqttBlocktime > utsNow) return null;\n let pl = {};\n //pl.mqttBlocktime = mqttBlocktime;\n pl.utsNow = utsNow;\n pl.topic = msg.topic;\n pl.payload = {};\n pl.cmdsource = \"SwitchWebInterface\";\n pl.payload.Id = Id;\n if (msg.payload.POWER === \"ON\") \n { pl.payload.Relay = \"On\"; }\n else if (msg.payload.POWER === \"OFF\") \n { pl.payload.Relay = \"Off\"; } \n else\n { return [null, null]; }\n return [pl, null];\n } \n }\n \n\n}\nelse if(msg.topic.match(Id) && msg.topic.match(\"SENSOR\"))\n{\n // Set Time for device online satus:\n flow.set(\"utsLastSensorMessage_t\", utsNow) || 5;\n\n if(IsJsonString(msg.payload)) msg.payload = JSON.parse(msg.payload);\n let power = parseInt(msg.payload.ENERGY.Power);\n if (power > 5000) power = 0;\n return [null, { \"payload\": power }];\n}\nelse\n{\n return [null, null];\n}\n\n\n// \"stat/SwitchTypT/84:F3:EB:31:CB:62/POWER\"\n\n\n\n\n// let Id = flow.get('SensorId')||\"empty\";\n// if (Id == \"empty\") return null;\n// if(IsJsonString(msg.payload)) msg.payload = parseJsonString(msg.payload);\n// if(msg.topic == \"stat/SwitchTypT/\" + Id + \"/STATUS10\")\n// {\n// return [msg, null, null, null];\n// }\n// else if(msg.topic == \"tele/SwitchTypT/\" + Id + \"/SENSOR\")\n// {\n// return [null, msg, null, null];\n// }\n// else if(msg.topic == \"cmnd/SwitchTypT/\" + Id + \"/POWER\")\n// {\n// return [null, null, msg, null];\n// }\n// else\n// {\n// return [null, null, null, msg];\n// }\n\n\n\n\n \n\n\nfunction IsJsonString(str) \n{\n try {\n JSON.parse(str);\n } catch (e) {\n return false;\n }\n return true;\n}\n\nfunction parseJsonString(str) \n{\n let parsedJson = JSON.parse(str);\n return parsedJson; \n}",
        "outputs": 2,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 770,
        "y": 1260,
        "wires": [
            [
                "feec226e3c412516",
                "a7f28cbac63f0146",
                "9059d6412b20f34d"
            ],
            [
                "0b54fbaac9ee3493",
                "919c269fc9fb07f7",
                "5b7425c7ea68d8c2"
            ]
        ]
    },
    {
        "id": "efe545702374712c",
        "type": "mqtt in",
        "z": "ba1f4b99a9e664d8",
        "d": true,
        "name": "",
        "topic": "tele/#",
        "qos": "0",
        "datatype": "auto",
        "broker": "f55c6c0d.194bb",
        "nl": false,
        "rap": false,
        "inputs": 0,
        "x": 610,
        "y": 1200,
        "wires": [
            [
                "46b84c72ade60c76",
                "ca9876cd3c7a3d2b"
            ]
        ]
    },
    {
        "id": "b98ff48da1322938",
        "type": "mqtt in",
        "z": "ba1f4b99a9e664d8",
        "d": true,
        "name": "",
        "topic": "stat/#",
        "qos": "0",
        "datatype": "auto",
        "broker": "f55c6c0d.194bb",
        "nl": false,
        "rap": false,
        "inputs": 0,
        "x": 610,
        "y": 1320,
        "wires": [
            [
                "41aae98349883907",
                "46b84c72ade60c76"
            ]
        ]
    },
    {
        "id": "a7f28cbac63f0146",
        "type": "function",
        "z": "ba1f4b99a9e664d8",
        "name": "setTriggerPriority",
        "func": "let flowX = flow.get('SensorId')||\"empty\";\nif (flowX == \"empty\") return null;\nlet keyX = \"PriorityMqtt\";\nlet conf = global.get('globalConfig');\nlet prio = conf[flowX][keyX];\nmsg.priority = prio;\nif (msg.cmdsource === \"SwitchWebInterface\") msg.priority = flow.get('priorityStatus')||99;\n//msg.cmdsource = \"PriorityMqtt\";\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1010,
        "y": 1200,
        "wires": [
            [
                "ea8601088eff9004"
            ]
        ]
    },
    {
        "id": "feec226e3c412516",
        "type": "debug",
        "z": "ba1f4b99a9e664d8",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 970,
        "y": 1160,
        "wires": []
    },
    {
        "id": "ea8601088eff9004",
        "type": "function",
        "z": "ba1f4b99a9e664d8",
        "name": "setLightSwitch",
        "func": "let priorityStatus = flow.get('priorityStatus')||99;\nif(msg.priority > priorityStatus) return null;\nif (msg.payload.Relay == \"Off\" || msg.payload === false)\n{\n //let tmp = msg.payload;\n\n let newPayload = {};\n newPayload.Id = flow.get('SensorId')||\"empty\";\n newPayload.Relay = \"Off\";\n msg.payload = newPayload;\n \n let newPayload2 = {};\n let state = false;\n newPayload2.payload = state;\n flow.set(\"relayStatus\", state);\n flow.set(\"priorityStatus\", 99);\n flow.set(\"utsRelayOffWebInterface_t\",0);\n flow.set(\"utsRelayOff_t\", 0); \n\n //if (tmp.sender == \"restore\")\n //{\n // return [msg, newPayload2, null];\n //}\n //else\n //{\n // return [msg, newPayload2, msg];\n //}\n return [msg, newPayload2, msg];\n}\nif (msg.payload.Relay == \"On\" || msg.payload === true)\n{\n //let tmp = msg.payload;\n \n let newPayload = {};\n newPayload.Id = flow.get('SensorId')||\"empty\";\n newPayload.Relay = \"On\";\n msg.payload = newPayload;\n \n let newPayload2 = {};\n let state = true;\n newPayload2.payload = state;\n flow.set(\"relayStatus\", state);\n flow.set(\"priorityStatus\", msg.priority);\n //if (tmp.sender == \"restore\")\n //{\n // return [msg, newPayload2, null];\n //}\n //else\n //{\n // return [msg, newPayload2, msg];\n //}\n return [msg, newPayload2, msg];\n}\nreturn null;",
        "outputs": 3,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1320,
        "y": 1040,
        "wires": [
            [
                "05410bac050504df",
                "eaeb554273b561e7",
                "5b09bb12a8c448eb",
                "e3dcf3aea11eec8e"
            ],
            [
                "dd1ebbdaf9dff194",
                "5fae6cd639cbc41f",
                "f7cfa8c00adbd4be"
            ],
            [
                "6eaf7e2f4b604fe1",
                "6f869bcc27dfe84a",
                "c30a2b6f87d488d5",
                "eba723867387436d",
                "5605363013419970"
            ]
        ]
    },
    {
        "id": "a44c05b240f1861a",
        "type": "function",
        "z": "ba1f4b99a9e664d8",
        "name": "setTriggerPriority",
        "func": "// let flowX = flow.get('SensorId')||\"empty\";\n// if (flowX == \"empty\") return null;\n// let keyX = \"PrioritySwitchWebinterface\";\n// let conf = global.get('globalConfig');\n// let prio = conf[flowX][keyX];\n// msg.priority = prio;\n// flow.set(\"utsRelayOff_t\", 0);\n// return msg;\n\nlet flowX = flow.get('SensorId')||\"empty\";\nif (flowX == \"empty\") return null;\nlet keyX = \"PrioritySwitchWebinterface\";\nlet conf = global.get('globalConfig');\nlet prio = conf[flowX][keyX];\nmsg.priority = prio;\nlet switchOnTimeValue = (flow.get('switchOnTimeValue')|0)*1000;\nmsg.cmdsource = \"webinterface\";\nutsCurrent = parseInt(+new Date());\nflow.set(\"utsRelayOffWebInterface_t\", (utsCurrent + switchOnTimeValue));\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1330,
        "y": 1120,
        "wires": [
            [
                "ea8601088eff9004",
                "0574049117730538"
            ]
        ]
    },
    {
        "id": "5fae6cd639cbc41f",
        "type": "ui_switch",
        "z": "ba1f4b99a9e664d8",
        "name": "Schreibtisch",
        "label": "",
        "tooltip": "",
        "group": "1631802e9c3c9572",
        "order": 2,
        "width": "3",
        "height": "1",
        "passthru": false,
        "decouple": "true",
        "topic": "",
        "topicType": "str",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "animate": true,
        "className": "",
        "x": 1270,
        "y": 1180,
        "wires": [
            [
                "a44c05b240f1861a"
            ]
        ]
    },
    {
        "id": "f7cfa8c00adbd4be",
        "type": "ui-switch",
        "z": "ba1f4b99a9e664d8",
        "name": "Schreibtisch",
        "label": "Schreibtisch",
        "group": "15ecf48a1d47cdcb",
        "order": 1,
        "width": "2",
        "height": "1",
        "passthru": false,
        "decouple": false,
        "topic": "",
        "topicType": "str",
        "style": "",
        "className": "",
        "layout": "",
        "clickableArea": "switch",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "x": 1270,
        "y": 1240,
        "wires": [
            [
                "a44c05b240f1861a"
            ]
        ]
    },
    {
        "id": "e3dcf3aea11eec8e",
        "type": "function",
        "z": "ba1f4b99a9e664d8",
        "name": "convertToTasmota",
        "func": "let Id = flow.get('SensorId')||\"empty\";\nif (Id == \"empty\") return null;\nif (msg.cmdsource == \"SwitchWebInterface\") return null;\nmsg.topic = \"cmnd/SwitchTypT/\" + Id + \"/POWER\";\nmsg.payload = msg.payload.Relay;\n//flow.set(\"MttBlocktime\", ((parseInt(+new Date())) + 200));\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1630,
        "y": 940,
        "wires": [
            [
                "e82da21963e2a55c",
                "a0253998b386edf5",
                "8f9d6a30ac1f994d"
            ]
        ]
    },
    {
        "id": "e82da21963e2a55c",
        "type": "mqtt out",
        "z": "ba1f4b99a9e664d8",
        "d": true,
        "name": "mqtt",
        "topic": "",
        "qos": "0",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "f55c6c0d.194bb",
        "x": 1830,
        "y": 940,
        "wires": []
    },
    {
        "id": "a0253998b386edf5",
        "type": "debug",
        "z": "ba1f4b99a9e664d8",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 1830,
        "y": 900,
        "wires": []
    },
    {
        "id": "402fc590e681f98e",
        "type": "inject",
        "z": "ba1f4b99a9e664d8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "1",
        "topic": "ExecuteOnStart",
        "payloadType": "str",
        "x": 1610,
        "y": 220,
        "wires": [
            [
                "e362b529b3647512",
                "995279a336276078"
            ]
        ]
    },
    {
        "id": "e362b529b3647512",
        "type": "function",
        "z": "ba1f4b99a9e664d8",
        "name": "setSensorId 2C:F4:32:78:26:1C",
        "func": "// Edit here:\nflow.set('SensorId',\"2C:F4:32:78:26:1C\");\nflow.set('isDelayLoopRunning', false);\nflow.set('isDelayLoopWebinterfaceRunning', false);\nreturn null;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1650,
        "y": 260,
        "wires": [
            []
        ]
    },
    {
        "id": "995279a336276078",
        "type": "debug",
        "z": "ba1f4b99a9e664d8",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 1810,
        "y": 220,
        "wires": []
    },
    {
        "id": "15ecf48a1d47cdcb",
        "type": "ui-group",
        "name": "Schreibtisch - Steckdose",
        "page": "3f733656bce2c526",
        "width": "2",
        "height": "1",
        "order": 2,
        "showTitle": true,
        "className": "",
        "visible": "true",
        "disabled": "false",
        "groupType": "default"
    },
    {
        "id": "1631802e9c3c9572",
        "type": "ui_group",
        "name": "Schreibtisch - Steckdose",
        "tab": "6106a649e7ac3347",
        "order": 12,
        "disp": true,
        "width": "6",
        "collapse": true,
        "className": ""
    },
    {
        "id": "f55c6c0d.194bb",
        "type": "mqtt-broker",
        "name": "",
        "broker": "mosquitto",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "3",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "Abbruch",
        "willQos": "0",
        "willRetain": "true",
        "willPayload": "{\"Abbruch\":\"Abbruch\"}",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    },
    {
        "id": "3f733656bce2c526",
        "type": "ui-page",
        "name": "Schalter - Sonstige",
        "ui": "282ba4e5c6170cd2",
        "path": "/SchalterSonstige",
        "icon": "home",
        "layout": "flex",
        "theme": "97db8f45911448c5",
        "breakpoints": [
            {
                "name": "Default",
                "px": "0",
                "cols": "3"
            },
            {
                "name": "Tablet",
                "px": "576",
                "cols": "6"
            },
            {
                "name": "Small Desktop",
                "px": "768",
                "cols": "9"
            },
            {
                "name": "Desktop",
                "px": "1024",
                "cols": "12"
            }
        ],
        "order": 20,
        "className": "",
        "visible": "true",
        "disabled": "false"
    },
    {
        "id": "6106a649e7ac3347",
        "type": "ui_tab",
        "name": "Schalter - Sonstige",
        "icon": "wb_incandescent",
        "order": 2,
        "disabled": false,
        "hidden": false
    },
    {
        "id": "282ba4e5c6170cd2",
        "type": "ui-base",
        "name": "Dashboard 2.0",
        "path": "/dashboard",
        "includeClientData": true,
        "acceptsClientConfig": [
            "ui-notification",
            "ui-control"
        ],
        "showPathInSidebar": false,
        "showPageTitle": true,
        "navigationStyle": "default",
        "titleBarStyle": "default"
    },
    {
        "id": "97db8f45911448c5",
        "type": "ui-theme",
        "name": "Default Theme",
        "colors": {
            "surface": "#ffffff",
            "primary": "#0094CE",
            "bgPage": "#eeeeee",
            "groupBg": "#ffffff",
            "groupOutline": "#cccccc"
        },
        "sizes": {
            "pagePadding": "12px",
            "groupGap": "12px",
            "groupBorderRadius": "4px",
            "widgetGap": "12px"
        }
    }
]

```

It works fine the code is somehow .... let s say "grown" 😉  
you need to enable the mqtt node.

you need to setup tasmota config like this or change mqtt in flow to make it work:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/8/4810308df55c697956ad157b9249cf8b4e7a1dd5.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/4/04488dffe31873a1bafaf312c9120fc0dd64c5a3.png)

---

<div class="post-metadata">

### Author: ![OffGridNoob](https://avatars.discourse-cdn.com/v4/letter/o/41988e/32.png) [@OffGridNoob](https://discourse.nodered.org/u/OffGridNoob)
#### Post date: [20 December 2024 20:52 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/12 "2024-12-20T20:52:10Z")

</div>

Got another router setup and it's all set. Now I just need to learn about using the "http-API of the tasmota device - connect directly from a http-node from NR or install a tasmota package" to get Node Red to talk to the tasmota device.

---

<div class="post-metadata">

### Author: ![hominidae](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hominidae/32/4174_2.png) [@hominidae](https://discourse.nodered.org/u/hominidae)
#### Post date: [20 December 2024 21:12 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/13 "2024-12-20T21:12:35Z")

</div>

-\> [Controlling the Tasmota SonOff Switch with HTTP and Node-Red](https://stevessmarthomeguide.com/control-tasmota-switch-http-node-red/)

or

-\> [node-red-contrib-tasmotas (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-tasmotas)  
This package seems to support control via http or mqtt (only if you have a broker - do not "misuse" the cerbo for this, I'd recommend).

---

<div class="post-metadata">

### Author: ![OffGridNoob](https://avatars.discourse-cdn.com/v4/letter/o/41988e/32.png) [@OffGridNoob](https://discourse.nodered.org/u/OffGridNoob)
#### Post date: [20 December 2024 21:24 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/14 "2024-12-20T21:24:51Z")

</div>

That HTTP Request Node looks like it will be money. I'll give that a try. Many thanks!

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [20 December 2024 21:42 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/15 "2024-12-20T21:42:58Z")

</div>

No doubt passing messages to and from Tasmota by HTTP will work.  
Personally though, I would much prefer to use MQTT, even if I had no other broker available than [node-red-contrib-aedes](https://flows.nodered.org/node/node-red-contrib-aedes) in Node-red.

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [20 December 2024 21:46 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/16 "2024-12-20T21:46:38Z")

</div>

here is the documentation with all commands. Http request or mqtt

> **[Commands - Tasmota](https://tasmota.github.io/docs/Commands/#with-web-requests)**
>
> Documentation (Wiki) for Tasmota

Plenty of examples to.

---

<div class="post-metadata">

### Author: ![OffGridNoob](https://avatars.discourse-cdn.com/v4/letter/o/41988e/32.png) [@OffGridNoob](https://discourse.nodered.org/u/OffGridNoob)
#### Post date: [20 December 2024 23:39 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/17 "2024-12-20T23:39:49Z")

</div>

That link you shared couldn't have made it any easier. Super simple. It's now working.

Thank you all for the information and help!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [3 January 2025 23:40 UTC](https://discourse.nodered.org/t/controlling-tasmota-switch-with-node-red/93945/18 "2025-01-03T23:40:22Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
