# Significant Rainfall Event SRE

**URL:** <https://discourse.nodered.org/t/significant-rainfall-event-sre/91052>\
**Category:** General\
**Created:** [17 September 2024 18:18 UTC](https://discourse.nodered.org/t/significant-rainfall-event-sre/91052 "2024-09-17T18:18:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhmeh](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@abhmeh](https://discourse.nodered.org/u/abhmeh)\
**Post date:** [17 September 2024 18:18 UTC](https://discourse.nodered.org/t/significant-rainfall-event-sre/91052/1 "2024-09-17T18:18:10Z")

</div>

Hi All,

I am developing a application that detects a significant rainfall event every 24 hours

**SRE Definition:**

Rainfall \>= 25 mm in 24 hr

I am using open microsoft to get ranifall data for last 24 hours

After a SRE Event is detect (SRE\_Event == True) I want to add rainfall data every 1 hour to 24 hour value(25mm) until the rainfall has ended (0 mm)

I am using change nodes right now to extract value for rainfall for past 24 hour and 1 Hour

---

<div class="post-metadata">

**Author:** ![abhmeh](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@abhmeh](https://discourse.nodered.org/u/abhmeh)\
**Post date:** [17 September 2024 18:20 UTC](https://discourse.nodered.org/t/significant-rainfall-event-sre/91052/2 "2024-09-17T18:20:27Z")

</div>

```auto
[
    {
        "id": "b45146a810171392",
        "type": "inject",
        "z": "18a6ff3f97d0870e",
        "name": "",
        "props": [
            {
                "p": "timestamp",
                "v": "",
                "vt": "date"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "3600",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 430,
        "y": 2780,
        "wires": [
            [
                "27fccc2cab4e22b8"
            ]
        ]
    },
    {
        "id": "d4f68a3ce7fca3ce",
        "type": "debug",
        "z": "18a6ff3f97d0870e",
        "name": "debug 16",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "SRE_Event",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1340,
        "y": 2780,
        "wires": []
    },
    {
        "id": "27fccc2cab4e22b8",
        "type": "http request",
        "z": "18a6ff3f97d0870e",
        "name": "",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "https://atlas.microsoft.com/weather/currentConditions/json?api-version=1.0&query=47.60357,-122.32945&subscription-key=7KtFD0f7uB6C6Mo7Cq3XXXXXXXXXXXXXXXXXXXXXXV1iE0A1JQQJ99AIAC8vTInGlVfjAAAgAZMPvOZv",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [
            {
                "keyType": "Content-Type",
                "keyValue": "",
                "valueType": "application/json",
                "valueValue": ""
            }
        ],
        "x": 630,
        "y": 2780,
        "wires": [
            [
                "3ed88f69160a5794",
                "5dd1dea98a797ebc",
                "27bed8caabdd785d"
            ]
        ]
    },
    {
        "id": "113a9639bddb4196",
        "type": "function",
        "z": "18a6ff3f97d0870e",
        "name": "Check Precipitation",
        "func": "//$PROMPT: Write a function that checks if precipitation value is greater than 25 which will set SRE_Event = True if no Sre Event = False {\"value\":0,\"unit\":\"mm\",\"unitType\":3}\nconst precipitation = msg.payload\n\nif (precipitation > 25) {\n msg.SRE_Event = true\n} else {\n msg.SRE_Event = false\n}\nreturn msg",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1090,
        "y": 2780,
        "wires": [
            [
                "d4f68a3ce7fca3ce"
            ]
        ]
    },
    {
        "id": "3ed88f69160a5794",
        "type": "change",
        "z": "18a6ff3f97d0870e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.results[0].precipitationSummary.past24Hours",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 820,
        "y": 2780,
        "wires": [
            [
                "113a9639bddb4196",
                "6247442d46094351"
            ]
        ]
    },
    {
        "id": "6247442d46094351",
        "type": "debug",
        "z": "18a6ff3f97d0870e",
        "name": "debug 17",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1040,
        "y": 2840,
        "wires": []
    },
    {
        "id": "5dd1dea98a797ebc",
        "type": "debug",
        "z": "18a6ff3f97d0870e",
        "name": "debug 18",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 2700,
        "wires": []
    },
    {
        "id": "c6fdce1d28345bc2",
        "type": "debug",
        "z": "18a6ff3f97d0870e",
        "name": "debug 19",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1200,
        "y": 2880,
        "wires": []
    },
    {
        "id": "27bed8caabdd785d",
        "type": "change",
        "z": "18a6ff3f97d0870e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.results[0].precipitationSummary.pastHour",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 820,
        "y": 2880,
        "wires": [
            [
                "113a9639bddb4196",
                "c6fdce1d28345bc2"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [17 September 2024 19:21 UTC](https://discourse.nodered.org/t/significant-rainfall-event-sre/91052/3 "2024-09-17T19:21:01Z")

</div>

@abhmeh Are you sure that you want to share your subscription key with the world?

Also, in order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your last post above by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [17 September 2024 19:46 UTC](https://discourse.nodered.org/t/significant-rainfall-event-sre/91052/4 "2024-09-17T19:46:57Z")

</div>

You need to report your own post and ask a moderator to remove that API key!

Or since it's out in public, change it for a new one with the site it's for.

---

<div class="post-metadata">

**Author:** ![abhmeh](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@abhmeh](https://discourse.nodered.org/u/abhmeh)\
**Post date:** [17 September 2024 20:23 UTC](https://discourse.nodered.org/t/significant-rainfall-event-sre/91052/5 "2024-09-17T20:23:11Z")

</div>

@Paul-Reed Thanks for the correction I removed the link. I have uploaded my code I am using change nodes to get values from array for past24Hours Precipitation and pastHour precipitation.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [17 September 2024 20:28 UTC](https://discourse.nodered.org/t/significant-rainfall-event-sre/91052/6 "2024-09-17T20:28:05Z")

</div>

> [@abhmeh](#):
>
> Thanks for the correction I removed the link

You should still get a moderator (eg @Paul-Reed) to fix it because we can see the history of your edits.

---

<div class="post-metadata">

**Author:** ![abhmeh](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@abhmeh](https://discourse.nodered.org/u/abhmeh)\
**Post date:** [17 September 2024 20:41 UTC](https://discourse.nodered.org/t/significant-rainfall-event-sre/91052/7 "2024-09-17T20:41:14Z")

</div>

@Paul-Reed Hi Paul can you please remove the link from the post?

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [17 September 2024 20:54 UTC](https://discourse.nodered.org/t/significant-rainfall-event-sre/91052/8 "2024-09-17T20:54:02Z")

</div>

I've hidden your history records and also edited a further exploit in the flow.  
As it's been shown for a number of hours, I would generate a fresh key, and retire that one.

---

<div class="post-metadata">

**Author:** ![abhmeh](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@abhmeh](https://discourse.nodered.org/u/abhmeh)\
**Post date:** [17 September 2024 21:21 UTC](https://discourse.nodered.org/t/significant-rainfall-event-sre/91052/9 "2024-09-17T21:21:18Z")

</div>

@Paul-Reed Thanks Paul, I will regenerate it. Coming back to my question please check my code.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [17 September 2024 21:42 UTC](https://discourse.nodered.org/t/significant-rainfall-event-sre/91052/10 "2024-09-17T21:42:17Z")

</div>

Do you have an example of the data you receive, preferably with a SRE event?

You can post the data using the `</>` button just like with code.

---

<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:** [16 December 2024 21:43 UTC](https://discourse.nodered.org/t/significant-rainfall-event-sre/91052/11 "2024-12-16T21:43:00Z")

</div>

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