Thankyou so much for this information. It helped so much! I have added this to my config and added the code into the templates.yaml. I have restarted and everything came back up. After I did this, Where do I go from here?
You will now have a sensor named sensor.percent_full_tank_storage which you can use in your gauge.
Thankyou so much for your time and your help. Its showing zero, which not sure why. But, this pushes me in the right direction.
Well shoot, now im seeing this in the error log.
TemplateError(‘UndefinedError: ‘state’ is undefined’) while processing template ‘Template<template=({% if has_value(‘sensor.shellyuni_4417931bdb79_adc’ ) %} {{ (state(‘sensor.shellyuni_4417931bdb79_adc’)|float) / 0.71 * 100 }} {% else %} 0.000 {% endif %}) renders=4>’ for attribute ‘_attr_native_value’ in entity 'sensor.percent_full_tank_storage
state should be states as in
(states('sensor.your_voltage_sensor')|float)
fat finger mistake
Thankyou so much! I appreciate the reply. Im still getting an error.
TemplateError(‘ValueError: Template error: float got invalid input ‘unknown’ when rendering template ‘{% if has_value(‘sensor.shellyuni_4417931bdb79_adc’) %} {{ (states(‘state.sensor.shellyuni_4417931bdb79_adc’)|float) / 0.70 * 100 }} {% else %} 0.000 {% endif %}’ but no default was specified’) while processing template ‘Template<template=({% if has_value(‘sensor.shellyuni_4417931bdb79_adc’) %} {{ (states(‘state.sensor.shellyuni_4417931bdb79_adc’)|float) / 0.70 * 100 }} {% else %} 0.000 {% endif %}) renders=4>’ for attribute ‘_attr_native_value’ in entity ‘sensor.percent_full_tank_storage’
I was able to resolve that portion of the error by using
|float(0))
Now, I am getting 0.0% again. Now I just need to figure out why Im seeing 0.0 even tho the volt is reporting 0.70.
{{ (states('sensor.shellyuni_4417931bdb79_adc') | float(0)) / 0.71 * 100 }}
if you wish to round to 1 decimal place
{{ ((states('sensor.shellyuni_4417931bdb79_adc') | float(0)) / 0.71 * 100 ) | round(1) }}
I really appreciate your help. This is what I have so far.
#--------------------------------------------------------------------------------------------------
# To Compute % from voltage
#--------------------------------------------------------------------------------------------------
- sensor:
- name: "Percent Full Tank Storage"
unit_of_measurement: "%"
unique_id: "Percent Full Tank Storage"
state: >-
{% if has_value('sensor.shellyuni_4417931bdb79_adc') %}
((states('sensor.shellyuni_4417931bdb79_adc') | float(0)) / 0.71 * 100 ) | round(1) }}
{% else %}
0.000
{% endif %}
Now getting the following error
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 644, in state
numerical_value = float(value) # type:ignore[arg-type]
You need the two curly braces in front
Just wanted to say thankyou for helping me resolve the issue!
Just paying back for others who have helped me. And you are very welcome!
I’m just in the middle of setting this up with our 30,000 L tank. I’ve bought one of these, the 5psi version and connected it up to a Shelly UNI and a 12v DC supply. The sensor I’ve screwed into a 20mm T-junction I have just at outlet pipe from the tank. No need to submerge it in the tank.
Just now its reading 1.12volts and the water level is 1.3m. I need to brush up on some maths now.
For $NZD20
https://a.aliexpress.com/_m0uSfLg
How are you guys visualizing and displaying your water levels?
Curious to see some dashboards.
Nothing fancy here. Where it says Water Tanks it links to another page where it just shows the Liters, uptime and voltage. I never look at it.
I’m curious,
Would one of these work?
Hello everyone. I have an ultrasonic sensor and a switch to turn pump on/off. I created an automation when distance is above 120cm ( the water tank is empty), the switch will be turn on and when distance is
below 20cm (the water tank is full), the switch will be turn off. Every thing work fine but there is an exception:
- Assume that the tank is full and automation is activated, the switch turn off. But someone turn switch on manually and the switch not turn off after that. I have to turn it off manully and when the water level is low, automation work back again
Sorry for my bad English. Can someone solve this problem. Thanks for your help
Hi Guys, im just embarking on this integration. We have a 5000L rain water tank in the backyard that i would like to monitor in my HA. What hardware should i purchase?
I’ve got a pressure sensor now arrived,
Question, it is outputting a 5V signal ! 0 - 4.5v output.
Do I need an ADC to use this sensor with ESP32?
Thanks