#SOLVED - Weird behavior for trigger ON for 5 minutes

1 messages · Page 1 of 1 (latest)

cedar nacelle
#

Hey all I have this trigger:

    - platform: state
      entity_id: binary_sensor.septic_pump
      to: "on"
      for: "00:05:00"  # Ensures the pump must be ON for at least 5 minutes
    - platform: state
      entity_id: binary_sensor.septic_pump
      to: "off"  # Trigger when the pump turns OFF```

but the problem is the binary sensor isn't on for 5 minutes before it is notifying me of the pump having ran for 5 minutes?
frail kestrel
#

Please post the full code of your automation.

gleaming breach
#

I have not tried adding comments inline like that. I'm not sure that is valid.
I know some places they are not allowed.

lucid ether
#

And what does the trace of the thing it's controlling look like?

cedar nacelle
#
# SEPTIC PUMP RUNNING TOO LONG TRACKING                #
#########################################################
- id: "septic_pump_running_too_long"
  alias: "Septic Pump Running Too Long Tracking"
  description: "Tracks when the septic pump runs for 5 minutes or more."
  trigger:
    - platform: state
      entity_id: binary_sensor.septic_pump
      to: "on"
      for: "00:05:00"  # Triggers only if ON for 5 minutes
  action:
    - variables:
        timestamp: "{{ now().strftime('%B %d, %I:%M %p') }}"
        alert_message: "{{ timestamp }} - ⚠️ Septic Pump Alert: The septic pump has been running for over 5 minutes!"

    - service: notify.home_assistant_alerts
      data_template:
        message: "{{ alert_message }}"
        target: "XXXXXXX"

    - service: notify.alexas
      data:
        title: "Septic Pump Alert"
        message: "The septic pump has been running for over 5 minutes. Please check it."

    - service: notify.pushover
      data:
        title: "⚠️ Septic Pump Alert"
        message: "The septic pump has been running for over 5 minutes. Check the septic system immediately!"

    - service: notify.gmail
      data:
        title: "⚠️ Septic Pump Alert"
        message: "The septic pump has been running for over 5 minutes! Please check the septic system immediately."
  mode: single```
#

it is weird because I have undoubtedly had automations that use "FOR" in the past

cedar nacelle
lucid ether
#

So you got the notifications despite it only being on for 4 and a bit mins each time?

#

Are you sure it wasn't the state off trigger?

#

Though that seems to have gone from the full automation

cedar nacelle
#

I get it when it immediately turns on i believe

#

I am wondering if its acting like this because its not a switch but a binary_Sensor?

#

thats the only thing that is "fishy"

lucid ether
#

shouldn't be an issue with that, do you have a trace? from when it went off?

cedar nacelle
#

i don't have a trace - not terribly familiar with how to do that

lucid ether
#

Go into the automation, top right corner where it has the dots

#

Select traces and you can see the last.. 5 times the automation has run, along with things like which trigger etc

cedar nacelle
#

Septic Pump Running Too Long Alert
No traces found

#

I am using files within directories to store my automations

#

I have several hundred I bet

#

someone else said they tested this with a binary-sensor and saw the same behavior?

lucid ether
#

So the automation has never run. What is the issue?

cedar nacelle
#

no thats impossible

#

unless its because I modified it to no longer have the comment in the same line?

cedar nacelle
#

someone took my code and changed the entity to be one of his own and had the same experience?

gleaming breach
#

I was wondering. That thing in the beginning said something ran less than 5 minutes, and you have a 5 minute delay so it shouldn't have triggered was my first thought, but wasn't certain.
Traces will stick around for a while, you should see old ones.

lucid ether
#

I just ran this

triggers:
  - trigger: state
    entity_id:
      - binary_sensor.test_rs_latch
    to: "on"
    for:
      minutes: 5
actions:
  - action: persistent_notification.create
    metadata: {}
    data:
      message: On for 5 mins
mode: single

And it works exactly as expected (specifying minutes rather than a HH:MM:SS string is valid and equivalent) so the only thing that could reasonably be causing you issues are all those comments. Delete them

cedar nacelle
#

that didn't fix it

#

I changed it and the pump just kicked on

#
    - platform: state
      entity_id: binary_sensor.septic_pump
      to: "on"
      for:  
        minutes: 5```
#

still no traces - not sure how that works but if its written in yaml and part of an include file I don't think I get those features?

lucid ether
#

The pump kicked on, but did you get any notifications?

#

You get traces from included automations

#

The only reason you would not have traces is if the automation hasn't run, which would be correct if the pump hasn't run for 5 minutes to trigger it

cedar nacelle
#

ok listen, without a doubt this automation has ran

#

without a doubt if I am in the right place to look - there is no traces

lucid ether
#

What does it say in the automation view under "last triggered"

#

Because I have just checked and it works fine for me

cedar nacelle
#

is your automation in file within an included directory or did you do it with the GUI?

lucid ether
#

As you might be able to tell from the 2nd screenshot, it's included. Lives in /automations/

cedar nacelle
# lucid ether

I would love to know where this first image is within Home Assistant

#

this is an impossibility

cedar nacelle
#

ill check it

#
  alias: "Septic Pump Running Too Long Tracking"
  description: "Tracks when the septic pump runs for 5 minutes or more."```
#

they have different names?!

#

but there isn't another one showing?!

gleaming breach
#

upper right is trace.

cedar nacelle
#

yeah I've done that

#

so im confused theres nothing there

#

nothing that looks like a flowchart

#

do I have to add traces?

lucid ether
#

No

cedar nacelle
#

I can't see the flow chart

#

yueah

#

something is awry

lucid ether
#

They don't exist for the ones that have never run

gleaming breach
#

The automation has to run. your's has not run.

cedar nacelle
#

and thats why I am confused because if you see my automation name

#

it doesn't match

lucid ether
#

Reloaded the configuration since changing the name? Or restarted

cedar nacelle
#

this is when it turns off

#

so im not complete bad at this 😉

cedar nacelle
#

again confused I might have restarted but before the off? I don't think so

#

is it based on alias name?

#

because theyre in the same file?

#

thats what I was trying to demonstate

gleaming breach
#

Tell us in words what do you want to happen here. What sequence of things happwning starting with the the pump is sitting there waiting for something to happen.

cedar nacelle
#

my apologies

#

you are 100% right

#

you can forget me now 🙂

#
# SEPTIC PUMP RUNNING TOO LONG ALERT                   #
#########################################################
septic_pump_alert:
  name: Septic Pump Running Too Long
  entity_id: binary_sensor.septic_pump
  state: "on"
  repeat:
    - 10
    - 15
    - 20
    - 25
    - 30
    - 35
    - 40
    - 60
    - 90
  title: "⚠️ Septic Pump Warning"
  message: "The septic pump has been running for too long! Check the septic system."
  done_message: "Septic pump has turned off."
  notifiers:
    - pushover
    - alexas
    - gmail```
#

this was causing the problem

#

you were 100% correct

#

my apologies and now we know why it didn't show up when I was looking 🙂