# Calculate rainfall per 24h

**URL:** <https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167>\
**Category:** General\
**Created:** [21 October 2018 11:17 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167 "2018-10-21T11:17:35Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [2 November 2018 09:22 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/21 "2018-11-02T09:22:39Z")

</div>

You have the function in the example I already gave you that has all the three parameters you want as different variables. So it should be very easy to follow the examples in the documentation to get each variable sent to a different output.  
The best way to learn is t play with it, make mistakes, so you understand what works

---

<div class="post-metadata">

**Author:** ![Florian](https://avatars.discourse-cdn.com/v4/letter/f/898d66/32.png) [@Florian](https://discourse.nodered.org/u/Florian)\
**Post date:** [2 November 2018 10:10 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/22 "2018-11-02T10:10:39Z")

</div>

I read it, but didn't understand it. Sorry.

You are outputting as payload " Total Rain =772.1 Period Rain0 Rain Today772.1". But I can't find a function to separate it, so 3 payloads then. Do you have a tip for me? Thanks a lot!

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [2 November 2018 10:27 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/23 "2018-11-02T10:27:54Z")

</div>

Don't look at the output, look at the function that creates it. (Which is also the function that you need to modify)

If you don't understand that function there are lots of guides/tutorials for javascript on the web.

Theres also a great introduction to node-red that you can follow here: [http://noderedguide.com](http://noderedguide.com)

---

<div class="post-metadata">

**Author:** ![Florian](https://avatars.discourse-cdn.com/v4/letter/f/898d66/32.png) [@Florian](https://discourse.nodered.org/u/Florian)\
**Post date:** [2 November 2018 10:32 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/24 "2018-11-02T10:32:46Z")

</div>

I have to translate everything first, because english is not my mother tongue. maybe i will recognize what i have to do to get the values into the dashboard ...

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [2 November 2018 10:47 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/25 "2018-11-02T10:47:51Z")

</div>

Wenn Sie die Grundlagen von Javascript verstehen, sind sie klar.  
Ich empfehle Ihnen, eine Anleitung für Javascript in Ihrer Muttersprache zu lesen.

---

<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:** [2 November 2018 10:57 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/26 "2018-11-02T10:57:41Z")

</div>

[https://wiki.selfhtml.org/wiki/JavaScript/Tutorials](https://wiki.selfhtml.org/wiki/JavaScript/Tutorials) - zum Beispiel.

---

<div class="post-metadata">

**Author:** ![Florian](https://avatars.discourse-cdn.com/v4/letter/f/898d66/32.png) [@Florian](https://discourse.nodered.org/u/Florian)\
**Post date:** [3 November 2018 10:04 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/27 "2018-11-03T10:04:22Z")

</div>

So, I've read through various publications and come to the conclusion that I don't understand it. Apparently I am already too old and I simply lack the basic information what I have to do.

But don't worry, I won't become a programmer anymore 🙂

Thanks for your help, the flow also works without the values in the dashboard.

All the best for you!

---

<div class="post-metadata">

**Author:** ![tccack](https://avatars.discourse-cdn.com/v4/letter/t/e9c0ed/32.png) [@tccack](https://discourse.nodered.org/u/tccack)\
**Post date:** [30 May 2019 08:10 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/28 "2019-05-30T08:10:44Z")

</div>

Florian.... in case you are still seeking this I found a node in the library which helped me with a power meter. It has 3 modes but the one you are looking for is the difference mode between start value and last value within a time bracket.

It is called Totaliser and is in the node-red flows library

---

<div class="post-metadata">

**Author:** ![Florian](https://avatars.discourse-cdn.com/v4/letter/f/898d66/32.png) [@Florian](https://discourse.nodered.org/u/Florian)\
**Post date:** [3 June 2019 07:19 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/29 "2019-06-03T07:19:49Z")

</div>

Thx Tony!

I will take a closer Look in the next few Days ...

Greetz!

---

<div class="post-metadata">

**Author:** ![tccack](https://avatars.discourse-cdn.com/v4/letter/t/e9c0ed/32.png) [@tccack](https://discourse.nodered.org/u/tccack)\
**Post date:** [5 June 2019 02:51 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/30 "2019-06-05T02:51:53Z")

</div>

if you use it, see if you can determine if multiple instances work. I have found I can use it one time in a flow (to calculate the difference between start value and end value in a power meter metric, but if I place a second instance it seems to replicate the value of the initial one.  
I suspect I'm missing something but scratching my head over it.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [5 June 2019 05:48 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/31 "2019-06-05T05:48:10Z")

</div>

You might want to check the source code for that node. If the variable being used is inside the register node function, it will be per-instance. If it is outside, it will be per-Node-RED instance instead of per-node instance.

---

<div class="post-metadata">

**Author:** ![tccack](https://avatars.discourse-cdn.com/v4/letter/t/e9c0ed/32.png) [@tccack](https://discourse.nodered.org/u/tccack)\
**Post date:** [5 June 2019 07:37 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/32 "2019-06-05T07:37:10Z")

</div>

What should I look for in the code?  
This is what I found as far as looking for the source code.  
[https://npm.runkit.com/node-red-contrib-totaliser/totaliser/totaliser.js?t=1559719711123](https://npm.runkit.com/node-red-contrib-totaliser/totaliser/totaliser.js?t=1559719711123)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [5 June 2019 09:17 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/33 "2019-06-05T09:17:02Z")

</div>

As @TotallyInformation guessed the declaration of total (line 33) is outside the main node declaration (line 39) so is one total per Node-RED , and not one per node.

You could raise an issue on that nodes project page and ask if that is intentional (it might be) or if not, could they fix it.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [5 June 2019 10:06 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/34 "2019-06-05T10:06:06Z")

</div>

Well, I'm glad that something good has come of all of the hours I've spent wading through the source code for nodes in order to try and improve uibuilder 😉

---

<div class="post-metadata">

**Author:** ![tccack](https://avatars.discourse-cdn.com/v4/letter/t/e9c0ed/32.png) [@tccack](https://discourse.nodered.org/u/tccack)\
**Post date:** [5 June 2019 11:21 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/35 "2019-06-05T11:21:41Z")

</div>

I'll head over to there and make some inquiries... I'm glad I wasnt going crazy(ier)

---

<div class="post-metadata">

**Author:** ![yutter](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/yutter/32/9026_2.png) [@yutter](https://discourse.nodered.org/u/yutter)\
**Post date:** [5 June 2019 11:59 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/36 "2019-06-05T11:59:45Z")

</div>

Good spot. Don't know what I was up to that day! Pushing a fix today

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [5 June 2019 12:14 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/37 "2019-06-05T12:14:03Z")

</div>

thanks for being so responsive.

---

<div class="post-metadata">

**Author:** ![yutter](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/yutter/32/9026_2.png) [@yutter](https://discourse.nodered.org/u/yutter)\
**Post date:** [5 June 2019 17:18 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/38 "2019-06-05T17:18:01Z")

</div>

The totaliser node has been updated! Hopefully that will work now 🙂

---

<div class="post-metadata">

**Author:** ![JohnMM](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnmm/32/47112_2.png) [@JohnMM](https://discourse.nodered.org/u/JohnMM)\
**Post date:** [10 December 2019 04:13 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/39 "2019-12-10T04:13:13Z")

</div>

**node-red-contrib-totaliser**

I think the update may have caused an issue where setting msg.payload to 'reset' (to clear the total and restart the interval timer) causes a ReferenceError: "startTime is not defined"

```auto
    node.on('input', function (msg) {
      if ('payload' in msg) {
        if (msg.payload === 'reset') {
          startTime = Date.now();
          node.total = 0;
        }

```

should it not be:

```
      node.startTime = Date.now();

```

I've just started using Node-RED and not much JavaScript so apologies if I'm just making some stupid mistake with Node-RED.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [10 December 2019 07:44 UTC](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167/40 "2019-12-10T07:44:14Z")

</div>

Hi,  
As it's not one of the core nodes you will have to contact the author direct, but yes what you suggest makes sense.

[Previous page](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167.md?page=1)

[Next page](https://discourse.nodered.org/t/calculate-rainfall-per-24h/4167.md?page=3)
