To decide on what voltage matches amount of litres in the tank I followed the advice along these lines.
Record your voltage with the device not in the tank.
Put your device in - check your voltage.
The differencer in the voltage should be more or less equal to the amount of water in the tank. Then a simple maths calc whould give you a good starting basis for water measure calculations.
Then…
Monitor both voltage and water level over the course of the next 4 weeks. You will soon begin to see a correlation between them.
With mine I was able to pump to the tank (header tank) that I wanted to monitor so I had a completely full tank to start with. I then had both empty and full voltage readings to give me max and min voltage readings.
I then have a volume reading (11,000 litres - just over halfway on my 22,500 litre tank) that triggers an automation to switch my header tank pump to run for 3 hours. I know this will then top up again to about 19,000 litres.
I further tweaked the automations so that the switching of the header tank pump only occurs after 11am (full solar). I intend to try and make it a bit smarter soon by including a condition whereby it monitors the output from solar so pumping doesn’t try and occur on a cloudy less productive day.
Pat
Thankyou both. I will try your suggestions when the sensor arrives.
Just FYI my 2 tanks are connected to equal 20,000L, rather than them being separate units that pump to each other. So unfortunately I do not have a magic water source to fill up one tank to get the values, literally reliant on rain to fill them both at the same time.
I will still need to do some rough measurements as the tank outlets are higher than the bottom of the tank and the tank overflow is lower than the top, so this may affect the quoted “10,000L” claimed capacity and consideration given for placement of the sensor.
Thanks again.
What’s the | float in this calculation?
This is my first time using a calculation like this in HA and I can’t find where it explains what the pipe (|) does in the calculation. Here’s what I’m referring to:
(states.sensor.tank_height.state | float)
I’m pretty sure my calculation should be as follows but I don’t know if I need (or want?) something following my uni state:
((sensor.shellyuni_34945475a116_adc | ???) * 8 / 9.6) * (916.9 * 7.48052) | round(2)
I’m using voltage. so to explain:
- (voltage * 8 / 9.6) - I have an 8 ft deep tank and the voltage when full will be 9.6, so I’m converting voltage to feet
- (voltage * 8 / 9.6) * (916.9 * 7.48052) - the surface area of my cistern is 916.9 feet, multiply that and feet deep by 7.48052 to get gallons in tank.
- | round(2) - round it to 2. I will probably change it to “integer.” assuming that works.
Thanks for your help.
It changes the string held in states.sensor.tank_height.state
into a floating point number. All states in HA are strings. Also in precedence of what is executed first without parens is | then / the * then + then -
Hope this helps
so for it to work in yaml
((sensor.shellyuni_34945475a116_adc | float(0)) * 8 / 9.6) * (916.9 * 7.48052) | round(2)
can be written as follows
{{ ((states('sensor.shellyuni_34945475a116_adc') | float(0)) * 0.8333333) * 6858.88787) | round(2) }}
Each volt represents 0.83333’ of water and each ft of water is equal to 6858.88787 gallons of water.
No reason to do calculation on constants in my opinion.
Thank you for explaining that @AllHailJ I’ve got the formula working on the template tester but am having a hell of a time integrating into the yaml file. I’ll save that question for another post though.
I’ve got a mystery happening though I’m testing the sensor in my pool. It won’t show any voltage until I’m in about a foot of water.
At 13” deep it is .03V
At 15” deep it’s 1.7V
I’m connected to 12V power and this reads at a max of 3 meters.
Should it show me a reading under 12” or are these not sensitive enough?
I was having similar issues. I connected the green earth wire from the shelly uni to the neutral and all is good now.
Also, in case it is not apparent. You can work out the ~expected volts using th sensor details. My sensor is 0-5v range for a depth of 200cm. So 0v is 0cm and 5v is 200cm… the rest is maths. From there you can work out volts to volume.
@balkerman I ended up doing that and it solved the issue. I can’t figure out how others got it to work without the green wire connected.
After I did that I went through the process of changing the voltage to gallons. The math part I worked out fairly quickly. My YAML skills are not great so that one almost made my head explode.
Does anyone else have a problem of the output voltage varying to the point it makes the readings unreliable? My setup the output from the pressure sensor varies between 1.6v and 1.87v when the water pressure should be unchanged. It changes every few seconds.
I am experiencing the same issue. I am suspecting on the power supply (12v). Maybe trying with 24V the measures are more stable. Did you solve your issues?
I’m using the statistics mean template with some success. I’m not sure if the power supply or the sensor or the Shelly Uni creates the varying voltage.
Thanks! I’ve redone the connections and I have improved a little bit the situation but it stills oscillating in terms of 0,15 V. I am currently applying the filter you propose, have you used the parameters of the sensor like this?
- platform: statistics
name: "shellyuni_34945477e138_adc_mean"
entity_id: sensor.shellyuni_34945477e138_adc
state_characteristic: mean
max_age:
minutes: 1
Still jumps around but I use these settings.
max_age:
seconds: 3600
sampling_size: 200
How’s everyone’s pressure sensors working out?
Stil working well, worth getting one?
Mine is working well still. I have another on my bench to install in a 5000L tank near my shed.
Iam in Brisbane and during the rains it was reporting 102% capacity as the tanks were actively overflowing.
Great, thanks that sounds promising.
Can you please share your hardware.
If you look at Mongoose’s post on the 23rd of Feb you can see the equipment, mine is the same. I used an old Netgear 12v power supply.
Hi there,
I am so sorry for the old reply, how in the world did you get this to work. Im struggling. I can get the volt but not sure where to start on the card. I am trying to just get a gauge with percentages. I am using the gauge card, just stuck on volts.
If you’re looking for percent full, it is the current voltage / full range voltage
So if your current voltage is 3 and the full range is 6 volts, then your percentage full is
3/6*100 = 50%.
Does that help?
I would write this as a template, and it would renew when the input voltage changed.
If the sensor has a starting voltage of say 0.2 volts and the full voltage is still 6 then your percent full would be
(3-0.2)/(6)*100 = 46.7%
I appreciate the reply. I am struggling with the basic fundamentals, I think. I need to create a Template Helper, correct? But yes, I want to convert the volts to percentage (so example, .71v is full = 100%)
I think Im confused on what goes where in the template sensor that I am creating. Do I need to select the unit of measurement, device class and state class in the selected drop down? I really appreciate all the help. Complete new to this.
I will assume you have this in a templates.yaml file by using a !include in configuration.yaml (template: !include templates.yaml). I am assuming that the full range is 0.71V and that the name of your voltage sensor is sensor.your_voltage_sensor (replace this with actual name).
has_value is testing for unknown or unavailable. If sensor has a value ,do the calculation, if not set to 0.
#--------------------------------------------------------------------------------------------------
# To Compute % from voltage
#--------------------------------------------------------------------------------------------------
- sensor:
- name: "Percent Full Tank Storage"
unique_id: "Percent Full Tank Storage"
state: >-
{% if has_value('sensor.your_voltage_sensor') %}
{{ (states('sensor.your_voltage_sensor') | float(0)) / 0.71 * 100 }}
{% else %}
0.000
{% endif %}
unit_of_measurement: "%"
Hope this helps.
Edit - correct state to states