Page 2 of 2

Re: Water level river Waal

Posted: Saturday 30 December 2023 10:05
by FireWizard
I will take a look at it and hopefully come up with a solution, either today or tomorrow.

Regards

Re: Water level river Waal

Posted: Saturday 30 December 2023 19:55
by FireWizard
Hello @Jan Jansen,

I have just a question.
What kind of data do you want to send to Domoticz.

1.The latest available actual water height.
This lags approx 20 minutes behind the actual time.

OR

2. The predicted water height for the current time

Let me know

Regards

Re: Water level river Waal

Posted: Saturday 30 December 2023 22:47
by Jan Jansen
Hello@Firewizard,

I prefer option 1

Regards,

Jan

Re: Water level river Waal

Posted: Sunday 31 December 2023 13:52
by Kedi
Just a simple dzVents script to get the waterheight of Nijmegen-haven into a General/Distance sensor

Code: Select all

local WHDev = 'Waterhoogte Nijmegen'              -- Create a General/Distance sensor to be used.
local scriptName = 'waterhoogteNijmegen'

local function split (str, pat)
    local t = {}  -- NOTE: use {n = 0} in Lua-5.0
    local fpat = "(.-)" .. pat
    local last_end = 1
    local s, e, cap = str:find(fpat, 1)
    while s do
        if s ~= 1 or cap ~= "" then
            table.insert(t,cap)
        end
        last_end = e+1
        s, e, cap = str:find(fpat, last_end)
    end
    if last_end <= #str then
        cap = str:sub(last_end)
        table.insert(t, cap)
    end
    return t
end

return {
        active = true,
--      active = false,

        on = {
                timer = {
                        'every 10 minutes',             -- there is no need to go below 10 mintes.
                },
                httpResponses = {
                        scriptName
                }
        },
        logging = {
                level = domoticz.LOG_INFO,
--              level = domoticz.LOG_DEBUG,
                marker= 'WHN'
        },

        execute = function(dz, item)

                if item.isTimer then
                        dz.openURL({
                              url = 'https://waterinfo.rws.nl/api/chart/Get?mapType=waterhoogte&locationCode=Nijmegen-haven%28NIJM%29&values=-6,3',
                                method = 'GET',
                                callback = scriptName,
                        })
                end

                if (item.isHTTPResponse) then
                        if (item.ok) then
                                -- For DEBUG purpose, can be deleted
                                local csvHandle
                                csvHandle = assert(io.open('/tmp/'..scriptName..'.csv', "w"))
                                csvHandle:write(item.data)
                                csvHandle:close()
                                -- For DEBUG purpose

                                local waterHeight, WHTmp
                                local i, k, t = {}
                                t = split(item.data, "\n")

                                for i = 1, #t do
                                        k = t[i]
                                        WHTmp = split(k, ';')[4]
                                        if WHTmp == nil or WHTmp == '' then
                                                break
                                        end
                                        waterHeight = split(k, ';')[4]
                                end
                                dz.log(WHDev..': '..tostring(waterHeight), dz.LOG_INFO)
                                dz.devices(WHDev).updateDistance(tonumber(waterHeight))
                        else
                                dz.log('There was a problem handling the request', dz.LOG_ERROR)
                                dz.log(item, dz.LOG_ERROR)
                        end

                end

        end
}
B.t.w. The output has some small errors (peaks) because of inconsistent output from Rijkswaterstaat. Looking for a solution.

Solved. My error.

Re: Water level river Waal

Posted: Monday 01 January 2024 13:17
by Jan Jansen
@Kedi,

Thanks for your attention, nice script!

Re: Water level river Waal

Posted: Monday 01 January 2024 18:56
by FireWizard
Hello @Jan Jansen,

Happy New Year to everybody.

As promised, I publish a new solution.
My apologies, that it has been delayed a little, but testing took some time as well.

I created a new flow:

Screenshot_Waterheight-flow.png
Screenshot_Waterheight-flow.png (19.89 KiB) Viewed 3177 times
In this case, it is made for Nijmegen Haven, but it is suitable for all measuring point in The Netherlands.

As I prefer to have the configuration parameters not included in the flow, all configuration is set in the "Inject" node.

You have to insert the correct location,which you can find at: https://waterinfo.rws.nl/#/publiek/waterhoogte

To find the correct measuring point, take the following steps:
1. Click on the desired location.
2. Click on "Meer details" (More details).
3.Check the URL (e.g. https://waterinfo.rws.nl/#/publiek/wate ... 0in___20cm, where Lobith(LOBI) is the correct name of the measuring point).

Also the Domoticz idx of the virtual "Alert" sensor should be set in the "Insert" node.

If everything is correctly configured, you will get the following for Nijmegen Haven:

Screenshot_Waterheight-Nijmegen-haven.png
Screenshot_Waterheight-Nijmegen-haven.png (60.96 KiB) Viewed 3177 times
or for Lobith:

Screenshot_Waterheight-Lobith.png
Screenshot_Waterheight-Lobith.png (59.42 KiB) Viewed 3177 times

You have to replace to MQTT Output node (Naar Domoticz) for your own MQTT and Config node.

As @Kedi has also created a nice and compact dZVents script. you can choose, which solution you prefer.

Please test the flow below.

Code: Select all

[
    {
        "id": "47db295ed5bd870e",
        "type": "http request",
        "z": "f1324d44.f6688",
        "name": "Waterstand Nijmegen Haven",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "body",
        "url": "https://waterinfo.rws.nl/api/chart/Get?mapType=waterhoogte&locationCode={{{location}}}&values=-6,3",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 420,
        "y": 400,
        "wires": [
            [
                "76acdca27168cb32"
            ]
        ]
    },
    {
        "id": "a970ebacb7a9b8e7",
        "type": "inject",
        "z": "f1324d44.f6688",
        "name": "10 minutes Inject",
        "props": [
            {
                "p": "location",
                "v": "Nijmegen-haven(NIJM)",
                "vt": "str"
            },
            {
                "p": "idx",
                "v": "30",
                "vt": "num"
            }
        ],
        "repeat": "600",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "x": 150,
        "y": 400,
        "wires": [
            [
                "47db295ed5bd870e"
            ]
        ]
    },
    {
        "id": "76acdca27168cb32",
        "type": "csv",
        "z": "f1324d44.f6688",
        "name": "CSV",
        "sep": ";",
        "hdrin": true,
        "hdrout": "none",
        "multi": "mult",
        "ret": "\\n",
        "temp": "semicolon seperated values",
        "skip": "0",
        "strings": false,
        "include_empty_strings": false,
        "include_null_values": false,
        "x": 650,
        "y": 400,
        "wires": [
            [
                "3eb0f740b4a226f7"
            ]
        ]
    },
    {
        "id": "3eb0f740b4a226f7",
        "type": "function",
        "z": "f1324d44.f6688",
        "name": "Function",
        "func": "let location;\nlet actual;\nlet estimated;\nlet time;\nlet level;\n\nfor (i = 0; i < msg.payload.length; i++) {\n    if (typeof (msg.payload[i][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"]) === 'undefined') {\n        actual = msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"];\n        estimated = msg.payload[i-1][\"Waterhoogte verwacht Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"];\n        time  = msg.payload[i-1].Datum + \" \" + msg.payload[i-1][\"Tijd (NL tijd)\"];\n        location = msg.payload[i-1].Locatie;\n\nswitch (true) {\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] > 1220):\n    level = 4\n    break;\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] > 1055):\n    level = 3\n    break;\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] > 965):\n    level = 2\n    break;\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] > 535):\n    level = 1\n    break;\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] < 535):\n    level = 0;\n    break;\n\n    }\n    \n    msg.payload = { \"command\" : \"udevice\", idx : msg.idx, \"nvalue\": level, \"svalue\": \"Location: \" + location + \"; Date/Time: \" + time + \"\\n\" + \"Actual: \" + actual + \" cm\" + \"; Estimated: \" + estimated + \" cm\"};\n\n    return msg;\n    }\n}",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 820,
        "y": 400,
        "wires": [
            [
                "e62499116c78e3a7",
                "6b2b322a97983848"
            ]
        ]
    },
    {
        "id": "e62499116c78e3a7",
        "type": "debug",
        "z": "f1324d44.f6688",
        "name": "debug 230",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1030,
        "y": 460,
        "wires": []
    },
    {
        "id": "6b2b322a97983848",
        "type": "mqtt out",
        "z": "f1324d44.f6688",
        "name": "Naar Domoticz",
        "topic": "domoticz/in",
        "qos": "0",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "108bbff65a6cdbf3",
        "x": 1040,
        "y": 400,
        "wires": []
    },
    {
        "id": "108bbff65a6cdbf3",
        "type": "mqtt-broker",
        "name": "",
        "broker": "192.168.10.51",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]
Best regards

Re: Water level river Waal

Posted: Monday 01 January 2024 20:40
by EdwinK
Maybe this is more Node-red 101 related but when using this flow it just gives me one update and then nothing. Last update was over an hour ago.

The only thing changed were the id and the city/

Re: Water level river Waal

Posted: Monday 01 January 2024 20:49
by FireWizard
Hello @EdwinK,

Can you check the "Inject" node. It should send a message every 10 minutes.

Which measuring station do you use? Nijmegen haven?

I do not see that issue.

Regards

Re: Water level river Waal

Posted: Tuesday 02 January 2024 8:03
by EdwinK
FireWizard wrote: Monday 01 January 2024 20:49 Which measuring station do you use? Nijmegen haven?

I do not see that issue.

Regards
I have Spijkenisse as measuring station
Screen Shot 2024-01-02 at 08.01.24.png
Screen Shot 2024-01-02 at 08.01.24.png (14.75 KiB) Viewed 3151 times
btw. It's not really important. Just trying to understand this node-red thing more and the best thing is looking at the flows I see here.

Re: Water level river Waal

Posted: Tuesday 02 January 2024 12:44
by Kedi
@FireWizard Nice flow, works good, but has a small 'flaw'
The alert levels depends on the place of the measurement, see attached pictures. So those levels should also be changed in the flow.
02.01.2024_12.38.02_REC.png
02.01.2024_12.38.02_REC.png (15.96 KiB) Viewed 3167 times
02.01.2024_12.38.42_REC.png
02.01.2024_12.38.42_REC.png (17.03 KiB) Viewed 3167 times

Re: Water level river Waal

Posted: Tuesday 02 January 2024 22:15
by FireWizard
Happy new Year to all Domoticz users,

@EdwinK,

I checked the script in the "Function" node and found the issue.
The problem is that the received CSV tables are different for the various locations.

"Nijmegen Haven" has two columns, named "Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm" and "Waterhoogte verwacht Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm" I use both columns for the data to Domoticz.

"Spijkenisse", however has two columns, named "Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm" and "Waterhoogte astronomisch Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm". The name of the second column is different. And honestly, I have no idea what "astronomisch" means in this respect. I have to find out that first.

While checking the tables, I also found that the limits of the alert levels are different for each location. Of course, I have to say.
So the remark of @Kedi is correct. As the "API" has changed from JSON to CSV, the "index" data is no longer available.
I decided to put in fixed values, but these are only correct for "Nijmegen Haven". I will try the find a solution, because I like the way to use these in an "Alert" sensor.

I hope to find a solution for more locations and the right limit for each location, but for now the flow is only correct for "Nijmegen Haven"

Regards

Re: Water level river Waal

Posted: Tuesday 02 January 2024 22:51
by EdwinK
Thanks for looking into this. I wonder why they have to use different columns instead of keeping it simple(r)

Re: Water level river Waal

Posted: Tuesday 02 January 2024 23:00
by Kedi

Re: Water level river Waal

Posted: Wednesday 03 January 2024 14:51
by FireWizard
Hi @Kedi,

Thanks for your post with the links. Some of them I already saw.
Some are outdated, so I skipped these, but I will certainly have a look.

Regards

Re: Water level river Waal

Posted: Wednesday 03 January 2024 22:01
by FireWizard
Hello,

I looked once more to the flow and tried to get the limits for the water heights by means of web scraping.
It is definitely not my favorite way of collecting data. However this was not successful. So I decided to stop the attempts.

In order to configure the right levels do the following:

1. Go to https://waterinfo.rws.nl/#/publiek/waterhoogte.
2. Select your favorite measuring point.
3. Click on it and select "Meer details" (More details).
4. It will open with the graphics. See the limits below the graph or Click on "Tabel" (Table) and find the limits below the table.
5. Due to the limited levels of the "Alert" sensor, I combined the two levels of "Licht verhoogd" and "Verhoogde waterstand".
6. Make a note of the following levels:
- Red (level 4): Extreem hoogwater
- Orange (level 3): Hoogwater
- Yellow (level 2): Licht verhoogd
- Green (level1): Normaal
- Grey (level 0): Verlaagde waterstand
7. Insert the values in the "Inject node" in the field "msg.level_limit. See screenshot below:

Screenshot_Inject_ Water_Heights.png
Screenshot_Inject_ Water_Heights.png (22.69 KiB) Viewed 3037 times

The example is for the location "Nijmegen-haven(NIJM)

The location should be inserted in the field msg.location. The exact location name you will find in the URL after you clicked "Meer details".
The idx of the created virtual "Alert" sensor has to be inserted in the field msg.idx.

Below you will find two flows:

1. A new flow for @Jan Jansen for the location Nijmegen-haven(NIJM)

Code: Select all

[
    {
        "id": "47db295ed5bd870e",
        "type": "http request",
        "z": "f1324d44.f6688",
        "name": "Waterstand Nijmegen Haven",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "body",
        "url": "https://waterinfo.rws.nl/api/chart/Get?mapType=waterhoogte&locationCode={{{location}}}&values=-6,3",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 420,
        "y": 400,
        "wires": [
            [
                "76acdca27168cb32"
            ]
        ]
    },
    {
        "id": "a970ebacb7a9b8e7",
        "type": "inject",
        "z": "f1324d44.f6688",
        "name": "10 minutes Inject",
        "props": [
            {
                "p": "location",
                "v": "Nijmegen-haven(NIJM)",
                "vt": "str"
            },
            {
                "p": "idx",
                "v": "30",
                "vt": "num"
            },
            {
                "p": "level_limit",
                "v": "{\"laag\":535,\"normaal\":535,\"verhoogd\":965,\"hoog\":1220,\"extreem_hoog\":1340}",
                "vt": "json"
            }
        ],
        "repeat": "600",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "x": 150,
        "y": 400,
        "wires": [
            [
                "47db295ed5bd870e"
            ]
        ]
    },
    {
        "id": "76acdca27168cb32",
        "type": "csv",
        "z": "f1324d44.f6688",
        "name": "CSV",
        "sep": ";",
        "hdrin": true,
        "hdrout": "none",
        "multi": "mult",
        "ret": "\\n",
        "temp": "semicolon seperated values",
        "skip": "0",
        "strings": false,
        "include_empty_strings": false,
        "include_null_values": false,
        "x": 650,
        "y": 400,
        "wires": [
            [
                "86b147ecec3872c9"
            ]
        ]
    },
    {
        "id": "6b2b322a97983848",
        "type": "mqtt out",
        "z": "f1324d44.f6688",
        "name": "Naar Domoticz",
        "topic": "domoticz/in",
        "qos": "0",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "38b35487299a036d",
        "x": 1060,
        "y": 400,
        "wires": []
    },
    {
        "id": "86b147ecec3872c9",
        "type": "function",
        "z": "f1324d44.f6688",
        "name": "Function",
        "func": "let location;\nlet actual;\nlet estimated;\nlet time;\nlet level;\n\nfor (i = 0; i < msg.payload.length; i++) {\n    if (typeof (msg.payload[i][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"]) === 'undefined') {\n        actual = msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"];\n        if (typeof (msg.payload[i][\"Waterhoogte verwacht Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"]) !== 'undefined') {\n            estimated = msg.payload[i-1][\"Waterhoogte verwacht Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"];\n        }\n        time  = msg.payload[i-1].Datum + \" \" + msg.payload[i-1][\"Tijd (NL tijd)\"];\n        location = msg.payload[i-1].Locatie;\n\nswitch (true) {\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] > msg.level_limit.extreem_hoog):\n    level = 4\n    break;\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] > msg.level_limit.hoog):\n    level = 3\n    break;\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] > msg.level_limit.verhoogd):\n    level = 2\n    break;\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] > msg.level_limit.normaal):\n    level = 1\n    break;\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] < msg.level_limit.laag):\n    level = 0;\n    break;\n\n    }\n    \n    if (typeof estimated !== 'undefined') {\n        msg.payload = { \"command\" : \"udevice\", \"idx\" : msg.idx, \"nvalue\": level, \"svalue\": \"Location: \" + location + \"; Date/Time: \" + time + \"\\n\" + \"Actual: \" + actual + \" cm\" + \"; Estimated: \" + estimated + \" cm\"};\n    } else {\n        msg.payload = { \"command\" : \"udevice\", \"idx\" : msg.idx, \"nvalue\": level, \"svalue\": \"Location: \" + location + \"; Date/Time: \" + time + \"\\n\" + \"Actual: \" + actual + \" cm\"};\n    }\n    return msg;\n    }\n}",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 820,
        "y": 400,
        "wires": [
            [
                "6b2b322a97983848"
            ]
        ]
    },
    {
        "id": "38b35487299a036d",
        "type": "mqtt-broker",
        "name": "Raspberry Pi 1",
        "broker": "192.168.10.51",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]
2. A flow for @EdwinK for the location Spijkenisse(SPIJ)

@EdwinK can you test this?

Code: Select all

[
    {
        "id": "4e91eb13761f6744",
        "type": "http request",
        "z": "f1324d44.f6688",
        "name": "Waterstand Spijkenisse",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "body",
        "url": "https://waterinfo.rws.nl/api/chart/Get?mapType=waterhoogte&locationCode={{{location}}}&values=-6,3",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 410,
        "y": 460,
        "wires": [
            [
                "e368146f43533174"
            ]
        ]
    },
    {
        "id": "c7b8ef209738446b",
        "type": "inject",
        "z": "f1324d44.f6688",
        "name": "10 minutes Inject",
        "props": [
            {
                "p": "location",
                "v": "Spijkenisse(SPIJ)",
                "vt": "str"
            },
            {
                "p": "idx",
                "v": "30",
                "vt": "num"
            },
            {
                "p": "level_limit",
                "v": "{\"laag\":-67,\"normaal\":-67,\"verhoogd\":210,\"hoog\":10000,\"extreem_hoog\":10000}",
                "vt": "json"
            }
        ],
        "repeat": "600",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "x": 150,
        "y": 460,
        "wires": [
            [
                "4e91eb13761f6744"
            ]
        ]
    },
    {
        "id": "e368146f43533174",
        "type": "csv",
        "z": "f1324d44.f6688",
        "name": "CSV",
        "sep": ";",
        "hdrin": true,
        "hdrout": "all",
        "multi": "mult",
        "ret": "\\n",
        "temp": "semicolon seperated values",
        "skip": "0",
        "strings": false,
        "include_empty_strings": false,
        "include_null_values": false,
        "x": 650,
        "y": 460,
        "wires": [
            [
                "f950e6c89def1967"
            ]
        ]
    },
    {
        "id": "f950e6c89def1967",
        "type": "function",
        "z": "f1324d44.f6688",
        "name": "Function",
        "func": "let location;\nlet actual;\nlet estimated;\nlet time;\nlet level;\n\nfor (i = 0; i < msg.payload.length; i++) {\n    if (typeof (msg.payload[i][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"]) === 'undefined') {\n        actual = msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"];\n        if (typeof (msg.payload[i][\"Waterhoogte verwacht Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"]) !== 'undefined') {\n            estimated = msg.payload[i-1][\"Waterhoogte verwacht Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"];\n        }\n        time  = msg.payload[i-1].Datum + \" \" + msg.payload[i-1][\"Tijd (NL tijd)\"];\n        location = msg.payload[i-1].Locatie;\n\nswitch (true) {\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] > msg.level_limit.extreem_hoog):\n    level = 4\n    break;\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] > msg.level_limit.hoog):\n    level = 3\n    break;\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] > msg.level_limit.verhoogd):\n    level = 2\n    break;\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] > msg.level_limit.normaal):\n    level = 1\n    break;\n\n    case (msg.payload[i-1][\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"] < msg.level_limit.laag):\n    level = 0;\n    break;\n\n    }\n    \n    if (typeof estimated !== 'undefined') {\n        msg.payload = { \"command\" : \"udevice\", \"idx\" : msg.idx, \"nvalue\": level, \"svalue\": \"Location: \" + location + \"; Date/Time: \" + time + \"\\n\" + \"Actual: \" + actual + \" cm\" + \"; Estimated: \" + estimated + \" cm\"};\n    } else {\n        msg.payload = { \"command\" : \"udevice\", \"idx\" : msg.idx, \"nvalue\": level, \"svalue\": \"Location: \" + location + \"; Date/Time: \" + time + \"\\n\" + \"Actual: \" + actual + \" cm\"};\n    }\n    return msg;\n    }\n}",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 820,
        "y": 460,
        "wires": [
            [
                "55c72613d26c5709"
            ]
        ]
    },
    {
        "id": "55c72613d26c5709",
        "type": "mqtt out",
        "z": "f1324d44.f6688",
        "name": "Naar Domoticz",
        "topic": "domoticz/in",
        "qos": "0",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "38b35487299a036d",
        "x": 1060,
        "y": 460,
        "wires": []
    },
    {
        "id": "38b35487299a036d",
        "type": "mqtt-broker",
        "name": "Raspberry Pi 1",
        "broker": "192.168.10.51",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]
For both flows:

1. Insert your own Domoticz IDX in the Insert node
2. Configure your own MQTT configuration.

In case of any questions or suggestions,let me know.

Regards

Re: Water level river Waal

Posted: Wednesday 03 January 2024 22:21
by EdwinK
Works for me now :). Thanks.

Re: Water level river Waal

Posted: Thursday 04 January 2024 11:03
by Jan Jansen
Works for me too, thank you very much!