Notify.home_assistant messages delayed by hours even after HA server powered down - mystery

This is truly a mystery to me. I have an automation that sends a text message to both my spouses phone and mine (using notify.home_assistant to our cell numbers) when it’s time for our kids devices to shut down at night. So, at 30 minutes before shutdown there’s a message, then at 10 minutes, then 5, then 1… then at shutoff; that’s 5 messages in the half hour leading up to shutoff time, which is 8:30 PM.

But, I was getting recurring message throughout the night, after 8:30, even though the automation wasn’t being triggered. So, I disabled the automation, but they continued. So, I unplugged the Raspberry Pi running HA, and… they still are coming. They come to both my phone and my wife’s. I don’t have any other HA instances running on any other servers in the house.

Does anyone have an explanation for this?

The main thing I’d be expecting here would be that you’ve got a queue of messages backed up at whatever service is sending those SMS messages.

2 Likes

This issue still comes up from time to time.

All through the night last night and all day today, I’ve been getting SMS messages via notify.home. They come every 5-10 minutes and they originate from my automations. But, they come even after I power down the raspberry pi running HA and unplug my modem and router. Attached is a screenshot from my iPhone.

@Tinkerer suggested the problem was a backed-up queue at the SMS service. If my cellular carrier is Verizon, is that what he’s suggesting?

Can anyone think of a solution for this?

Could you include the time in the message sent by HA? Then you could compare it with the time the message was received.

1 Like

@Stiltjack
When I swipe left on the messages, I can see the times next to each message (see screenshot). I think those are the times they are received. Could you point me in the right direction to find when they were sent? In that last message (Kitchen door locked…) - that automation hasn’t actually been triggered for 9 hours.

I’m a complete beginner at this, but something like:

{{ as_timestamp(now()) | timestamp_custom('%I:%M%p', true) }}

I forget where I copied this from… :grinning:

Alternatively, you could create an entry in the log:

    - service: logbook.log
      data:
        name: Fridge battery low
        message: SMS notification sent - Wireless tag battery in fridge is low.
1 Like

The most recent message was received 1 minute ago and triggered / sent 17 hours ago. The messages keep coming and coming; it’s incessant and I can’t find a way to stop it!

It sounds like they’re buffered somewhere at your mobile phone provider - there’s nothing you can do at this point.

What you may want to do is:

  1. Add a timestamp to future notifications so you can see when they were sent
  2. Switch to some other method of notification (eg Telegram, Signal, Discord) that can handle the volume of notifications you’re sending
  3. Consider sending less notifications
1 Like

@Tinkerer
Thanks for these recs. I’ve added timestamps to the scripts using notify.home_assistant and will see how that goes. Will also probably transition to using Pushover as a more definitive solution. Fewer notifications is a last resort option… love me notifications :crazy_face:

1 Like

FYI, SMS messaging works like this*:

SMS messages are placed in a queue at your phone network provider. Message delivery is attempted at the next available opportunity. If that fails a back-off time is implemented, typically 5 minutes. Then delivery is attempted again. This repeats with the back-off time getting larger. There is a configurable limit to the number of attempts. If still undelivered after the maximum number of attempts the message stays in the queue waiting for your phone to contact the network at which point delivery is attempted again. This can occur when you re-enter a coverage area or when you turn your phone on.

The queue is a first in first out queue of limited size, so if more messages are queued than the queue can hold the oldest messages get dropped. Gone, never to be seen again. Most carriers have a sufficiently sized queue that this rarely happens, but it can. Particularly at times like local area emergencies or at the end of a large sporting event or concert.

* this isnformation is from decades ago when I was developing SMS alarm monitoring hardware for council sewerage transfer stations in conjunction with a cell phone network provider. It may have changed in the intervening decades. Also it is wise to implement your own back-off timer. Due to a software bug we accidentally sent 10,000 messages over one weekend.

2 Likes

This is almost 2 years since my original post. The issue persists. As others in the thread have suggested, and as all the evidence suggests, the problem would seem to be queue-related on the service provider side. One thing doesn’t quite make sense to me though. I don’t get delayed SMS messages from any other non-HA sources. For example, I don’t get delayed messages from my spouse, friends, or relatives. It’s only from Home Assistant. I can’t quite square that with the backed up queue theory. If anyone has any other thoughts, I’d be really interested. In the meantime, I switched to Pushover for notifications.