# Enabling / disabling writing data to a file using a dashboard switch node

**URL:** <https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438>\
**Category:** General\
**Tags:** node-red-dashboard, function-node\
**Created:** [19 December 2021 15:41 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438 "2021-12-19T15:41:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![nosered1966](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nosered1966/32/52859_2.png) [@nosered1966](https://discourse.nodered.org/u/nosered1966)\
**Post date:** [19 December 2021 15:41 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/1 "2021-12-19T15:41:52Z")

</div>

Dear Experts,

I have created a flow where I can store data into a file and it already works as expected.

But now I want to enable / disable the logging using a simple switch (may be by blocking the entire message?) on the dashboard and I've been looking for a solution for hours now again and now I can no longer!  
😫

Can you please help me with a few concrete hints?  
I am sure, that in the end it is really easy. But I can't figure it out ...

Here is a screenshot of my flow...

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/e/0e8e3a3c5983404069859cc137fbbcea8bcb287f.png)

Thank you!!!!

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 December 2021 15:46 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/2 "2021-12-19T15:46:24Z")

</div>

Didnt your other thread solve this?

> [@Disable flow / injection using a button on the dashboard](https://discourse.nodered.org/t/disable-flow-injection-using-a-button-on-the-dashboard/55006):
>
> Hi all, I am totally new here and I am not really familiar with software development and things like this... I have created an example with a gauge on a dashboard feed with a random number activated using a inject node firing every second. Is it possible to stop the inject node firing using a button on the dashboard? I did see some answers about similar topics in this forum but I did not understand them because they have been not detailed enough for me. Thx. Code: [{"id":"9aace…

---

<div class="post-metadata">

**Author:** ![nosered1966](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nosered1966/32/52859_2.png) [@nosered1966](https://discourse.nodered.org/u/nosered1966)\
**Post date:** [19 December 2021 15:49 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/3 "2021-12-19T15:49:36Z")

</div>

No! Or do you see a 'switch' and a 'write file' node on this screenshot?

I do not want to disable the flow or the injection, I want to disable the logging only...

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 December 2021 15:53 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/4 "2021-12-19T15:53:07Z")

</div>

> [@nosered1966](#):
>
> do you see a 'switch' and a 'write file' node on this screenshot

No, but that is completely irrelevant.

For example several of the solutions offered in that thread show you how to block the flow of a msg.

So using the same process, you can block these `log` messages reaching the file node!

* * *

If you cant see that then post your flow and I'll show you.

---

<div class="post-metadata">

**Author:** ![nosered1966](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nosered1966/32/52859_2.png) [@nosered1966](https://discourse.nodered.org/u/nosered1966)\
**Post date:** [19 December 2021 16:00 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/5 "2021-12-19T16:00:16Z")

</div>

Hi Stephen,  
first thank you very much for your quick response!  
I think I understand what you mean. In German you say "Viele Wege führen nach Rom!"...  
But currently I can not see it.

But I will check this again and come back

- with a solution or
- a new question or
- with a copy of my code or
- I don't know...

But it will take some time.  
Playing around with Node Red is (unfortunately?) not my main activity...

😉

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 December 2021 16:04 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/6 "2021-12-19T16:04:52Z")

</div>

> [@nosered1966](#):
>
> Viele Wege führen nach Rom

We in UK also use "Many roads lead to Rome"

NOTE: I recommend the 2nd option in this thread: [Cancel inputs for a period of time - #6 by Steve-Mcl](https://discourse.nodered.org/t/cancel-inputs-for-a-period-of-time/43749/6) - because I can help you with it & it doesnt use contrib nodes.

If you were to use that ↑ demo then you would place the `gate` in series between the `function` and `file` node to block / allow the flow of messages. And instead of injects to control the `gate`, use your dashboard switch to send the necessary values to "flip" the gate open / closed.

---

<div class="post-metadata">

**Author:** ![nosered1966](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nosered1966/32/52859_2.png) [@nosered1966](https://discourse.nodered.org/u/nosered1966)\
**Post date:** [19 December 2021 19:23 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/7 "2021-12-19T19:23:47Z")

</div>

I tried... no success!

Your code in `gate` is using `msg.topic == "_block_toggle"`.  
But in dashboard switch I do not have a `msg.topic`.  
?

![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a63a886841517b6bc49dff04dd91dac9a990e1d3.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 December 2021 19:39 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/8 "2021-12-19T19:39:42Z")

</div>

You can change the comparison to anything that suits you.

---

<div class="post-metadata">

**Author:** ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)\
**Post date:** [19 December 2021 20:24 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/9 "2021-12-19T20:24:14Z")

</div>

I do not see the problem. Set a flow variable with the dashboard switch node. Then put a switch node as filter before the write file node. Where is the problem??

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

```auto
[{"id":"6f9ecff51b3542f4","type":"ui_switch","z":"88a88855e07a9bcf","name":"","label":"switch","tooltip":"","group":"8439522ea5fad93c","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"x":930,"y":180,"wires":[["8868a7d0e6140a88"]]},{"id":"8868a7d0e6140a88","type":"change","z":"88a88855e07a9bcf","name":"","rules":[{"t":"set","p":"logging","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":180,"wires":[[]]},{"id":"51139ba4f58d1264","type":"switch","z":"88a88855e07a9bcf","name":"allow logging","property":"logging","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":910,"y":300,"wires":[["2388402aadeea722"]]},{"id":"2388402aadeea722","type":"file","z":"88a88855e07a9bcf","name":"","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":1090,"y":300,"wires":[[]]},{"id":"da8487fee9b7db7c","type":"function","z":"88a88855e07a9bcf","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":300,"wires":[["51139ba4f58d1264"]]},{"id":"8439522ea5fad93c","type":"ui_group","name":"Test","tab":"49e9f4d45b15375e","order":1,"disp":true,"width":"6","collapse":false},{"id":"49e9f4d45b15375e","type":"ui_tab","name":"Test","icon":"dashboard","order":5,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![nosered1966](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nosered1966/32/52859_2.png) [@nosered1966](https://discourse.nodered.org/u/nosered1966)\
**Post date:** [19 December 2021 20:32 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/10 "2021-12-19T20:32:23Z")

</div>

@mickym2 : The main problem with all forums is:

- If you are somehow an "expert" then your comment / description might be helpful
- If you are an absolute beginner it can happen that the comment / description is simply not understood

But I am already on a good way using the solution from @Steve-Mcl .  
Still struggling to implement the correct initial state: "writing disabled"...

But your solution sounds easier.... I will have a look on it...  
Dankeschön!

---

<div class="post-metadata">

**Author:** ![nosered1966](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nosered1966/32/52859_2.png) [@nosered1966](https://discourse.nodered.org/u/nosered1966)\
**Post date:** [19 December 2021 20:54 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/11 "2021-12-19T20:54:07Z")

</div>

@Steve-Mcl

As you can see in the screenshot I have now somehow manged the issue by using your solution.  
But the logic is still wrong (unblocked when "logging is switched off" and blocked when "logging is switched on"). And I can't figure out how to change it.

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/7/a7d05776836c29551c949f36a336c80aa361c851.png)  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/c/ecabeb8f2866231d307e85ded63d2a3fd25e8b64.png)

Here is the code:

```auto
[{"id":"f8a5b7e1c332a045","type":"tab","label":"Spielwiese","disabled":false,"info":"","env":[]},{"id":"68cf734df0af2b1b","type":"inject","z":"f8a5b7e1c332a045","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"0.5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":230,"y":200,"wires":[["2b5a4837b7a3778a"]]},{"id":"e9af5b33d982125b","type":"debug","z":"f8a5b7e1c332a045","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":610,"y":160,"wires":[]},{"id":"2b5a4837b7a3778a","type":"function","z":"f8a5b7e1c332a045","name":"gate","func":"var block = context.get(\"block\") || false;\n\n//if (msg.topic == \"_block_toggle\") {\nif (msg.payload == true) {\n\n block = !block;\n context.set(\"block\", block);\n var stat = {\n fill: block ? \"red\" : \"green\",\n shape: block ? \"dot\": \"ring\",\n text: block ? \"Blocked\" : \"Unblocked\"\n }\n node.status(stat)\n}\n\nif(block) return null; //halt flow\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":160,"wires":[["e9af5b33d982125b"]]},{"id":"dc568e29ed2459b2","type":"ui_switch","z":"f8a5b7e1c332a045","name":"Switch Logging","label":"<font color=#FFFFFF size=\"4\"><strong>Logging</strong></font>","tooltip":"","group":"d15916e202a9929f","order":8,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":220,"y":140,"wires":[["2b5a4837b7a3778a"]]},{"id":"d15916e202a9929f","type":"ui_group","name":"Spielwiese","tab":"f045990709d4a630","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"f045990709d4a630","type":"ui_tab","name":"Spielwiese","icon":"dashboard","order":9,"disabled":false,"hidden":false}]

```

I will now try to test the solution from the Bavarian expert @mickym2 . Perhaps his code is in German  
🙂

---

<div class="post-metadata">

**Author:** ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)\
**Post date:** [19 December 2021 21:04 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/12 "2021-12-19T21:04:49Z")

</div>

> [@nosered1966](#):
>
> Perhaps his code is in German

You may be disappointed. 😉 - The function node is only dummy to demonstrate where the switch node has to be placed. So my function node is a dummy and should be replaced with your function node.

The logic is still simple:  
With the switch - I set a flow variable logging to true or false - dependend on the switch.  
The switch node in front of your file node blocks all messages if the flow variable logging isn't true. 😉

If you need to initialize your flow variable to a specific value then use an inject node which act as input as well and sends only one message after node-red is started. In this case you can use pass through of the dashboard switch.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/b/5b599d69a310b1bcdcdd1b57d36b88706b52c6f0.png)

```auto
[{"id":"b4c0206a2b9d36ce","type":"ui_switch","z":"c451086a0228abe0","name":"","label":"switch","tooltip":"","group":"8439522ea5fad93c","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"x":630,"y":180,"wires":[["7bf1ce8f689ece25"]]},{"id":"7bf1ce8f689ece25","type":"change","z":"c451086a0228abe0","name":"","rules":[{"t":"set","p":"logging","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":180,"wires":[[]]},{"id":"99bd263a70cdef9d","type":"switch","z":"c451086a0228abe0","name":"allow logging","property":"logging","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":610,"y":300,"wires":[["268359bb89df44fe"]]},{"id":"109c875874c35d74","type":"file","z":"c451086a0228abe0","name":"","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":790,"y":300,"wires":[[]]},{"id":"a8b46906379c4b31","type":"inject","z":"c451086a0228abe0","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":420,"y":320,"wires":[["99bd263a70cdef9d"]]},{"id":"268359bb89df44fe","type":"debug","z":"c451086a0228abe0","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":800,"y":360,"wires":[]},{"id":"d29dcbc8a62e4387","type":"inject","z":"c451086a0228abe0","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":490,"y":180,"wires":[["b4c0206a2b9d36ce"]]},{"id":"8439522ea5fad93c","type":"ui_group","name":"Test","tab":"49e9f4d45b15375e","order":1,"disp":true,"width":"6","collapse":false},{"id":"49e9f4d45b15375e","type":"ui_tab","name":"Test","icon":"dashboard","order":5,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 December 2021 21:08 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/13 "2021-12-19T21:08:17Z")

</div>

The difference beetween my solution and @mickym2 is that mine is portable (can be re-used) & has visual feedback (i.e. status in the editor). Like in mickym2s solution, when using a flow variable, if you want a 2nd or 3rd gate, you need to change all the flow variable names - however it is simpler to understand..

Anyhow, i imagine this is what you want...

![EGh8KclFWS](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/f/af679577251709bd9c715d3cfa6e55c04ccde2c0.gif)

![H1ZALstvFB](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/6/4692ed5539534236036f4a0bfdd0478de14e36d4.gif)

flow...

```auto
[
    {
        "id": "68cf734df0af2b1b",
        "type": "inject",
        "z": "f8a5b7e1c332a045",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "0.5",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payloadType": "date",
        "x": 278,
        "y": 192,
        "wires": [
            [
                "2b5a4837b7a3778a"
            ]
        ]
    },
    {
        "id": "e9af5b33d982125b",
        "type": "debug",
        "z": "f8a5b7e1c332a045",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 630,
        "y": 192,
        "wires": []
    },
    {
        "id": "2b5a4837b7a3778a",
        "type": "function",
        "z": "f8a5b7e1c332a045",
        "name": "gate",
        "func": "var block = context.get(\"block\") || false;\n\n//if (msg.topic == \"_block_toggle\") {\nif (msg.topic == \"block\") {\n block = !!msg.payload;\n context.set(\"block\", block);\n var stat = {\n fill: block ? \"red\" : \"green\",\n shape: block ? \"dot\": \"ring\",\n text: block ? \"Blocked\" : \"Unblocked\"\n }\n node.status(stat)\n return null; //halt flow\n}\n\nif(block) return null; //halt flow\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 450,
        "y": 192,
        "wires": [
            [
                "e9af5b33d982125b",
                "8ce9b9d926ad212d"
            ]
        ]
    },
    {
        "id": "dc568e29ed2459b2",
        "type": "ui_switch",
        "z": "f8a5b7e1c332a045",
        "name": "Add to log",
        "label": "<font color=\"#000\" size=\"4\"><strong>Add to log</strong></font>",
        "tooltip": "",
        "group": "d15916e202a9929f",
        "order": 8,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "block",
        "topicType": "str",
        "style": "",
        "onvalue": "false",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "true",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "animate": false,
        "className": "",
        "x": 252,
        "y": 288,
        "wires": [
            [
                "2b5a4837b7a3778a"
            ]
        ]
    },
    {
        "id": "8ce9b9d926ad212d",
        "type": "ui_text",
        "z": "f8a5b7e1c332a045",
        "group": "d15916e202a9929f",
        "order": 1,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "text",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 610,
        "y": 128,
        "wires": []
    },
    {
        "id": "d15916e202a9929f",
        "type": "ui_group",
        "name": "Spielwiese",
        "tab": "f045990709d4a630",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "f045990709d4a630",
        "type": "ui_tab",
        "name": "Spielwiese",
        "icon": "dashboard",
        "order": 9,
        "disabled": false,
        "hidden": false
    }
]

```

---

<div class="post-metadata">

**Author:** ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)\
**Post date:** [19 December 2021 21:16 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/14 "2021-12-19T21:16:08Z")

</div>

My visual feedback - is the context menu - just a joke. 😉

---

<div class="post-metadata">

**Author:** ![nosered1966](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nosered1966/32/52859_2.png) [@nosered1966](https://discourse.nodered.org/u/nosered1966)\
**Post date:** [19 December 2021 21:16 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/15 "2021-12-19T21:16:19Z")

</div>

Es ist zum ... ich krieg's nicht hin.  
Deine Lösung sieht so einfach aus, aber das Loggen wird nicht gestopp:

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/d/8d688c6770918482635cfc673e2daa54b92d0fe0.png)

Was mache ich falsch?

---

<div class="post-metadata">

**Author:** ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)\
**Post date:** [19 December 2021 21:17 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/16 "2021-12-19T21:17:53Z")

</div>

Zeig mal Dein Kontext Menü -

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/2/12571c105da2367a22892a512c4e0af97a4bd854.png)

---

<div class="post-metadata">

**Author:** ![nosered1966](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nosered1966/32/52859_2.png) [@nosered1966](https://discourse.nodered.org/u/nosered1966)\
**Post date:** [19 December 2021 21:19 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/17 "2021-12-19T21:19:17Z")

</div>

Ja das ist leer... da muss wohl noch was rein. Oder? Keine Ahnung leider...

---

<div class="post-metadata">

**Author:** ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)\
**Post date:** [19 December 2021 21:20 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/18 "2021-12-19T21:20:09Z")

</div>

Na dann hast Du nicht initialisiert oder den switch noch nicht betätigt. Nutz den Flow zum Schluss da initialisiere ich den switch mit einer inject Node. Und es ist solange leer - Du musst refreshen:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/7/c7ebd10d3e8f7d5653737701d8ae184708233150.png)

---

<div class="post-metadata">

**Author:** ![nosered1966](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nosered1966/32/52859_2.png) [@nosered1966](https://discourse.nodered.org/u/nosered1966)\
**Post date:** [19 December 2021 21:22 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/19 "2021-12-19T21:22:03Z")

</div>

OK, I will try ......

---

<div class="post-metadata">

**Author:** ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)\
**Post date:** [19 December 2021 21:29 UTC](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438/20 "2021-12-19T21:29:18Z")

</div>

The switch node - is very simple - just looking if flow variable logging is true. If this is not the you must initialize the flow variable with the dashboard switch or Inject Node - and it used boolean true for on and boolean false for off.

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/7/97f439f97899528be40cc892e4fe23a67ae63e12.png)

The flow varibale is set by the next change node:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/4/546eab8d65c71491f22c16a63b206de090f2b631.png)

[Next page](https://discourse.nodered.org/t/enabling-disabling-writing-data-to-a-file-using-a-dashboard-switch-node/55438.md?page=2)
