I have a Sonoff SWV water valve which hooks into HA via Zigbee2MQTT. Turning a valve on and off is the easy bit. Can’t seem to work out how I can close the valve after X number of liters have passed through it. The Sonoff only seems to return a flowcontrol value.
Note that I don’t own one of these, so the below advise is only based on the Z2M docs for this device.
You should have an irrigation_capacity setting for that device, measured in litres. Set that to 1 for testing purposes and turn on the SWV. It should* dispense around 1L before turning off.
*Note that this will depend on how accurately the SWV measures the flow. You may have to play around with the values a bit to get the desired amount of water, since there seem to be no calibration options for this device.
Thanks @ShadowFist - Using that link I can see that “irrigation_capacity” is available as part of ‘cyclic_quantitative_irrigation’ (which you have to enable/config) and that I can set it via the Z2M config page. Will indeed have a bit of a play with that and see what info it reports back to HA so I can use it for further automation.
How are you getting on with this Akubra? I’m having the same issue as you.
Not much luck I’m afraid.
I have just added some steps outlined in:
https://www.reddit.com/r/homeassistant/comments/1hrbc6t/sonoff_water_valve_usage_tracking_issue_in_home/
and will do some actual testing with it tomorrow.
@Blen With the above implemented I get a bit more details returned but not what I was expecting. The ‘usage_increasing’ sensor jumps to 30L as soon as the valve opens and stays on 30 even after having the valve open (and water running) for about 10 minutes.
I also have the Sonoff SWV valve. I am connected via ZHA and it provides flow rates. I am brand new to HA and from what I can tell I am supposed to use an integral helper. I believe I have created the helper but I don’t know what to do with that. I am hoping to be able to press a button and have it dispense a certain volume of water.
The flow rate seems to report only one digit after the decimal point. I increased the display digits to 3, but all I see is 0.100, 0.200, 0.300, etc.
My measurement this morning showed a flow rate of 0.300, with 20min irrigation translates to 0.100 m^3 (100 liter), and my utility meter showed a consumption of 112 liter, so it seems accurate enough.
To find the water volume, you can set up an integral sensor to give you the total amount of water, and then a statistics sensor to give you the delta per 24 hours, to display the daily amount of water your plants receive.
Roman
Hi Roman,
That’s exactly what I need. When I try to create this, I get a much too high water consumption, as the sum is formed using the maximum of the volume flow. However, the maximum is only reached at the beginning, when the valve is opened. The total should be calculated using the average of the volume flow. Can you show me how you have implemented this?
Maybe it is calculated from the maximum flow, that is shortly after the valve is open.
How can I calculated the water usage from the medium (Mittel) value?
I probably haven’t fully understood how I can display or calculate the water usage from the flow value.
I could not find a way to display the yaml, so here are two screenshots with my integral sensor.
I am not sure about the integration rule, I am now trying the trapezoidal rule, and compare.
Thank you.
I have copied your configuration, but it still displayed much too high values. Maybe my Sonoff SWV is not working properly.
The valve itself can stop after a predetermined amount of water. I created three “input number” helpers and an automation that uses these values. This will only work with Zigbee2MQTT.
The automation:
alias: Gartenwasser
description: ""
triggers: []
conditions: []
actions:
- action: mqtt.publish
metadata: {}
data:
qos: "2"
retain: false
topic: zigbee2mqtt/Gartenwasser-Ventil/set
payload: >-
{"cyclic_quantitative_irrigation": {"total_number": {{
states('input_number.gartenwasser_anzahl_zyklen') | int }},
"irrigation_capacity": {{
states('input_number.gartenwasser_liter_pro_zyklus') | int }},
"irrigation_interval": {{
states('input_number.gartenwasser_pause_s_zwischen_zyklen') | int }}}}
mode: single
I guess the problem is the flow sensor. When I switch on the valve the value of the field “Flow” is shortly displaying something between 0.1 and 0.3 m³/h. After 0.5 seconds the value is 0 m³/h.
I use this valve for a drip irrigation with a flow of approx. 10-20 l/h
Why is the field “Flow” not permanently displayed the water flow in m³/h?
Because 10-20 l/h = 0.01-0.02 m³/h, and the device is probably only reporting at a single decimal place.
Read the above posts - the SWV seems to be reporting only the maximum flow (when you first open the water) up to a single decimal point.
Thank you! I opened the outlets at the plants a little and voila, I can see the flow. Unfortunately, the Sonoff SWV is not so precise.






