@donparlor you are most welcome. If you look elsewhere in this thread, I also described how you can use Home Assistant to log the total volume of water per day/week/month/year, which is very useful for long term record keeping, if you are into that sort of data analysis.
I would like to join @Pensee in asking to see your YAML if you don’t mind; it is always very interesting to me to see how other people solve problems. I learn most that way.
I should also mention that to calculate the volume of the last water usage, I also created an input_number value that is triggered when water flow is detected
Before creating the automation storing the initial volume of water when flow is detected, you need to create a binary_sensor that will be used to trigger that action of storing the initial value.
Here is the code for the binary sensor named binary_sensor.debit_d_eau_on_off (in configuration.yaml)
I got a problem getting this to work! What is it I do wrong. I had to cut up my config file with mqtt changed this last update so I used !include_dir_merge_list.
This i did for the template sensors too in this example, but now the sensors are not being seen in HA what I have or done is this!?
in configuration i put: template: !include_dir_merge_list templates/
I made a directory named “templates” in my config dir
then I grabbed donparlor his examples only way for me to get things running>>>>
for instance.
template:
- sensor:
- name: Durée de la dernière douche
state: >
{% set current_liters = states('sensor.debit_d_eau_instantane') | float(0) %}
{% if current_liters > 0 %}
{{ this.state | float(0) + current_liters if this.state is defined else 0 }}
{% else %}
off
{% endif %}
and i made a yaml file in my templates dir named “water verbruik laatst”
then I rewrote the code to get no errors into this
sensor:
- name: waterverbruik per keer
unique_id: '8775758200'
state: >
{% set current_liters = states('sensor.waterverbruik_in_liters') | float(0) %}
{% if current_liters > 0 %}
{{ this.state | float(0) + current_liters if this.state is defined else 0 }}
{% else %}
off
{% endif %}
But that was it, in my states I do not find the sensors back, HA does not see them. SO please where did I make the error, what do I not see?!
This boolean tells Home Assistant that water flow is ON or OFF. If you need help creating an Input Boolean, look at this tutorial: Input Boolean - Home Assistant
Durée de la dernière utilisation (Duration of the last water usage) refers to that boolean so it can calculate time properly. Let me know if you created that boolean, I’ll dig further into your code after you answered. I need some sleep here, it’s 2h52 AM!
Hello Vincent. I am happy to have a return from you, I hope the night was good , and it is normal to continue our exchanges in English for the community.
I have created both inputs. Maybe they are misconfigured ?
Sorry for the delay, very busy this week. I think I forgot to mention about a binary sensor in my YAML file that I didn’t mention. This template binary sensor triggers the automation which input volume, its name is binary_sensor.debit_d_eau_on_off. This is probably why sensor.duree_de_la_derniere_douche with friendly name Durée de la dernière utilisation (Duration of the last water usage) is not working.
Here is the code for the binary sensor named binary_sensor.debit_d_eau_on_off (in configuration.yaml)
Hello, no worries, thank you for taking the time to answer me today.
I added the binary_sensor.
I have the information that appears but only indicates the enabled/disabled state.
I don’t have the time that appears.
Here is a screenshot.
But basically, this setup can work with most if not any flow sensor. The only thing that change is the first sensor in ESPHome that calculate the rotation of the flow sensor.
sensor:
- platform: pulse_counter
pin:
number: 4 #Change according to the pin where you connected your flow sensor on ESP32 board
mode:
input: true
pullup: true
unit_of_measurement: 'L/min'
accuracy_decimals: 2
id: water_usage
name: "Débit d'eau instantané" #Choose name according to your display language
update_interval: 5s
filters:
- lambda: return (x / 450); # 450 = 7,5 * 60