#how to add delay after initial trigger notification ?

1 messages · Page 1 of 1 (latest)

nova vessel
#

I'm trying to put a trigger together, that sends an email once the event happens and a subsequent email every {{ delay }} minutes later, as long as the tiggering event is active.

My current spec is as follows:

alias: Degree Minute is below -500
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.degree_minute
    below: -500
conditions: []
actions:
  - device_id: 1266358ed4d6399f1dabccb66e0e7615
    domain: mobile_app
    type: notify
    message: Degree Minute is below -500
  - device_id: c607151773a54d17af320fac9d16b532
    domain: mobile_app
    type: notify
    message: Degree Minute is below -500
  - repeat:
      until:
        - condition: state
          entity_id: automation.degree_minute_is_below_500
          state: "off"
      sequence:
        - action: notify.smtp
          metadata: {}
          data:
            message: >
              Degree minute is currently {{ states.sensor.degree_minute.state }}
              System state is: {{ states.sensor.hs1_status.state }}
              Primary flow temp: {{ states.sensor.hs1_primary_flow_temperature.state }}
              Current RPS: {{ states.sensor.hp1_a1_current_rps.state }}
              Brine pump: {{ states.binary_sensor.hp1_a1_brine_pump.state }}
            title: >-
              Critical - Degree minute {{ states.sensor.degree_minute.state }}
            target:
              - foo@example.com
sweet mango
# nova vessel I'm trying to put a trigger together, that sends an email once the event happens...

I did a similar thing for the oven being on as detected by a ct clamp meter to remind that the oven is still on every 30 minutes so ensure it does not get left on.

here was the approach i used. i feel like there is a probably a better solution but i didnt find it when i needed this to work 😛

first i have a binary sensor helper templated

{{ states('sensor.shellyem_34945477fccb_channel_2_power')|float > 15 }}

which shows on when power > 15 watts else off

then separately i have a templated sensor helper

{% if states('sensor.oven_on_off') == 'True' %}
  {{ ((now() - states.sensor.oven_on_off.last_changed).seconds /1800)|round(0,'floor') }}
{% else %}
  0
{% endif %}

this tells me how many 30 minute intervals have passed since it turned on.

I then automate on this value changing (filtering out if it reset (changed to 0)) also double checking the energy reading.

triggers:
  - trigger: state
    entity_id:
      - sensor.oven_on_30_min_intervals
    id: oven_on_every_30_mins
conditions:
  - condition: template
    value_template: "{{ states('sensor.oven_on_30_min_intervals')|int != 0 }}"
    alias: filter resetting trigger
  - condition: numeric_state
    entity_id: sensor.shellyem_34945477fccb_channel_2_power
    above: 15
#

another more basic solution is to just trigger an automation with a time trigger every x minutes then check the state as a condition. this means it will always run every x minutes but only do something if condition is passed. however this causes the issue of not knowing how long between the switch on trigger and time trigger. so the first reminder could be very quickly after initial trigger. i trieed this but a couple of "the oven is still on" notifications within a minute off turning the thing on was enough to change approach

steady mapleBOT
sweet mango
#

😮 look at this guy over here with their sensible solutions that means i am probably gunna rebuild that automation as soon as i get a moment...

nova vessel
#

I was hoping there would be a "delay" condition that I could put into the "repat an action until" loop

hazy plinth
#

Delay exits

sweet mango
nova vessel
#

The intent is not to have it long running, but if the ground source heating system goes into a fault, I would want to get a status email about it's state, every 30 minutes or so, where I can see the current values for eg. heating circuit and weather or not immersion heater is handling it, until I am able to get the issue fixed

sweet mango
# nova vessel The intent is not to have it long running, but if the ground source heating syst...

the issues with an automation that runs for a long time with a loop is if home assistant restarted for some reason the automation would stop running and wouldnt trigger again when HA came back up so it would stop.
or if for some reason the initial trigger fails then there may not eb a subsequent trigger.

you are better off having something that actually triggeers every x minutes. specially if its a critical thing.