# Help with injecting a boolean value into a payload?

**URL:** <https://discourse.nodered.org/t/help-with-injecting-a-boolean-value-into-a-payload/9223>\
**Category:** General\
**Created:** [20 March 2019 09:40 UTC](https://discourse.nodered.org/t/help-with-injecting-a-boolean-value-into-a-payload/9223 "2019-03-20T09:40:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kroissantti](https://avatars.discourse-cdn.com/v4/letter/k/ec9cab/32.png) [@Kroissantti](https://discourse.nodered.org/u/Kroissantti)\
**Post date:** [20 March 2019 09:40 UTC](https://discourse.nodered.org/t/help-with-injecting-a-boolean-value-into-a-payload/9223/1 "2019-03-20T09:40:57Z")

</div>

I am trying to inject a true or false value into my Siemens S7-300 PLC. I can only manage to send numbers trough inject node JSON for example: {"Value":[5]}. I need to toggle inputs on my PLC with a boolean value. Here is my node red flow:

`[{"id":"91d339ac.1bae68","type":"debug","z":"2a98a51b.fd07aa","name":"msg.payload","active":true,"console":"false","complete":"payload","x":684,"y":272,"wires":[]},{"id":"ef00622f.98f69","type":"inject","z":"2a98a51b.fd07aa","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"x":160,"y":275,"wires":[["1d9af56d.4c456b"]]},{"id":"1d9af56d.4c456b","type":"write","z":"2a98a51b.fd07aa","connection":"1b5001ca.703bae","topic":"write","globallist":{"items":[{"S7_Type":"DB","S7_DBnum":"1","S7_Datatype":"X","S7_Offset":"0","S7_BitOffset":"0","S7_Length":"1","S7_Name":"ON"}]},"payload":"{\"S7_Type\":\"DB\",\"S7_DBnum\":\"1\",\"S7_Datatype\":\"X\",\"S7_Offset\":\"0\",\"S7_BitOffset\":\"0\",\"S7_Length\":\"1\",\"S7_Name\":\"ON\"}","name":"write","x":405,"y":269,"wires":[["91d339ac.1bae68"]]},{"id":"1b5001ca.703bae","type":"connection","z":"2a98a51b.fd07aa","ip":"192.168.50.20","port":"102","rack":"0","slot":"0","payload":[{"S7_Type":"DB","S7_DBnum":"1","S7_Datatype":"X","S7_Offset":"0","S7_BitOffset":"0","S7_Length":"1","S7_Name":"ON"}],"globallist":null}]`

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 March 2019 09:58 UTC](https://discourse.nodered.org/t/help-with-injecting-a-boolean-value-into-a-payload/9223/2 "2019-03-20T09:58:04Z")

</div>

Please see this post for how to share flows so that they are importable. You can edit your previous post to fix it.

> [@How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506):
>
> To share code samples or flow json in this forum, you need to take care to format it properly so that it is displayed correctly. The easiest way to do that is to click the 'Preformatted Text' button in the toolbar: [image] Then paste in your code or flow json. You should end up with three back-tick characters - ``` - on their own line before and after the code. On standard US English keyboards, this is on the same key as the ~ character. Using the backticks will ens…

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 March 2019 09:59 UTC](https://discourse.nodered.org/t/help-with-injecting-a-boolean-value-into-a-payload/9223/3 "2019-03-20T09:59:23Z")

</div>

I think you may be using a contrib node, if so please tell us what it is, probably node-red-contrib-something.

---

<div class="post-metadata">

**Author:** ![Kroissantti](https://avatars.discourse-cdn.com/v4/letter/k/ec9cab/32.png) [@Kroissantti](https://discourse.nodered.org/u/Kroissantti)\
**Post date:** [20 March 2019 10:27 UTC](https://discourse.nodered.org/t/help-with-injecting-a-boolean-value-into-a-payload/9223/4 "2019-03-20T10:27:32Z")

</div>

It should be now fixed!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 March 2019 10:32 UTC](https://discourse.nodered.org/t/help-with-injecting-a-boolean-value-into-a-payload/9223/5 "2019-03-20T10:32:35Z")

</div>

Yes, ok now, but we need to know which node you are using, node-red-contrib-???

---

<div class="post-metadata">

**Author:** ![Kroissantti](https://avatars.discourse-cdn.com/v4/letter/k/ec9cab/32.png) [@Kroissantti](https://discourse.nodered.org/u/Kroissantti)\
**Post date:** [21 March 2019 06:54 UTC](https://discourse.nodered.org/t/help-with-injecting-a-boolean-value-into-a-payload/9223/6 "2019-03-21T06:54:23Z")

</div>

Sorry it's my first time using node red and I didn't know I was using such a node. I am using node-red-contrib-s7.

---

<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:** [21 March 2019 07:09 UTC](https://discourse.nodered.org/t/help-with-injecting-a-boolean-value-into-a-payload/9223/7 "2019-03-21T07:09:14Z")

</div>

> [@Kroissantti](#):
>
> I am trying to inject a true or false value into my Siemens S7-300 PLC. I can only manage to send numbers trough inject node JSON for example: {"Value":[5]}. I need to toggle inputs on my PLC with a boolean value

Hi and welcome.

I don't use the s7 nodes so I'm guessing but have you tried feeding Number 1 or 0 to your Boolean PLC tags instead of Boolean true/false?

---

<div class="post-metadata">

**Author:** ![Kroissantti](https://avatars.discourse-cdn.com/v4/letter/k/ec9cab/32.png) [@Kroissantti](https://discourse.nodered.org/u/Kroissantti)\
**Post date:** [21 March 2019 08:35 UTC](https://discourse.nodered.org/t/help-with-injecting-a-boolean-value-into-a-payload/9223/8 "2019-03-21T08:35:51Z")

</div>

Yes I tried using 1 and 0 and it didn't work.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 March 2019 08:39 UTC](https://discourse.nodered.org/t/help-with-injecting-a-boolean-value-into-a-payload/9223/9 "2019-03-21T08:39:02Z")

</div>

> [@Kroissantti](#):
>
> I am using node-red-contrib-s7.

I think you must be using another one. Your flow has a node of type `write` that does not appear to be in the S7 node. If you go to manage palette in node-red it will show you all the nodes you have installed.

---

<div class="post-metadata">

**Author:** ![Sotiris\_Sy](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@Sotiris\_Sy](https://discourse.nodered.org/u/Sotiris_Sy)\
**Post date:** [25 May 2020 23:32 UTC](https://discourse.nodered.org/t/help-with-injecting-a-boolean-value-into-a-payload/9223/10 "2020-05-25T23:32:30Z")

</div>

Hi All

I suggest using the 'button' from dashboard. It is configured to output 'true' and 'false'
