KNX Water Leakage Sensor: Convert Alternating 0|1 to Alarm Flag

Hi there,

I have a KNX water leakage sensor that sends nothing to the group address when there is no water detected. When there's a leakage it begins sending alternating zeroes and ones to the group address.

In Node-RED I want to convert this to a simple flag that indicates if there's an alarm (1) or not (0). Being new to Node-RED I have no clue how to approach this.

Any ideas?

cheers,
Mathias

ok we need a bit more what KNX node are you using> Ultimate?
can you copy your flow and paste into this thread pls flow these instructions.

There is no flow, yet, since that's what I am trying to figure out. I use KNX Ultimate and created a "KNX Device" node with the respective group address in KNX. When I connect a debug node, there is nothing. The devices does not emit any messages. When I spill water on the sensor, the messages keep coming with payloads alternating 0 and 1:

So, when there's
no alarm: ... nothing, no message
an alarm: 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, and so on

I think the idea of the device is to connect an light that will flash when there's a water leak, but I'd prefer to get message on the phone somehow :smiley:

You could use a Trigger node set to send the alarm message every time there is a message in. Set the timeout to greater than the longest time between the 0/1 messages and then to send the alarm off message. Follow that with a Filter node to suppress the repeated alarms, so you will get an alarm on when the first transition occurs and then an alarm off when the input stream stops.

This is the msg from a Gira PS3 button to turn lights on

{"topic":"10/1/3","payload":true,"devicename":"local bus","payloadmeasureunit":"unknown","payloadsubtypevalue":"On","knx":{"event":"GroupValue_Write","dpt":"1.001","dptdesc":"Switch","source":"1.1.1","destination":"10/1/3","rawValue":[1]},"_msgid":"56649462.bbe86c"}

image

I am confused, what has that got to do with determining whether there is an alarm state or not?

It is an example of a working KNX device that uses the same Data type the Mathias should see with his device.

@mathias-ewald are you monitoring via ETS group monitor to see 0/1 values ?

Oh, sorry, I thought that message had come from the OP.

In terms of detecting the alarm it doesn't matter what is in the message if using the Trigger node technique that I suggested. It is just a matter of distinguishing between a stream of messages and no messages.

Good morning :slight_smile: I think my KNX node works fine. I double checked the data I am seeing: It is actually true/false (not 0/1) that I am getting in Node-RED.

I tried the approach with the Trigger, but the result doesn't seem to be right. I used an Inject node at a 1s interval and a Function node to generate the true/false sequence for testing since I don't want to have to spill water behind my washing machine every time to test the flow :smiley: I might have configured the Trigger node wrong but I still get alternating true/false from it just with a delay:

[
    {
        "id": "9da7dd49afa1d6a5",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "dd3b7f2116359ec3",
        "type": "inject",
        "z": "9da7dd49afa1d6a5",
        "name": "Clock",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payloadType": "date",
        "x": 210,
        "y": 280,
        "wires": [
            [
                "b921967f8d5c1620"
            ]
        ]
    },
    {
        "id": "b921967f8d5c1620",
        "type": "function",
        "z": "9da7dd49afa1d6a5",
        "name": "True/False",
        "func": "msg.payload = context.get(\"alternate\") || false;\nmsg.payload =  (msg.payload === false) ? true : false;\ncontext.set(\"alternate\", msg.payload);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 350,
        "y": 280,
        "wires": [
            [
                "14f68eda2ef8d1d6"
            ]
        ]
    },
    {
        "id": "c3f1d5fed9ba2bc8",
        "type": "debug",
        "z": "9da7dd49afa1d6a5",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 770,
        "y": 280,
        "wires": []
    },
    {
        "id": "14f68eda2ef8d1d6",
        "type": "trigger",
        "z": "9da7dd49afa1d6a5",
        "name": "",
        "op1": "true",
        "op2": "false",
        "op1type": "bool",
        "op2type": "bool",
        "duration": "5",
        "extend": false,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 620,
        "y": 280,
        "wires": [
            [
                "c3f1d5fed9ba2bc8"
            ]
        ]
    }
]
1 Like

Sorry, I should have said to set 'Extend delay if new message arrives'. That stops it sending the false message until no input is received for 5 seconds.

1 Like

Nice. I read that option but didn't understand its purpose. Works now, thanks!

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