Closed richardgaywood closed 1 month ago
What unit should it be?
This device completely changed the exposed sensors in HA during the last update. It was previously recognized as "https://www.zigbee2mqtt.io/devices/TS0207_water_leak_detector.html#tuya-ts0207_water_leak_detector" and in addition to its solar sensors, it exposed the "water_leak". The "rain intensity" gives a value of 2896 if the sensor gets wet for testing which makes little sense for developing automations. Is it therefore possible to expose the old sensors again?
thank you
The raw sensor itself is outputting values in mV, because it's the "amount of volts necessary to create a short" value that it uses to indicate the sensor is wet. That's a fairly weird value to show to the user in the UI, but I don't have a better idea... It seems that you have to set a unit or Home Assistant won't treat the field as a number (which is also weird to me.)
One option could be as follows: from reading this review and the spec sheet, it sounds like this is how it responds normally:
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.
I suspect these voltage values are relative to the 3.3V VCC output pin on the chip. So maybe the best approach is to divide the current reading from the chip by 3.3V and report that as a percentage value, called, I dunno, rain_sensor_conductivity
or similar. I'd be wary of trying to map the value to intensity bands inside Z2M though, feels like the kind of thing where two sensors might have very different calibrations.
FWIW, ZHA seems to call the mV reading rain_sensor_voltage
, which I guess is maybe a little clearer if you have to put it in mV.
Also, unrelated, but -- as sajikur just wrote above as I was typing this -- the commit to Z2M doesn't seem to have the binary "water detected" sensor the device used to expose; you can see it in the sample code here (water_leak
). Was omitting that intentional?
Changes will be available in the dev branch in a few hours from now.
What happened?
The newly-added-in-1.40.0 rain sensor, when imported into HA, has no defined units of measurement; hence it looks like this when you view it:
Obv. it'd be better if this was a line graph!
What did you expect to happen?
No response
How to reproduce it (minimal and precise)
Just set up the device, no other repro steps needed.
Pretty sure the root cause is in this commit:
Note that
rain_intensity
has nowithUnit()
call. I think that's what makes HA default to the unitless mode where it treats the value as discrete categories instead of a continuous number range.Zigbee2MQTT version
1.40.0
Adapter firmware version
20210708
Adapter
ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_acea7ed057beed1196ba622e38a92db5
Setup
Home Assistgant OS add-on, on a Dell OptiPlex Micro 3050
Debug log
No response