Alerts don't alert after first time

I have the following alert setup in my alerts.yaml config:

  garage_door:
    name: Garage is open
    message: Garage door is open
    done_message: Garage is closed
    entity_id: binary_sensor.garage_door_contact
    state: 'on'
    repeat:
      - 5
      - 5
      - 15
      - 60
    can_acknowledge: true
    skip_first: false
    notifiers:
      - html_notifier
      - notify

With this configuration I get a notification when the door opens (note the skip_first: false), and one when it closes. However, I never get a second notification. I let the switch sit “on” for over 20 minutes, which should be enough to get at least 3 notifications, but I never received a second one. If I switch the skip_first: to false I never get any notification at all. Any recommendations or help is appreciated. Does the component not like a repeated value in the list of times? Or am I missing something else?

Tested and works for me with this simple example:

# Input Boolean
input_boolean:
  alert_test:
    initial: 'off'

# Notify
notify:
  - name: test_file_notify
    platform: file
    filename: /config/cmd/file_notify.txt
    timestamp: true

# Alert
alert:
  alert_test:
    name: Alert Test fired
    done_message: Alert test closed
    entity_id: input_boolean.alert_test
    state: 'on'
    repeat:
      - 2
      - 2
      - 5
      - 10
    can_acknowledge: true
    skip_first: false
    notifiers:
      - test_file_notify

The output file_notify.txt:

Home Assistant notifications (Log started: 2019-05-28T12:53:03.210960+00:00)
--------------------------------------------------------------------------------
2019-05-28T12:53:15.441952+00:00 Alert Test fired
2019-05-28T12:55:16.007821+00:00 Alert Test fired
2019-05-28T12:57:17.014221+00:00 Alert Test fired
2019-05-28T13:02:18.007351+00:00 Alert Test fired
2019-05-28T13:12:19.007176+00:00 Alert Test fired
2019-05-28T13:19:22.525318+00:00 Alert test closed

Can you confirm that the two notifiers work?

Yes, the notifiers work, since I get the first and last notifications.

I have the same problem. I opened an issue for it that was eventually closed with nothing being done to fix it.

ETA: This worked for me when I was running hass.io on a pi. It has not worked for me since I switched to a NUC running Home Assistant as a docker container (or whatever the terminology is for docker).

I just tried @VDRainer’s test config on my system, a NUC Hassio image.

It works as expected.

Home Assistant notifications (Log started: 2019-05-28T23:42:42.851088+00:00)
--------------------------------------------------------------------------------
2019-05-28T23:42:42.851133+00:00 Alert Test fired
2019-05-28T23:44:43.012519+00:00 Alert Test fired

I can confirm that VDRainer’s test also works on my system (0.91 docker).

Home Assistant notifications (Log started: 2019-05-29T01:43:02.674511+00:00)
--------------------------------------------------------------------------------
2019-05-29T01:43:02.674557+00:00 Alert Test fired
2019-05-29T01:45:03.004171+00:00 Alert Test fired
2019-05-29T01:47:04.004090+00:00 Alert Test fired
2019-05-29T01:52:05.007869+00:00 Alert Test fired
2019-05-29T02:02:06.007500+00:00 Alert Test fired

I’m running 0.93.1 on a raspberry pi with Hass.io.

I setup a file notifier to make sure my notifications weren’t just being inconsistently consistent in not delivering the middle notifications, but that confirmed.

Has anyone on this thread tested with an binary_sensor instead of an input_boolean? I’m going to test now with an input_boolean and see if that makes a difference.

I think I found the problem. I think my raspberry pi with hass.io installed was not set to the correct time zone, but my home assistant install was set to the correct time zone. I suspect the mismatch in times is the problem. Will try to fix it and report back.

1 Like

I’m at a complete loss now. I’ve tried restarting several times with different configurations of timezone in the host docker container to no avail. I’ve used an input_binary instead of a binary_sensor. I don’t know what else to try here. Any other recommendations or troubleshooting tips would be much appreciated. I’m not sure where to look for logs to debug something like this.

For reference, here are the relevant parts of my config now:
alerts.yaml:

  alert_test:
    name: Alert Test fired
    done_message: Alert test closed
    entity_id: input_boolean.alert_test
    state: 'on'
    repeat:
      - 2
      - 2
      - 5
      - 10
    can_acknowledge: true
    skip_first: false
    notifiers:
      - notify_log

configuration.yaml:

# Test Alert
input_boolean:
  alert_test:
    name: Test Alert

notify:
  - name: notify_log
    platform: file
    filename: /config/cmd/file_notify.txt
    timestamp: true

alert: !include alerts.yaml

and here’s some shell history showing the problem:

âžś  /config cat cmd/file_notify.txt
Home Assistant notifications (Log started: 2019-05-29T23:42:31.857379+00:00)
--------------------------------------------------------------------------------
2019-05-29T23:42:31.857510+00:00 Alert Test fired
âžś  /config date -u
Wed May 29 23:49:59 UTC 2019
âžś  /config cat cmd/file_notify.txt
Home Assistant notifications (Log started: 2019-05-29T23:42:31.857379+00:00)
--------------------------------------------------------------------------------
2019-05-29T23:42:31.857510+00:00 Alert Test fired
2019-05-29T23:50:15.994440+00:00 Alert test closed

I don’t see the problem in the history (too much wine maybe :upside_down_face:) at the moment.

It’s configured to send alerts at intervals of 2 minutes, but no alerts are sent except the first and last even though the device is “on” for 8 minutes. Here’s just the output in the notifier log file (note the timestamps)

Home Assistant notifications (Log started: 2019-05-29T23:42:31.857379+00:00)
--------------------------------------------------------------------------------
2019-05-29T23:42:31.857510+00:00 Alert Test fired
2019-05-29T23:50:15.994440+00:00 Alert test closed

I managed to get some non-first time firings, but they seem quite random and I’m not sure how to interpret them.

âžś  /config cat cmd/file_notify.txt.test
Home Assistant notifications (Log started: 2019-05-29T23:42:31.857379+00:00)
--------------------------------------------------------------------------------
2019-05-29T23:42:31.857510+00:00 Alert Test fired
2019-05-29T23:50:15.994440+00:00 Alert test closed
2019-05-29T23:57:55.444635+00:00 Alert Test fired
2019-05-30T00:49:20.652529+00:00 Alert Test fired
2019-05-30T01:01:17.045188+00:00 Alert Test fired
2019-05-30T01:14:08.751467+00:00 Alert Test fired
2019-05-30T03:57:21.893592+00:00 Alert Test fired
2019-05-30T03:59:04.907374+00:00 Alert test closed
âžś  /config

At first after looking at the file that I renamed to file_notify.txt.test below, I thought maybe it was a timezone issue after all, since the alerts started after nearly an hour (though actually 52 minutes). However, after moving that file, setting the config to just a single

    repeat:
      - 2

I get a single non-first notification after over two hours (and that notification came 1h4m6s after the initial event.

âžś  /config cat cmd/file_notify.txt
Home Assistant notifications (Log started: 2019-05-30T04:01:59.710075+00:00)
--------------------------------------------------------------------------------
2019-05-30T04:01:59.710176+00:00 Alert Test fired
2019-05-30T05:06:05.752723+00:00 Alert Test fired
âžś  /config date -u
Thu May 30 06:03:10 UTC 2019

I’ve left my test alert open for over a day now, and I think I’ve found a pattern (though it’s not terribly consistent, the inconsistency maybe due to my messing with the system, restarts, etc).

The alert is still configured to fire every 2 minutes. However, it is firing every 7 hours and 2 minutes. My time zone is Pacific, which is currently 7 hours behind GMT. My hypothesis is that the Alert system is somehow using the PT when it sets the “next fire time” but using the GMT time when it evaluates. Unfortunately, I’m still unsure how to fix this…

2019-05-30T04:01:59.710176+00:00 Alert Test fired
2019-05-30T05:06:05.752723+00:00 Alert Test fired
2019-05-30T12:08:06.024880+00:00 Alert Test fired
2019-05-30T19:10:07.025693+00:00 Alert Test fired
2019-05-31T02:12:08.032596+00:00 Alert Test fired
2019-05-31T09:14:09.029256+00:00 Alert Test fired
2019-05-31T16:16:10.027057+00:00 Alert Test fired
2019-05-31T17:30:15.733670+00:00 Alert Test fired
âžś  /config date -u
Fri May 31 18:03:27 UTC 2019
âžś  /config date
Fri May 31 11:05:25 PDT 2019

Thanks to some troubleshooting from another thread:

I confirmed it was a time zone issue. I was able to change the timezone in my config.yaml and now my timed alerts are firing every 2 minutes as expected instead of every 7 hours and 2 minutes.

I’d much rather be able to actually use the time zone I’m in, but at least I have a work around for now.

1 Like

So you set HA’s time zone config to UTC, just to get it to work? Yeah, that doesn’t sound right to me. But I don’t use hassio and have no idea how to get the environment’s time zone setting to be the correct local time zone (or why it wouldn’t be that way in the first place.)

Yes, setting my timezone in config.yaml to UTC fixed the issue. I changed the time zone and rebooted around 19:05 (UTC), and here are the logs from my test alert:

âžś  /config cat cmd/file_notify.txt | grep "Alert Test"
2019-05-30T04:01:59.710176+00:00 Alert Test fired
2019-05-30T05:06:05.752723+00:00 Alert Test fired
2019-05-30T12:08:06.024880+00:00 Alert Test fired
2019-05-30T19:10:07.025693+00:00 Alert Test fired
2019-05-31T02:12:08.032596+00:00 Alert Test fired
2019-05-31T09:14:09.029256+00:00 Alert Test fired
2019-05-31T16:16:10.027057+00:00 Alert Test fired
2019-05-31T17:30:15.733670+00:00 Alert Test fired
2019-05-31T19:04:54.898722+00:00 Alert Test fired
2019-05-31T19:10:02.458415+00:00 Alert Test fired
2019-05-31T19:12:03.027362+00:00 Alert Test fired
2019-05-31T19:14:04.020062+00:00 Alert Test fired
2019-05-31T19:16:05.031943+00:00 Alert Test fired
2019-05-31T19:18:06.023503+00:00 Alert Test fired
2019-05-31T19:20:07.024598+00:00 Alert Test fired
2019-05-31T19:22:08.031380+00:00 Alert Test fired
2019-05-31T19:24:09.031245+00:00 Alert Test fired
2019-05-31T19:26:10.020971+00:00 Alert Test fired
2019-05-31T19:28:11.034064+00:00 Alert Test fired
2019-05-31T19:30:12.019890+00:00 Alert Test fired
2019-05-31T19:32:13.039630+00:00 Alert Test fired
2019-05-31T19:34:14.023054+00:00 Alert Test fired

It may have fixed it, but I would hesitate to call it a solution. Setting your timezone to UTC (as opposed to your actual timezone) has system-wide ramifications. If you enter this {{ now() }} into the Template Editor, on my system it reports the local date and time, on your system it won’t be local but UTC.

Set your home assistant timezone config back to your local timezone before running the next update.

I had this issue (affecting a different component) and updating caused the system timezone to set to the HA timezone.

You can also do this using the community SSH addon with protection mode off. See Time probelms

That worked! Thanks tom_l!