Shower Time Detection - Light Flash Automation

In need of some help te create an automation (or in node-red) to detect waterusage when bathroomlight is on and humidity goes up.

I have 3 entities:
current water consumption: sensor.water_consumptie_nu
current bathroom humidity: sensor.esp32_duco_01_sensor_1_humidity
current light status: switch.relay_1_relay

I want to create an automation to:
flash the light 2 times quickly when:
water consumption (with some possible intervals) is 5 minutes >0
and humidity is rising during the 5 minutes
and light is on.

Where do I start? → I need some automation advice.

Actions:

Triggers AND Conditions (one of each for all three):

The first two are numeric_state triggers and conditions, the last one is a state trigger and condition.

By including each as a trigger and a condition you achieve the AND logic you want. The automation will trigger on any of them but all must be true to pass the conditions. Which ever two trigger first will fail the third condition but the last to trigger will pass as by then all three conditions are true.

1 Like

What should be in the numeric state trigger for the light?

Like this?

And for conditions? On for 5 minutes?

You can’t use a for tile in the numeric conditions, only the triggers.

Sorry, I do not understand you. I did trigger state and the selected the entity…?

The last one, you meant light, correct?

Which of these three is the last one?

Hint: it’s not the first two.

How do I handle that? NowI think the water usage should be 5 mins more than 0, but what if the shower isstopped for a while for doing shampoo? It should count "5 minutes’ from start during high humidity and lights on…

Did that…

  • Add trigger
  • Selected state
    It is the screenshot 🤷

So why did you ask?

I’m done. Good luck.

What did I do wrong to you?

Being a moderator, you could at least explain why you behave like this, what did I do wrong?

I am unable to help you.

Some more information. I would like to acheive to flash the light if 5 minutes (example) of water have been used during the time the light was on and the humidity is raised above 75%.

This is an example of a shower session :slight_smile: :slight_smile:

So 5 minutes of water usage during 6 or 7 minutes under the shower. in total and then flash.

This is what I have now:

I think it now works " kinda" but only when 5 minutes of consecutive water is used. And I am not sure if it is now exactly 5 minutes (will time).

Thanks!

Try to imagine the “Flow” of each “Trigger”, and whether the " 3 triggers" is AND or OR …
Then go on to imagine whether your Automation will abort or continue through the “conditions” and when it will “abort” and/or “Restart” ( not counting in state-changes in Spots and it’s attributes )

🤷🙉 sorry, my imagination leaves me behind

So start “simple” i.e “1 trigger” , so AND/OR is not involved in the equation, left is your “Conditions” , and as you have a “sensor” involved which measure consumption over time, thou you want only the “accumulated” consumption, you might need another template-sensor.

i.e. If you measure your Oven, it used i.e 1000W during the day(or within an hour), thou you only used it twice, ones in the morning, ones in the evening(or within an hour) … however you did turn it off in between, so to find out how much time you actually had it on, you have to subtract the “time-on” from from total-time(1 day/ 1 hour) , a counter might accomplice this, or template

I find quite uncertain what/why you want this particular automation for, with it’s particular conditions/triggers, but obviously you have your “shower-session-entity” ( 4 - 3 == total-water-minutes-been used ) … (not counting in humidity-level, do to uncertain circumstances, and neither “Spots and it’s attributes changes”)

PS: my “shower-sessions” begins before humidity reach 75%, in fact my fan starts to evacuate at this point ( and might even, hopefully, either keep it under 75% or reduce under 75% from “time-to time” during the “Shower-session”), and who knows some attributes in my “light-entity” might change during the session, if it’s on at all … i don’t know if you can “follow” me here ?, i.e how many minutes did my water run through the pipes ? how many minutes do i have to subtract, from my “shower-session” because the humidity was under 75% (spite the water was running) , even worse, the power-measuring, or “instability” of my light-entity(or some atribute-update/state-changes turned out to give me no result at all ( or 10 “Showers-sessions” within half an hour )

I have tried a lot, but it’s not as reliable as I want, so I am going to try the node-red route:

Good Luck , although i wonder why you got the idea of trying your luck with Node-Red, when you don’t understand how your entities work, and that a “trigger” is what suppose to start your automation

As i said start simple, until you know( or that way you know ) what goes wrong
I.E 1 trigger + 1 Condition , then add successfully 1 by 1 … or you’ll never learn how it works and how your entities work, and whether you need a template-sensor involved instead of i.e “Current Values”
Anyhow you might still ending up with an automation that flashes your light “repeatedly” during your shower-session, the way you want it to work ( True i do assume this do to my own shower-habits, seldom under 30min long, could be 5 times flashing then … for what ever reason )
PS: I assume also that your Water-Meter only is connected to your Shower-Pipe

I am now going to try this…

sensor

  - platform: template
    sensors:
      accumulated_water_usage_5min:
        friendly_name: "Accumulated Water Usage (5 min)"
        value_template: >
          {% set window_start = now() - timedelta(minutes=5) %}
          {% set water_consumption = states('sensor.water_consumptie_nu') %}
          {% set events = state_changes['sensor.water_consumptie_nu'] %}
          {% set accumulated_usage = 0 %}
          {% for event in events %}
            {% if event.state == 'unknown' %}
              {% set accumulated_usage = 0 %}
            {% elif event.state | float > 0 and event.last_changed > window_start %}
              {% set accumulated_usage = accumulated_usage + (event.state | float) %}
            {% endif %}
          {% endfor %}
          {{ accumulated_usage | round(2) }}

Automation

- id: shower_timer_notification
  alias: Shower Timer Notification
  trigger:
    platform: numeric_state
    entity_id: sensor.accumulated_water_usage_5min
    above: 5  # Adjust this threshold as needed
  condition:
    condition: and
    conditions:
      - condition: numeric_state
        entity_id: sensor.esp32_duco_01_sensor_1_humidity
        above: 75
      - condition: state
        entity_id: switch.relay_1_relay
        state: 'on'
  action:
    - service: notify.mobile_app_sm_s908b
      data:
        message: "Shower timer: Accumulated water usage over 5 min exceeded."

but although water flows I see unavailable…
image

Im not particular good in templates, but wont last_changed always be “before now” ? , meaning less

Edit: And again, i think other people(who might be interested in helping “solving” your mystery) would be interested in knowing how/what your sensor.water_consumptie_nu provide , i.e screenshot from dev_tools-states, int/string, or are you addressing attribute, last_changed ?
And does your water-meter provide/update amount(Liters), every minute, or hour, i believe there is a huge variation of what/how a water-meter “report”