Hi @FireWizard,
You were right about wrong value in the interval length node.
I had changed one of the milliseconds to seconds and forgot to re-set it.
I also found out that I managed to add another string from the sensor input to the function node.
I have corrected these two errors. and Now I'm back with only 0;0.0
Regards
Markus
Issue with data from WGR800
Moderator: leecollings
-
- Posts: 13
- Joined: Wednesday 04 January 2017 17:29
- Target OS: Linux
- Domoticz version: 2021.1
- Location: Sweden
- Contact:
Re: Issue with data from WGR800
- Attachments
-
- node 20231107_111.jpg (41.97 KiB) Viewed 1039 times
- FireWizard
- Posts: 1769
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: Issue with data from WGR800
Hello Markus, @hasselhoffer,
In one of my previous posts, I said also:
I found the following topic from waaren (RIP):
states the following:
I also found in a post:
So if your RAIN shows 1035.4, just send it. If it receives in a next post 1037.8, it will show that value, but because the counter is reset to 0 at midnight, the next value (of the next day), you will send e.g. 1039.9, the device will show 2.1 mm.
However the disadvantage is that, if you e.g. start your device at a certain time a value of 1037.8 is shown and a very high bar in the log graph is shown.
We should solve that in Node-RED.
I also found another post from @waltervl at viewtopic.php?p=302322&hilit=Rain+sensor#p302322, telling:
Some pictures:
The first Debug Node shows what your Rain Sensor delivered, RAIN is 1005 mm. The last value of the previous day has been 1003 mm.
The Rain widget:
So the difference between 1005 and 1003 is 2 mm and that is exactly what is indicated in the widget.
The rain rate is calculated as follows.
You can see in debug 203, that the interval between sending 1003 and 1005 has been 63430803 milliseconds. (I skipped the values after the decimal point.) 63430803 milliseconds equals to approx. 63430 seconds and that divided by 3600 gives us approx. 17.62 hours. Which is correct.
The rain rate is 2 mm divided by 17.62 hr. 0.11 mm/hr. This is also the value indicated in the widget.
So far so good, but to get that, I had to multiply this rain rate with 100. See the result of debug node 201 for svalue.
[Edit]
This is also confirmed in the WIKI. See: https://www.domoticz.com/wiki/Domoticz_ ... L%27s#Rain
@hasselhoffer.
So I modified the "Function" node again and I introduced an "offset" in order to avoid a very high value on the first day of operation.
I believe that not every rain sensor has the capabilities of resetting its value to 0.
So in line 3 you have to set the received value from the rain sensor, just before you send the message for the first time to Domoticz.
See:
The complete Node RED flow for the "Function" node, see below:
Test it during some days and let me know.
Regards
That was my only possibility to create a NaN, so I thought that was the reason for it.I had changed one of the milliseconds to seconds and forgot to re-set it.
I also found out that I managed to add another string from the sensor input to the function node.
I have corrected these two errors. and Now I'm back with only 0;0.0
In one of my previous posts, I said also:
I did some further research and search for similar forum topics.During my tests with the "Rain" sensor, I saw also some strange values. Not sure, what caused this, but as this is a cumulative counter, it might be caused by the values I sent.
I found the following topic from waaren (RIP):
The documentation, presented at: https://piandmore.wordpress.com/2019/02 ... -domoticz/The value shown on the title row of a rain device shows the latest send value minus the first value of today. So if you have send the same value it will show 0
The value will be reset to 0 at midnight.
states the following:
This note may confuse you, as you would expect, in order to show the Total Rain Counter as being 5 mm for today, you should send the delta. So you might think that you should sent 2 (mm). That is wrong. Your Rain Counter may send anything, but as soon as a new value is received, Domoticz takes care of the difference between those two and will show it in the title bar. So we have to correct this, as I earlier assumed also, that I have to send the delta.The rain sensor will show the amount of rain fallen in mm and a rate in mm/h. You can send:
{"command":"udevice", "idx":1234, "svalue":"rt;fl"}
where rt is the rate in mm/h fl is amount of rain fallen. PLEASE NOTE that fl is cumulative, so if the value is 3 mm and you send 2 mm, it will be 5 mm.
I also found in a post:
This confirms my previous opinion.If you use MQTT to update the Domoticz Rain device you have to send the TOTAL counter and not the delta's
So if your RAIN shows 1035.4, just send it. If it receives in a next post 1037.8, it will show that value, but because the counter is reset to 0 at midnight, the next value (of the next day), you will send e.g. 1039.9, the device will show 2.1 mm.
However the disadvantage is that, if you e.g. start your device at a certain time a value of 1037.8 is shown and a very high bar in the log graph is shown.
We should solve that in Node-RED.
I also found another post from @waltervl at viewtopic.php?p=302322&hilit=Rain+sensor#p302322, telling:
Also @waltervl confirms my conclusion, however I do not support his multiplication of 100 for the Total Rain Counter.The counter is a total counter (like your electricity counter) so you have to send the total mm of rain measured from installing the rain meter. Example:
100000 - 1000 mm rain measured until now
100000 - no rain
100100 -- 1 mm rain has fallen
100100 -- no rain
101000 -- 9 mm rain has fallen.
101000 -- no rain
Some pictures:
The first Debug Node shows what your Rain Sensor delivered, RAIN is 1005 mm. The last value of the previous day has been 1003 mm.
The Rain widget:
So the difference between 1005 and 1003 is 2 mm and that is exactly what is indicated in the widget.
The rain rate is calculated as follows.
You can see in debug 203, that the interval between sending 1003 and 1005 has been 63430803 milliseconds. (I skipped the values after the decimal point.) 63430803 milliseconds equals to approx. 63430 seconds and that divided by 3600 gives us approx. 17.62 hours. Which is correct.
The rain rate is 2 mm divided by 17.62 hr. 0.11 mm/hr. This is also the value indicated in the widget.
So far so good, but to get that, I had to multiply this rain rate with 100. See the result of debug node 201 for svalue.
[Edit]
This is also confirmed in the WIKI. See: https://www.domoticz.com/wiki/Domoticz_ ... L%27s#Rain
@hasselhoffer.
So I modified the "Function" node again and I introduced an "offset" in order to avoid a very high value on the first day of operation.
I believe that not every rain sensor has the capabilities of resetting its value to 0.
So in line 3 you have to set the received value from the rain sensor, just before you send the message for the first time to Domoticz.
See:
Code: Select all
const idx = 27;
let bat;
const offset = 1005; // Insert your RAINCOUNTER value, just before you connect to your Domoticz for the first time.
if (typeof flow.get("rainvalue") == "undefined" || typeof flow.get("rainvalue") != "number" || isNaN(flow.get("rainvalue"))) {
flow.set ("rainvalue", (msg.payload.RAIN - offset));
} else {
let rate = ((msg.payload.RAIN - offset) - flow.get("rainvalue")) / (msg.interval / 360000000);
flow.set ("rainvalue", (msg.payload.RAIN - offset));
if (msg.payload.BAT === "OK") {
bat = 100
} else if (msg.payload.BAT === "LOW") {
bat = 10
}
msg.payload = {"command": "udevice", "idx": idx, "svalue": rate.toFixed().toString() + ";" + (msg.payload.RAIN - offset).toFixed(1).toString(), "Battery" : bat};
return msg;
}
Code: Select all
[
{
"id": "b9a92466bc45cba4",
"type": "function",
"z": "d4b35d52470a739f",
"name": "To Domoticz",
"func": "const idx = 27;\nlet bat;\nconst offset = 1005; // Insert your RAINCOUNTER value, just before you connect to your Domoticz for the first time.\n\n\n\nif (typeof flow.get(\"rainvalue\") == \"undefined\" || typeof flow.get(\"rainvalue\") != \"number\" || isNaN(flow.get(\"rainvalue\"))) {\n flow.set (\"rainvalue\", (msg.payload.RAIN - offset));\n} else {\n let rate = ((msg.payload.RAIN - offset) - flow.get(\"rainvalue\")) / (msg.interval / 360000000);\n flow.set (\"rainvalue\", (msg.payload.RAIN - offset));\n \n if (msg.payload.BAT === \"OK\") {\n bat = 100\n } else if (msg.payload.BAT === \"LOW\") {\n bat = 10\n }\n\n msg.payload = {\"command\": \"udevice\", \"idx\": idx, \"svalue\": rate.toFixed().toString() + \";\" + (msg.payload.RAIN - offset).toFixed(1).toString(), \"Battery\" : bat};\n \n return msg;\n}",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 650,
"y": 360,
"wires": [
[
"8f742a18051a24ce",
"f4315ef89c60f491"
]
]
}
]
Regards
Who is online
Users browsing this forum: No registered users and 0 guests