Whenever I come across a new type of smart product that’s I’ve never encountered before, I perk up like a little child. Even though the hero device of this article is nothing new per se, it was interesting enough that I decided to get it for a review.
In this article, I’m testing and reviewing this new Tuya Zigbee Solar Rain Sensor, white labelled as model RB-SRAIN01 or sometimes WKD-LS100. I got it off AliExpress for less than $20 but it’s also available on some Amazon stores.
Technical Specification
- Model: Solar Rain Sensor RB-SRAIN01 / WKD-LS100
- Communication protocol: Zigbee 3.0
- Battery: Lithium 3.7V, 1300mAh
- Ingress rating: IPX6
- Operating temperature: -10 to 50°C
- Data sampling rate: 60sec
- Size: 104x104x21mm
- Price: $19.90 @ AliExpress
Teardown and Overview
This Tuya Solar Rain Sensor arrived in a box containing the device itself, a mounting bracket with some screws, a special sticker for installing the device on glass and a user manual. Everything was neatly packaged and wrapped in foil to prevent shipping damage.
The mounting bracket screws in place on the backside of the sensor. It can rotate and swivel up and down, useful for adjusting the proper angle and aiming the device towards the sun. The sticker is optional and needs to be used if you decide to mount the device on a glass window. It’s a very large and strong sticker that will no doubt hold this Tuya rain sensor in place.
The device looks like a sunflower, with the main induction plate going around the center. A small solar panel that recharges this rain sensor is installed in the middle. It’s powered by a 1300mAh lithium battery which should last for a very long time if the inside components are not compromised by moisture or water.
The backside of the sensor has some basic information printed along with a QR scanning code for the Tuya Smart Life app. The pairing button is placed at the bottom, marked with a small hand and an indicator LED. It’s not obvious at first, but you need to press the protective foil a bit stronger than usual in order to trigger it.
Opening up the device took a bit of pulling and I suspect I damaged the IPX6 protection rating of the sensor. I will have to fill it up with glue after I’m done. A small PCB is found inside, powered by the Tuya ZTU [Datasheet] communication module. There are no marking on the sensor whatsoever. The good thing is the lithium battery is easily user replaceable.
Home Assistant Integration
This sensor is not officially supported in Zigbee2MQTT or ZHA yet. However, I managed to create a fully working external converter for Z2M that operates great. To pair the sensor to the coordinator, press and hold the button for around 5 seconds until the LED starts blinking.
UPDATE 10.08.2024: Device now works with ZHA too! Apply this custom quirk.
Zigbee2MQTT
Out of the box, this sensor is detected as a water leak device in Zigbee2MQTT. It recycles a converter from a cabled water leak sensor that has nothing to do with this device. To get it in working order, I created an external converter and applied it in Zigbee2MQTT. Here’s how you can do that:
- Create a new file in the zigbee2mqtt directory (next to configuration.yaml)
- Name it
tuya_rain_sensor.js
(make sure it ends with .js) - Open the file, copy the contents from bellow and save the file
- Open Zigbee2MQTT and navigate to Settings > External Converters
- Press the + button and type in
tuya_rain_sensor.js
- Press Submit in the bottom left corner
- Press Restart in the top right corner
- Pair the Tuya Rain Sensor
- Done
const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const e = exposes.presets;
const ea = exposes.access;
const definition = {
fingerprint: [
{
modelID: 'TS0207',
manufacturerName: '_TZ3210_tgvtvdoc',
},
],
model: 'TS0207_rain_sensor',
vendor: 'Tuya',
description: 'Solar Rain Sensor RB-SRAIN01',
fromZigbee: [tuya.fz.datapoints, fz.battery, fz.ias_water_leak_alarm_1],
toZigbee: [],
exposes: [
e.water_leak('raining').withDescription('Droplet Detection (Raining)'),
e.numeric('illuminance', ea.STATE).withUnit('mV').withDescription('Illuminance level'),
e.numeric('illuminance_average_20min', ea.STATE).withUnit('mV').withDescription('Illuminance average for the last 20 minutes'),
e.numeric('illuminance_maximum_today', ea.STATE).withUnit('mV').withDescription('Illuminance maximum for the last 24 hours'),
e.binary('cleaning_reminder', ea.STATE, 'ON', 'OFF').withDescription('Cleaning reminder'),
e.numeric('rain_intensity', ea.STATE).withUnit('mV').withDescription('Rainfall intensity'),
e.numeric('battery', ea.STATE).withUnit('%').withDescription('Battery level'),
e.battery_low(),
],
meta: {
tuyaDatapoints: [
[4, 'battery', tuya.valueConverter.batteryPercentage],
[101, 'illuminance', tuya.valueConverter.raw],
[102, 'illuminance_average_20min', tuya.valueConverter.raw],
[103, 'illuminance_maximum_today', tuya.valueConverter.raw],
[104, 'cleaning_reminder', tuya.valueConverter.trueFalse],
[105, 'rain_intensity', tuya.valueConverter.raw],
],
},
extend: [],
};
module.exports = definition;
If the external converter was applied successfully, the rain sensor will be identified without a photo. It will have a model name of TS0207_rain_sensor with a manufacturer ID _TZ3210_tgvtvdoc. The description should be set to Solar Rain Sensor RB-SRAIN01. Here’s how it should look:
If you navigate to the exposes tab, you can see all the entities this device exposes in Home Assistant through Zigbee2MQTT and this external converter. The water leak sensor is a simple binary entity that changes state whenever the contacts of the device are connected.
It is very sensitive and operates correctly. It will immediately detect the slightest water drop on it’s surface, so it’s very usable in automations as is.
Now this is where things get interesting. Since this device uses exposed conductivity traces, when water falls on the sensor board, it bridges the gaps between these conductive traces, changing the resistance and producing a measurable voltage change. The value is reported in mV (millivolts) and has no use case as is, unless you are an expert in this field.
Creating template sensors
Even though this sensor is not meant to actually measure rainfall rate, I created a few template sensors based on the voltage reading that I believe are accurate enough to detect whether its raining lightly, moderately or heavily.
NOTE: The following calculations are based on assumptions and not facts. The sensor is not meant to measure rainfall rate. These template sensors are simply my shenanigans to convert the mV readings to text-based sensors usable in automations and dashboards.
Please do not rely on these values for anything other than fun automations.
I discovered that the mV (millivolt) reading changes non-linearly when water is introduced. With a single drop of water, it will immediately spike to 2000mV. Adding 4-5 more drops to the plate brings the value up to 2600mV. Completely submerging the sensor gives me a maximum reading of 3000-3100mV. It also has a base value of 5-7mV when dry that needs to be ignored.
With this information in mind, I created the following template sensor in an effort to differentiate between light, moderate and violent rain:
template:
- sensor:
- name: "Rain Rate"
state: >
{% set intensity = states('sensor.tuya_rain_sensor_rb_srain01_rain_intensity') | int %}
{% if intensity < 10 %}
No Rain
{% elif intensity <= 2000 %}
Light Rain
{% elif intensity <= 2600 %}
Moderate Rain
{% else %}
Violent Rain
{% endif %}
Now, depending on the amount of water at the surface of the sensor it will change state accordingly:
Of course, this method is flawed in the way that even light rain will eventually wet the entire plate and you will get a violent rain reading. Because of this, I suspect in practice the values will have to be increased even more. Something like 3000 for moderate rain and above 3000 for violent rain might prove more truthful. I intend to test this theory when we do get actual rain in my area.
If you have any ideas how to handle this better, I’d love to hear them!
Summary
The Tuya Zigbee Rain Sensor RB-SRAIN01 is quite an interesting device. It can detect rain as soon as the first drop hits its plate and report it’s state back to the coordinator. It’s powered by a rechargeable lithium battery that can keep the device going as long as there is daily sunlight to recharge the battery. It’s also user replaceable without soldering and costs only a few dollars.
The build quality of the device itself is okay. It’s glued completely shut on all sides and I don’t think water is getting inside as long as you don’t submerge it completely. The ideal mounting location would be on a window or wall, so it stays off the ground.
If you are interested in adding this Zigbee Solar Rain Sensor to your smart home, here are a few links, including my seller (1st link).
AliExpress | AliExpress | AliExpress
United Kingdom | Germany
Canada | Netherlands | France
*If links fail to open, try disabling your AdBlocker.
This is a brilliant write up. Thank you very much.
Do you think the device is good enough to detect just a few small rain drops (spitting rain) and be able to use this to know to run and get washing in? Or do you think washing would get wet before this detects enough rain?
Yes, even the slightest drop will trigger the sensor.
Even touching it with your hands will close the circuit and trigger it.
Great tutorial, thanks a lot!
I was a little bit to impatient though and paired with Z2MQTT befóre loading in the external converter. Now Z2MQTT keeps thinking it’s a water leak sensor… I already forced deletion multiple times, restarted Z2MQTT and even restarted HAss but unfortunately every time I pair it, it detects as water leak sensor.
Any idea how I can fix this?
The external converter is not applied correctly, you are doing something wrong.
Applying an external converter has priority of the default discovery of the device.
So, no matter what time you paired it, you can always apply the converter and it will work.
Force remove the device
Stop Z2M
Create the converter file
Add in Z2M (Settings > External Converters)
Start Z2M
Pair the device
same problem for me
Very nice write up, just ordered one using your affiliate link!
One suggestion, I would suggest to use the modern template sensor format for the rain intensity sensor instead of the legacy format.
I also added an availability template to avoid errors when the source sensor is not available, and a unique id so you can edit stuff like name, entity_id and icon in the GUI.
template:
- sensor:
- unique_id: template_sensor_rain_rate
name: "Rainfall Category"
state: >
{% set rain = states('sensor.your_rain_sensor') | int %}
{% if rain < 10 %}
No Rain
{% elif rain <= 2000 %}
Light Rain
{% elif rain
{{ 'sensor.your_rain_sensor' | has_value }}
sorry, the comment section messed up the indentation. here’s a link:
https://dpaste.org/uByyZ
I totally forgot about that, and just typed it out in legacy.
Changed it, thanks for the hint!
Any smart way to get around that problem? (separate notification between condensation and rain)
No, as the plate is a simple binary contact
Will condensation/dew trigger the sensor?
Yes, I believe it will
Any long term / durability experience? Usually those conductors corrode very fast and render the devices useless after 6-12 month (based on location and average rain density). Unfortunately not very sustainable.
No, not really. I cannot make any claims for the durability, as I’ve only had it for about 1 month.
Seems is going to be natively integrated in Zigbee2MQTT soon
https://github.com/Koenkk/zigbee2mqtt/issues/23532
Yes, I added the image and converter
Hello,
did you already wrote in the Z2M community in order to ask to officially integrate the device?
Yes I did!
https://github.com/Koenkk/zigbee2mqtt/issues/23532
Hello David,
I have an issue with my battery reporting (same one from Facebook). I waited 24 hours as you suggested but it is still showing as Null. If I press the button on the back of the rain sensor it changes to N/A for a short time but then reverts to Null. Is there anything else I can do? Do I have a faulty sensor?
That’s weird, converter works 100%, I’m sure as I’ve tested in on two instances.
Battery reporting is flaky in Zigbee devices, but it should have pushed an update already.
Does the device works as it should, e.g. when you add water?
yes, it reacts either to touch or a drop of water. When I first added it to z2m I wasn’t using the converter, and I’m pretty sure it was reporting a battery percentage then. Unfortunately I now can’t work out how to remove the external converter to check. Deleting the file and removing the external converter from z2m has not done anything and it still shows as a rain sensor
1. Remove the device from Zigbee2MQTT (Force)
2. Stop Zigbee2MQTT
3. Remove the
.js
converter file from your directory4. Edit Zigbee2MQTT’s
configuration.yaml
file and removeexternal_converters
along with everything bellow it5. Start Zigbee2MQTT
6. Re-pair the device.
Let me know how it goes.
Please, would You be so kind and help how to create the template? I still get errors…
btw without converter there is still very limited info (tested right now)
what do you mean exactly, create the template?
so after getting the battery to report without using the external converter, I have added the external converter and I’m back to getting Null again. Is there anything what you can think of to try?
Try this and let me know how it goes:
https://pastebin.com/LggRkRVs
I have problem -. when I follow Your guide (With this information in mind, I created the following template sensor in an effort to differentiate between light, moderate and violent rain:) – i still get errors. So I have no idea now – is converter needed? Because in my case I need it, otherwise I see only water leak senasor. So how to place the template in configuration.yaml to make it work? I am sorry, I wish I have Your skills 🙁
Just paste the template code in Home Assistant’s configuration.yaml file and change your entity name.
Save, reboot Home Assistant.
I really try
Logger: homeassistant.config
Source: config.py:592
First occurred: 8:33:10 PM (1 occurrences)
Last logged: 8:33:10 PM
Invalid config for ‘template’ at configuration.yaml, line 49: invalid template (TemplateSyntaxError: expected token ‘end of statement block’, got ‘rain’) for dictionary value ‘sensor->0->state’, got “{% set rain = states(‘sensor.rain_sensor_rain_intensity’) | int %} {% if rain < 10 %}\n No Rain\n{% elif rain <= 2000 %}\n Light Rain\n{% elif states rain <= 2600 %}\n Moderate Rain\n{% else %}\n Violent Rain\n{% endif %}\n"
You have a syntax error. Specifically, it indicates that the template parser expected the end of a statement block but instead encountered an invalid token (rain).
You are pasting wrong!
I took a screenshot of how it needs to look when correctly set in configuration.yaml.
https://imgur.com/a/GW3auxP
Done – beer on You
Remark – how do I get it to show battery level? All I have is red “%”
Thank you, that worked!
I recalled correctly and the battery % is now reported:
info 2024-08-21 18:15:25z2m:mqtt: MQTT publish: topic ‘zigbee2mqtt/Water_Leak_Detector_TZ3210_tgvtvdoc’, payload ‘{“battery”:93,”battery_low”:false,”linkquality”:94,”tamper”:false,”water_leak”:false}’
Confusing!
hi, thank you very much for the work you are doing for your blog, I wanted to tell you that I am also experiencing the battery problem, I also updated the converter what you posted above but it always gives me null % what should I do?
https://ibb.co/hdnMcK1
Try this, it fixes battery reporting:
https://pastebin.com/LggRkRVs
Hi David, unfortunately this still does not work for me. This is what I see when I generate an external definition from the dev console (before applying any external definitions):
const {battery, iasZoneAlarm, commandsOnOff} = require(‘zigbee-herdsman-converters/lib/modernExtend’);
const definition = {
zigbeeModel: [‘TS0207’],
model: ‘TS0207’,
vendor: ‘_TZ3210_tgvtvdoc’,
description: ‘Automatically generated definition’,
extend: [battery(), iasZoneAlarm({“zoneType”:”generic”,”zoneAttributes”:[“alarm_1″,”alarm_2″,”tamper”,”battery_low”]}), commandsOnOff()],
meta: {},
};
module.exports = definition;
is this any different to yours? I have a semi working device with battery reports but I have a lot to learn before I would have a fully working one
Hi SHS, I have the same problem here where the battery is reporting as null even after removing the device and adding it again using the new converter you shared, any idea why this could be happening to some of us? maybe there are devices from different manufacturers or with different firmware being sold as the same device?
This is the message I see in MQTT Explorer:
{
“battery”: null,
“battery_low”: false,
“cleaning_reminder”: null,
“illuminance”: 66,
“illuminance_average_20min”: 63,
“illuminance_maximum_today”: 5849,
“last_seen”: “2024-08-26T20:33:46.918Z”,
“linkquality”: 47,
“rain_intensity”: 44,
“tamper”: false,
“water_leak”: false
}
Yes, I’m starting to believe it might be so.
Converter is correct and battery reports for me, so it’s a possibility.
Is there anything we can do to help fix this issue? I can sniff zigbee traffic in my network while the device is paired and share the extracted data if that would help
Hello,
I tried pairing it with my Zigbee2mqtt instance (
1.39.1 commit: e132316)
The device is discovered as a ts0207_water_leak_detector
https://www.zigbee2mqtt.io/devices/TS0207_water_leak_detector.html
using the js file you provided.
I also removed it and got it discovered again (did it twice) but I always got the same issue.
I think I will have to wait the next z2m release.
Good day! All such rain sensors had the issue that, over time, the contacts oxidized significantly. Does this problem exist here? Also, what type of battery is installed, and can it withstand negative temperatures? It is not clear where and how the light sensor is connected, as no wires to the cover are visible.
Hello,
Is there a way to reset the rain meter because at home, it does not recover to 0 if it no longer and nothing happens anymore?
thanks
Read this carefully:
https://smarthomescene.com/reviews/tuya-zigbee-solar-rain-sensor-rb-srain01-review/#creating-template-sensors
The sensor has a base value of 5-7mV
I managed to solve the battery problem, basically you have to delete the custom template and forcefully delete the associated device, then reconnect the device and it will be seen as a flood sensor with the battery percentage, now just reinsert the custom template, the last one shared, and everything should work! It has been reporting the battery status correctly for two days
Would like to add my bit of experience with this battery issue. Immediately after receiving my rain sensor and connecting it to my zb2mqtt, followed by adding the external converter from this article, everything worked perfect for a few days, including the battery %.
Then one day it decided to route through another device instead of the device that I permitted to join to during my original pairing process. It then started to drop off the network. I noticed this because when i tried to repair my rain sensor after it stopped reporting sensor values, zb2mqtt says the interview was successful but the rain sensor still did not update any of its sensors (I was lazy and just press the permit join(all)).
After selecting back the original device that I used, it started working again. Only that now the battery % is now the dreaded Null% instead of reporting a proper percentage like it did before this.
Its either this rain sensor itself is picky with what it route its network to (possible because I couldn’t pair it with my coordinator directly when attempting to troubleshoot the above problem) or it doesn’t like being routed through certain devices. In this case would be a sonoff zigbee smart plug.
HA returns an error with this code
template:
– sensor:
– unique_id: template_sensor_rain_rate
name: “Rain Rate”
state: >
{% set rain = states(‘sensor.tuya_rain_sensor_rb_srain01_rain_intensity’) | int %}
{% if rain < 10 %}
No Rain
{% elif rain <= 2000 %}
Light Rain
{% elif states rain 0->state’, got “{% set rain = states(‘sensor.tuya_rain_sensor_rb_srain01_rain_intensity’) | int %} {% if rain < 10 %}\n No Rain\n{% elif rain <= 2000 %}\n Light Rain\n{% elif states rain <= 2600 %}\n Moderate Rain\n{% else %}\n Violent Rain\n{% endif %}\n"
You an indentation/syntax error.
Copy paste properly.
Many thanks for the converter!
What a strange device.
When I first started to use it, the battery reports were NULLs, and it soon stopped reporting.
Thanks to Davide for spotting to first use the inbuilt (wrong) template, then the external one.
Now my battery reports are working correctly.
Also thanks to Riri0 for the tip about (not) changing routers.
The last weeks humidity overnight is over 90%. The rain sensor keeps reporting rain due to high voltage between 1000 and 3000 mV. The sensor is already placed at a steep angle but no succes … A pity. The only resolution I see to this issue is to read actual weather and humidity and maybe setup some logic with a bayesian sensor.
Official support for Z2M has been added at 1.40.0.
Battery reporting now works for me but I have lost “Water Leak” detection.
Is this the same for anyone else?
Water leak should be there. A PR has been raised
https://github.com/Koenkk/zigbee-herdsman-converters/pull/7931
Just received this sensor. I can’t get it to pair.
Did you press the hand icon or the red dot?
And should there be a LED when pressing the button?
I don’t have anything showing up on my zigbee network and no led. Did you have to charge it first in the sun?
You need to hold the button until the LED starts blinking.
Its quite possible the battery is depleted, so leave it in the sun for a while before pairing.
Hi !
Thanks for the tutorial ! This is awesomely detailed !
But I would like to see if anyone encountered my problem which is no illuminance detected at all. It remains at 0 mV.
No problem for leak detection or battery level either.
Bud
Does anyone know how the cleaning reminder works?
Mine has now gone to true, so I’ve cleaned the front but it’s still true!
Hi all, great article. The question I have after owning this sensor for 3 weeks it has only rained twice. The first time seemed to work fine but the second time it seems that although it detects rain starting water remains on the surface for a while after the rain stops. This is despite being at quite a steep angle, more than 45 degrees. I first used coconut oil to see if that would make a difference then I used washing up liquid to remove the oil. Does anyone have any ideas to make the surface repel the water more. Thanks
I have the same problem, does anyone know what’s wrong? It rains, and it takes a long time to notify that it’s no longer raining
Great write up on a cool smart device. I do however have one issue with the device that I haven’t found any good tips on. The one I got delivered seems to have pool range at best. I can pair it with my zigbee2mqtt if the device and Z2M is in the same room but if I go outside I loose connectivity. Meshing doesn’t seem to work either.
Try pairing it directly to a router, that would enable a good path to the coordinator. Something like a smart plug in between or something
Good day! All such rain sensors had the issue that, over time, the contacts oxidized significantly. Does this problem exist here? Also, what type of battery is installed, and can it withstand negative temperatures? It is not clear where and how the light sensor is connected, as no wires to the cover are visible.
The battery can withstand negative temperatures up to -10°C.
I’m not sure about oxidation, as I haven’t had the device that long.
Hi and thanks for this wonderful article
I’m also having the battery issue, but I’ve installed just few hours ago, so I will wait at least one day.
Is there a way to convert the illuminance mV in lux or lumen ?
Thanks
After using this product for roughly a month, I would like to 100% not recommend it to anyone. Even with a pretty robust zigbee network imho, this is the first device I have owned that refuses to reconnect to the network once it drops off. I will notice it only a few hours or maybe even the next day, then I am forced to climb up there and reset it to make it join the network. The funny thing is, when I reset it, zb2mqtt does detect it leaving the network. And no, pressing the button or triggering the sensor yourself doesn’t magically reconnect it back, a reset is the only option.
I would like to suggest smarthomescene to do a more thorough review of a devices reliability. All because the device is based on the same chip/platform that has worked well for many devices before this doesn’t mean it is as reliable as those previous product.
Hello,
I still have this rain sensor deployed. It has not caused any connectivity issues for me.
Since it’s far from my coordinator (SMLight SLZB-06M), I have it paired through a router plug (Tuya TS011F_plug_3) and it works without connection drops.
I don’t assume anything when I’m testing smart devices, especially those from the Tuya ecosystem.
I spent several days tinkering with the device and trying to get the template sensors to make sense before writing my article.
Are you certain the battery is fully charged? I would not trust the reported battery level in Zigbee2MQTT.
Is the unique manufacturer identifier the same (_TZ3210_tgvtvdoc)?
I am sorry but I am with SHS on this one, and just because you are having some issues with connectivity doesn´t mean everyone else is having those issues. I’ve had this device connected to my zigbee network for almost a month now and only had one connectivity issue at the very beginning when I placed it too far away from the nearest router so it dropped the network after some hours. After placing the device closer to a router it has not dropped the network even once for the last three weeks.