Automation - re-send notification every X seconds

Hi,
I have a simple automation that notifies me when smart plug is switched on. That works great. Now I want it to send me repeated notification every 60s as long as that plug is on. I have tried changing the automation mode to restart but that made no difference - I just get one notification when the plug is switched on but nothing after that ( I will be hooking up 120dB siren to that plug to act as a basic burglar alarm for my shed )
My automation:

alias: PLUG - notification
description: ''
trigger:
  - platform: state
    entity_id: switch.plug10
    to: 'on'
action:
  - service: notify.mobile_app_my_iphone
    data:
      title: notification
      message: Plug is on
mode: single

I’m not sure how to approach this. Any suggestions?
Thanks

Well, one way would be to create an automation on a time based trigger for the notification, and have that automation be enabled/disabled when the swtich is toggled. That would be a bit more efficient for HA than having a condition in it saying the switch must be on.

Why did you not use an alert?

1 Like

What do you mean ?
How to use it ?
Where is it documented ?

Where nearly everything is documented :wink:

1 Like

yep - and that led me to this fantastic blueprint

I didn’t know there was an integration called alert.
The way you said, I thought it was some kind of optional parameter of “notify” integration.

Thanks

Trying to implement this but I am not getting notification… this is in my configuration.yaml file and both notifiers are tested working. Not getting any alerts. for now I am using a state of ‘off’ so I do not have to hold the button to on. So I trigger it to on get a notice from other automation but I would expect if this is working that 1 minute later I would get a notification from this alert. Thanks for the help. TIA

alert:
water_found:
name: Flooding detected
done_message: Flooding is clear
message: flooding detected
entity_id:
- binary_sensor.water_sensor_main_drain_water_leak
state: ‘off’
notifiers:
- gmail
- mobile_app_bphone11
repeat: 1

can_acknowledge: true

Please post it formatted. Otherwise, we can not see if the reason is perhaps a wrong yaml code.

image

image

Again. Please use formatted text. I directly gave you the toolbar button. No plain text, no screenshot of text.

First try

entity_id: input_boolean.water_sensor_main_drain_water_leak

Secondly, it will not trigger after one minute, but directly, when the condition is true and then every new minute again. If you want to avoid the first, use skip_first. See docs.

And then, what is the history of input_boolean.water_sensor_main_drain_water_leak? The alert will only switch on, if it changes from something else to off in your example. You should test this behavior manually with your input_boolean. And double-check, the status of the (generated) alert-entity alert.water_found.

BTW is there a alert.water_found entity and did you restart HA?

alert:
  water_found:
    name: Flooding detected
    done_message: Flooding is clear
    message: flooding detected
    entity_id:
      - binary_sensor.water_sensor_main_drain_water_leak
    state: 'off'
    notifiers: 
      - gmail
      - mobile_app_bphone11
    repeat: 1
#    can_acknowledge: true

very sorry did not realize what you where telling me… believe I have it right this time

input_boolean does not appear to come up on the list when I start entering it. Should it?

Yes so the way I have written the code is test the water sensor when it goes from the on to off state so that I am not listening to the beep beep beep while I wait for a minute (or more to go buy) testing to make sure it works … So I trigger a wet condition and other interfaces confirm that it has been triggered and then then I stop the device from thinking it is wet so it returns to off state which is when I would expect this to trigger this action and likely keep sending me out alerts for a long time (kinda of a dumb move but it would prove the point with out listening to beep beep beep beep… :slight_smile: ) Once working I would move the state to ‘on’ in the action

Hope that all made sense.

This code works for the control panel. Showing the binary_sensor… item works with on and off

      {% if states('binary_sensor.water_sensor_main_drain_water_leak') == 'on'
      %}
        mdi:water-circle
      {% else %}
        mdi:water-off
      {% endif %}

Thanks for all the help

Sorry, was a typo. I was talking about your binary_sensor.water_sensor_main_drain_water_leak

But coming back to my questions above. Is there the alert-entity available? And what is the value and history of that? And was ist the current value and the history of `binary_sensor.water_sensor_main_drain_water_leak?

And did you test with my suggestion above?

alert:
  water_found:
    name: Flooding detected
    done_message: Flooding is clear
    message: flooding detected
    entity_id: binary_sensor.water_sensor_main_drain_water_leak
    state: 'off'
    notifiers: 
      - gmail
      - mobile_app_bphone11
    repeat: 1

I don’t understand what you mean by this: Is there the alert-entity available? If I go to developer tools.>States->Entity and try and enter alert. nothing comes up if this is what you mean. Can’t get to history without understanding how to get to it.

For the water sensor - main drain this is the status of it (see attached) at 1:45 I put the entity_id: binary_sensor.water_sensor_main_drain_water_leak inline as suggested and reloaded the system. triggered water for which I get notification from other entities right away that water is detected but waiting for the notices to come in when the state went to off but no luck yet.

If the setup for the alert is working, there is a alert entity afterwards. In your case alert.water_found

If it is not there, it cannot work. Is the nothing in the log if you restart HA?

Did you try my suggestion above and restart HA? Really don’t get, why you are not trying suggestions. It is now the third time I’m mentioning the change in the entity_id row.

Thanks for your persistence (most people just walk away) Yup that was exactly it the alert was not loading into the system… and well that was the novice to HA in me… I had entered it into the configuratoin.yaml under the zigbee2mqtt drop down and not the one in the root directory.

But yes I was doing everything I could and understood that you documented sorry if I was not clear in my responses but ya I was doing everything.

Thanks for your help and persistence got it figured out now. As a relative newbie to HA really appreciate the help.

Found another error while checking the logs for you that will keep me busy for a little. It appears to work but I get errors (just love those ones).

Complains about this one:

TemplateError(‘ValueError: Template error: int got invalid input ‘unknown’ when rendering template ‘{{ states (‘sensor.water_mb_window_sill_battery’) | int / 2 }}’ but no default was specified’) while processing template ‘Template("{{ states (‘sensor.water_mb_window_sill_battery’) | int / 2 }}")’ for attribute ‘_attr_native_value’ in entity ‘sensor.battery_status_mb_sill’

5:06:03 PM – (ERROR) helpers/template_entity.py - message first occurred at 5:06:03 PM and shows up 4 times

Error while processing template: Template("{{ states (‘sensor.water_mb_window_sill_battery’) | int / 2 }}")

5:06:03 PM – (ERROR) helpers/template.py - message first occurred at 5:06:03 PM and shows up 4 times

But exact same line different sensor (same model… no complaints ).
{{ states (‘sensor.water_sensor_main_drain_battery’) | int / 2 }}

You’re welcome.

Regrading the errors. You should use default for filters ( here |int) wherever you can. Esp. as they are thowing errors, if there is no value and you don’t use them (new for some releases, before it returned 0 or input value or …).

So have a look here

and use e.g.

states (‘sensor.water_mb_window_sill_battery’) | int(default=0)

soem for floats, etc. etc.

This makes sense, I will review and work on it later… kinda indicates why I was not figuring it out that it did not have a valve… but weirdly the result works… Where it is being used is the Third Reality water sensors are now reporting to zigbee twice the power they have so 90 is reported as 180 and they did this because the values where getting a mess when they where going through certain devices… but left us out on a lurch that we can pickup the real value so I had to right an entity that held the value at half and so this happens on only some of there devices, depends on the firware level and they do not expose the firmware level to us to do the math with just have to do it manually for each of the devices… apparently they are going to have a chat with zigbee2mqtt to see what can be done to make it work right for them. Till then NewValue= OrgValue/2 but weird it comes back with no value but it still work and gauges are all reading correctly now.

Thanks again for you help its been awesome… wish I had a mentor in Ottawa I could just sit down with over beers and drain tons of knowledge from.

Have a great day.