Hello, I wanted to put this sensor, but it does not appear.
I don’t understand if I made a mistake. Thank you
Hello, I wanted to put this sensor, but it does not appear.
And if you go in your Development tools tab, can you find it?
Look what I can see when I search for it:
Curiously, there is nothing with “duree_ec….”
And very basic question but I must ask: Did you restart your HA after adding those lines in your configuration.yaml ?
Yes, I haven’t forgotten that.
Hello JayJay,
It seems your waterverbruik per keer sensor is based on my Duration of the last shower sensor.
That sensor is wrongly named, I created it in the beginning of the project with the help of @Petro in Home Assistant Discord #Template channel. I should have changed that name, but it’s a piece of the puzzle created along the project. That template sensor simply gives me a value that I use in an automation to trigger a boolean ON/OFF state based on that template sensor value.
Here is the automation that use this sensor:
alias: Douche / Eau principale (ON/OFF)
description: ""
trigger:
- platform: state
entity_id:
- sensor.duree_de_la_derniere_douche
id: Trigger-ON
from: "off"
- platform: state
entity_id:
- sensor.duree_de_la_derniere_douche
to: "off"
id: Trigger-OFF
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: Trigger-ON
sequence:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.eau_principale_on_off
- conditions:
- condition: trigger
id: Trigger-OFF
sequence:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.eau_principale_on_off
default: []
mode: single
Your waterverbruik per keer sensor states its value based on sensor.waterverbruik_in_liters. I am not sure what you are trying to do here because this template sensor will end up giving you an OFF value. It was intended to be used as a boolean.
Hello Patrice,
And does you YAML configuration check returns a green light?
I am not a YAML expert, but I always make a check. If there is a syntax mistake somewhere it can lead to that sensor not being created.
I don’t have any error that stands out. it’s green
Thank you so much. I will try and see what the results are. Your help is great. Thousand likes…
I transcribed my yaml like yours, I still have nothing in sensor (duree…)
I do not understand.
I’m bad.
The sensor can probably be installed outdoor, but make sure the electronics, connectors and the ESP board do not get moisture.
Seems good, give it a try!
I went back in Home Assistant Discord #Template channel and @RobC pointed me toward the #legacy-sensor-configuration-format
It seems like there is missing the first header “sensor:” to encapsulate that template sensor. In my configuration.yaml file the header “sensor:” was above because I had multiple template sensors below.
Here is the corrected syntax so you can give it a try.
sensor:
- platform: template
sensors:
duree_ecoulement_eau_principale:
friendly_name: Durée d'écoulement de l'eau principale
unit_of_measurement: "sec"
value_template: >
{% set t = this.state if states('input_boolean.eau_principale_on_off') == 'off' else now().timestamp() - states.input_boolean.eau_principale_on_off.last_changed.timestamp() %}
{{ t | round(2, 'common') }}
Let me know if it works.
Can you translate all the code into English please. I use English code. So there are some errors. Some sensor names are not displayed, thank you very much
Only the friendly_name and sensors name are in french in my code. The code itself remain the same whatever the language. If you need assistance with translation, use https://translate.google.ca/.
Hello, progress!
So I can see my sensors! Thanks a lot.
However
With this code, the last volume is well indicated.
But the last shower time remains disabled.
The link is not made between the sensors?
default_config:
- plateform: template
sensor:
duree_de_la_derniere_douche:
state: >
{% set current_liters = states('sensor.debit_d_eau_total_instantane') | float(0) %}
{% if current_liters > 0 %}
{{ this.state | float(0) + current_liters if this.state is defined else 0 }}
{% else %}
off
{% endif %}
sensor:
- platform: template
sensors:
duree_ecoulement_eau_principale:
friendly_name: Durée d'écoulement de l'eau principale
unit_of_measurement: "sec"
value_template: >
{% set t = this.state if states('input_boolean.eau_principale_on_off') == 'off' else now().timestamp() - states.input_boolean.eau_principale_on_off.last_changed.timestamp() %}
{{ t | round(2, 'common') }}
volume_derniere_utilisation:
friendly_name: Volume d'eau utilisé
unit_of_measurement: 'L'
value_template: >
{{ (states('sensor.utilisation_d_eau_total') | float - states('input_number.volume_de_depart_debit') | float) | round(2, 'common') }}
cout_de_la_derniere_douche:
friendly_name: Coût de la dernière douche
unit_of_measurement: '$'
value_template: >
{{ (states('sensor.volume_derniere_utilisation') | float * 0.01 | float) | round(2, 'common') }}
template:
- binary_sensor:
- name: Débit d'eau (ON/OFF)
state: "{{ states('sensor.debit_d_eau_total_instantane') | float(0) > 0 }}"
Thank you again for all your time, I hope it helps a lot of people too.
Hello Patrice!
Great news! I think this one will be easy to solve.
For the duree_de_la_derniere_douche sensor, it’s a template, you must put it under the template header as follow.
template:
- sensor:
- name: Débit d'eau instantané ou OFF
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 %}
Also, I recommend changing the name of that sensor. As I said previously to JayJay in Post #183, that sensor is wrongly named, I created it in the beginning of the project with the help of @Petro in Home Assistant Discord #Template channel. I should have changed that name and I just did yesterday. It was an early piece of the puzzle created along the project. I renamed that sensor: “Débit d’eau instantané ou OFF” (Instant water debit or OFF). What this sensor is showing is either the active flow rate or an OFF state. After second thought, maybe the boolean inside HA could simply be triggered when the flow rate is 0.00L/min, but I preferred to have an OFF state to trigger the boolean inside Home assistant. Whatever you decide, feel free to rename that one and change the sensor that triggers the automation for your boolean Débit d’eau ON/OFF.
Let me know if it works for you
Is it better this way?
But the code does not change anything, duree_ecoulement_eau_principale remains deactivated.
Thank you
default_config:
sensor:
- platform: template
sensors:
duree_ecoulement_eau_principale:
friendly_name: Durée d'écoulement de l'eau principale
unit_of_measurement: "sec"
value_template: >
{% set t = this.state if states('input_boolean.eau_principale_on_off') == 'off' else now().timestamp() - states.input_boolean.eau_principale_on_off.last_changed.timestamp() %}
{{ t | round(2, 'common') }}
volume_derniere_utilisation:
friendly_name: Volume d'eau utilisé
unit_of_measurement: 'L'
value_template: >
{{ (states('sensor.utilisation_d_eau_total') | float - states('input_number.volume_de_depart_debit') | float) | round(2, 'common') }}
cout_de_la_derniere_douche:
friendly_name: Coût de la dernière douche
unit_of_measurement: '$'
value_template: >
{{ (states('sensor.volume_derniere_utilisation') | float * 0.01 | float) | round(2, 'common') }}
template:
- binary_sensor:
- name: Débit d'eau (ON/OFF)
state: "{{ states('sensor.debit_d_eau_total_instantane') | float(0) > 0 }}"
- sensor:
- name: Débit d'eau instantané ou OFF
state: >
{% set current_liters = states('sensor.debit_d_eau_total_instantane') | float(0) %}
{% if current_liters > 0 %}
{{ this.state | float(0) + current_liters if this.state is defined else 0 }}
{% else %}
off
{% endif %}
As we discussed previously, the value being displayed at Durée de la dernière utilisation (Duration of the last water usage) comes from sensor.duree_ecoulement_eau_principale
The value being displayed at Durée de la dernière utilisation (Duration of the last water usage) comes from sensor.duree_ecoulement_eau_principale, and you selected Debit d’eau (ON/OFF)
Did you change the sensor from where this value is displayed?