# DS2408 from owfs to 8 dashboard output for status

**URL:** <https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065>\
**Category:** General\
**Created:** [22 January 2022 21:09 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065 "2022-01-22T21:09:54Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [22 January 2022 21:09 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/1 "2022-01-22T21:09:54Z")

</div>

Hello  
Please help me, because I don't know how to create a solution in the most system-friendly way.  
I am reading a DS2408 from an OWFS server. This returns between 0 and 255 as a decimal number.  
I convert this as into a binary number.  
The result is 10011010 as an example.  
I would like to create something like this  
the first binary number 1  
Heating pump=true  
the second binary number 0  
Solar pump= false  
the third binary number 0  
Fireplace=false  
the fourth binary number 1  
Floor pump=true  
.  
.  
.  
the eighth binary number 0  
Circulation=false.

the whole thing should be displayed in the dashboard and I would like to trigger further actions, for example when the fireplace is generating heat, so that my burner control of the heating system is then set to night reduction. I know how to do this, I just have to set the status of the fireplace as global flow.  
I don't know how to break down the bimary number to generate 8 outputs for the dahbord. I am grateful for any suggestions

---

<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:** [22 January 2022 21:30 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/2 "2022-01-22T21:30:46Z")

</div>

> [@edstobi](#):
>
> This returns between 0 and 255 as a decimal number.  
> I convert this as into a binary number.

I don't understand what you mean by that. All numbers in javascript are stored the same, as floats. So what exactly have you converted it into? Feed it into a debug node and show us what it says.

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [22 January 2022 21:37 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/3 "2022-01-22T21:37:49Z")

</div>

You need to use binary AND to mask the bits, for example if you binary AND your result with 128 you will get the leftmost bit (heating pump), 64 = solar pump and so on.

---

<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:** [22 January 2022 21:40 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/4 "2022-01-22T21:40:06Z")

</div>

I recommend to use the buffer node

---

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [22 January 2022 21:40 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/5 "2022-01-22T21:40:52Z")

</div>

interesting, I haven't thought about that yet, so it's similar to the network mask.  
I have tried with split and switch.

---

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [22 January 2022 21:46 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/6 "2022-01-22T21:46:21Z")

</div>

#Colin:  
I get a decimal number from DS2408 of the status from the potential applied to the pins. If I convert this to binary, this is the status of the eight inputs, that show me the states of my pumps.

---

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [22 January 2022 21:50 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/7 "2022-01-22T21:50:55Z")

</div>

buffer node? I have not heard of. Is this a separate node? will ask google

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [22 January 2022 21:51 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/8 "2022-01-22T21:51:53Z")

</div>

> **[node-red-contrib-buffer-parser](https://flows.nodered.org/node/node-red-contrib-buffer-parser)**
>
> Node-red nodes to convert values to and from buffer/array. Supports Big/Little Endian, BCD, byte swapping and much more

---

<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:** [22 January 2022 21:54 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/9 "2022-01-22T21:54:37Z")

</div>

Feed it into a debug node and show us please.

---

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [22 January 2022 22:01 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/10 "2022-01-22T22:01:12Z")

</div>

reading from device:  
msg.payload : Object  
object  
Devices-Detail-Response: object  
$: object  
xmlns: "[http://www.embeddeddatasystems.com/schema/owserver](http://www.embeddeddatasystems.com/schema/owserver)"  
xmlns:xsi: "[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)"  
PollCount: array[1]  
0: "8185"  
DevicesConnected: array[1]  
0: "12"  
LoopTime: array[1]  
0: "0.360"  
DataErrors: array[1]  
0: "0"  
owd\_DS18S20: array[11]  
[0 … 9]  
0: object  
1: object  
2: object  
3: object  
4: object  
5: object  
6: object  
7: object  
8: object  
9: object  
[10 … 10]  
owd\_DS2408: array[1]  
0: object  
$: object  
Name: array[1]  
Family: array[1]  
ROMId: array[1]  
Health: array[1]  
RawData: array[1]  
PrimaryValue: array[1]  
**0: "207"**  
PIOLogicState: array[1]  
PIOOutputLatchState: array[1]  
PIOActivityLatchState: array[1]  
RSTZconfiguration: array[1]  
PowerOnResetLatch: array[1]

converting PrimaryValue 207 to:  
msg.payload : string[8]  
"11001111"

my 8 inputsof the DS2408 device

---

<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:** [22 January 2022 22:07 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/11 "2022-01-22T22:07:52Z")

</div>

> [@edstobi](#):
>
> msg.payload : string[8]  
> "11001111"

OK, so you haven't converted it to a value in a Buffer, as @ghayne assumed, but as characters "1" and "0" in a string. You might be better just to build the js object instead of building the string.

---

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [22 January 2022 22:13 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/12 "2022-01-22T22:13:52Z")

</div>

Can yo help me to change my function to generate an object?

```auto
let num = msg.payload.FA0000000C56E529.Value;
    let binary = (num % 2).toString();
    for (; num > 1; ) {
        num = parseInt(num / 2);
        binary = (num % 2) + (binary);
    }
    msg.payload= binary;

return msg;

```

---

<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:** [22 January 2022 22:31 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/13 "2022-01-22T22:31:52Z")

</div>

So if I take your example:

> [@edstobi](#):
>
> The result is 10011010 as an example.  
> I would like to create something like this  
> the first binary number 1  
> Heating pump=true  
> the second binary number 0  
> Solar pump= false  
> the third binary number 0  
> Fireplace=false  
> the fourth binary number 1  
> Floor pump=true

The result 1001 1010 is decimal 157.

So with the buffe nodes you can convert the number in a buffer - and then it will be analysed.

So the first buffer node converts number in a buffer:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/8/186ff69ca60f6224091a48097de22b21d6e0f759.png)

so

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/8/e823355a4c10a8f590704c11e97b88c2923e9b66.png)

buffer is 0x9d

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

The buffer node can parse the byte bitwise and convert it to a boolean and directly assign a key to it.

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

The result is a payload with the specified keys:

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

You can also create directly the buffer within a function node:

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

The topic contains the decimal number of the inject Node and is marked in green. So you can directly see the outcome of decimal 157 (1001 1101) and 207 (1100 1111).

```auto
const buf= new Buffer(1);
buf.writeUInt8(msg.payload, 0);
msg.payload = buf;
return msg;

```

```auto
[{"id":"3a160476169a5f53","type":"inject","z":"61c5ee22.b88f1","name":"","props":[{"p":"payload"},{"p":"topic","v":"payload","vt":"msg"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"157","payloadType":"num","x":530,"y":3400,"wires":[["8e56b87c0b808d68"]]},{"id":"8e56b87c0b808d68","type":"function","z":"61c5ee22.b88f1","name":"","func":"const buf= new Buffer(1);\nbuf.writeUInt8(msg.payload, 0);\nmsg.payload = buf;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":3420,"wires":[["2653be59f0069fc4"]]},{"id":"2653be59f0069fc4","type":"buffer-parser","z":"61c5ee22.b88f1","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"bool","name":"Heating Pump","offset":0,"length":1,"offsetbit":7,"scale":"1","mask":""},{"type":"bool","name":"Solar pump","offset":0,"length":1,"offsetbit":6,"scale":"1","mask":""},{"type":"bool","name":"Fireplace","offset":0,"length":1,"offsetbit":5,"scale":"1","mask":""},{"type":"bool","name":"Floor pump","offset":0,"length":1,"offsetbit":4,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":850,"y":3420,"wires":[["89478baccc51bfde"]]},{"id":"89478baccc51bfde","type":"debug","z":"61c5ee22.b88f1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1030,"y":3420,"wires":[]},{"id":"576557b0aaf107d3","type":"inject","z":"61c5ee22.b88f1","name":"","props":[{"p":"payload"},{"p":"topic","v":"payload","vt":"msg"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"207","payloadType":"num","x":530,"y":3440,"wires":[["8e56b87c0b808d68"]]}]

```

---

<div class="post-metadata">

**Author:** ![edstobi](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@edstobi](https://discourse.nodered.org/u/edstobi)\
**Post date:** [23 January 2022 11:55 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/14 "2022-01-23T11:55:52Z")

</div>

WAU  
first of all thank you for this mickm2  
It works wonderfully and with the buffer function I will have to read the documentation a little more in detail, as I haven't really understood it yet, but I see some opportunities here where I have probably built completely overblown flows in the past.

---

<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:** [6 February 2022 11:56 UTC](https://discourse.nodered.org/t/ds2408-from-owfs-to-8-dashboard-output-for-status/57065/15 "2022-02-06T11:56:43Z")

</div>

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