Duplicate push notification
See original GitHub issueThe problem
I have a fairly simply automation that sometimes results in a duplicate notification. It’s not the only one that exhibits this behaviour, but for simplicity of debugging the issue I’m focusing on only this one.
- alias: "Notify If New Backup Found"
trigger:
- platform: state
entity_id: sensor.last_backup
mode: single
condition:
condition: template
value_template: >-
{% set last_backup = states('sensor.last_backup') | as_datetime %}
{{ ((utcnow() - last_backup).seconds) < 60 }}
action:
- service: notify.mobile_app_ceres
data:
title: "System"
message: "A new Home Assistant backup was made."
data:
group: "system-backup"
url: homeassistant://navigate/lovelace/devices
I logged this issue the first time in March on the forum in case it was an issue on my side. After some assistance from @zacwest it seems like I should report this as a bug.
Zac made a few suggestions, among which to include a random number to establish if it is indeed a duplicate notification and not simply a second notification due to some other issue.
I was already sure at the start that there isn’t a duplicate event or state change – at least not what could be seen via the UI tools.
When I first logged this I was on 2022.2.9. I’m now on 2022.5.4. I keep my iOS companion app up to date all the time.
This is what the duplicate notification looks like:
Home Assistant.txt
:
2022-05-20 17:53:13.339 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 711)
2022-05-20 17:53:13.339 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 711)
2022-05-20 17:53:13.339 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 711)
2022-05-20 17:53:13.340 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 711)
2022-05-20 17:56:13.148 [Verbose] [main] [WebViewController.swift:1014] sendExternalBus(message:) > sending {"type":"command","id":-1,"command":"restart"}
2022-05-20 17:56:13.148 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"id":712,"type":"ping"}
2022-05-20 17:56:13.154 [Verbose] [main] [NotificationManager.swift:236] userNotificationCenter(_:didReceive:withCompletionHandler:) > User info in incoming not
ification [AnyHashable("webhook_id"): REDACTED, AnyHashable("url"): homeassistant://navigate/lovelace/de
vices, AnyHashable("aps"): {
alert = {
body = "Systems shut down prior to loadshedding. (547)";
title = System;
};
sound = default;
"thread-id" = "system-general";
}] with response <UNNotificationResponse: 0x2827cc1e0; actionIdentifier: com.apple.UNNotificationDefaultActionIdentifier, notification: <UNNotification: 0x2827d
b540; source: io.robbie.HomeAssistant date: 2022-05-20 15:56:01 +0000, request: <UNNotificationRequest: 0x2827dacd0; identifier: 024FC8AC-8444-4D9B-9506-8C52493
BE92E, content: <UNNotificationContent: 0x2814df900; title: <redacted>, subtitle: (null), body: <redacted>, summaryArgument: , summaryArgumentCount: 0, category
Identifier: , launchImageName: , threadIdentifier: system-general, attachments: (
), badge: (null), sound: <UNNotificationSound: 0x280398850>, realert: 0, interruptionLevel: 1, relevanceScore: 0.00, trigger: (null)>, intents: (
)>>
2022-05-20 17:56:13.154 [Info] [main] [NotificationManager.swift:250] userNotificationCenter(_:didReceive:withCompletionHandler:) > launching URL homeassistant:
//navigate/lovelace/devices
2022-05-20 17:56:13.386 [Error] [main] [Environment.swift:72] init() > WebSocket: Error: Optional(POSIXErrorCode(rawValue: 53): Software caused connection abort
)
2022-05-20 17:56:13.386 [Info] [main] [Environment.swift:71] init() > WebSocket: phase transition to disconnected(error: Optional(POSIXErrorCode(rawValue: 53):
Software caused connection abort), forReset: false)
2022-05-20 17:56:13.386 [Info] [main] [Environment.swift:71] init() > WebSocket: disconnecting; permanently: false, error: Optional(POSIXErrorCode(rawValue: 53)
: Software caused connection abort)
2022-05-20 17:56:13.386 [Info] [main] [Environment.swift:71] init() > WebSocket: phase transition to disconnected(error: nil, forReset: true)
2022-05-20 17:56:13.387 [Info] [main] [WebhookManager.swift:217] sendEphemeral(server:request:) > sending to historic: WebhookRequest(type: "update_registration
", data: ["manufacturer": "Apple", "model": "iPhone13,1", "app_data": ["push_url": "https://mobile-apps.home-assistant.io/api/sendPushNotification", "push_token
": "REDACTED"], "os_version": "15.5", "app_version": "2022.3 (2022.358)", "device_name": "Ceres"], localMetadata: nil)
2022-05-20 17:56:13.388 [Verbose] [main] [WebViewController.swift:835] userContentController(_:didReceive:) > message { id = "-1"; result = "<null>";
success = 1; type = result; }
2022-05-20 17:56:13.388 [Error] [main] [WebViewController.swift:997] handleExternalMessage(_:) > unknown: result
2022-05-20 17:56:13.419 [Info] [main] [Environment.swift:71] init() > WebSocket: connecting using HAConnectionInfo(url: http://homeassistant.local:8123, userAge
nt: Optional("Home Assistant/2022.3 (io.robbie.HomeAssistant; build:2022.358; iOS 15.5.0)"), engine: nil)
2022-05-20 17:56:13.422 [Verbose] [main] [IncomingURLHandler.swift:16] handle(url:) > Received URL: homeassistant://navigate/lovelace/devices
2022-05-20 17:56:13.552 [Info] [main] [Environment.swift:71] init() > WebSocket: Viability changed: true
2022-05-20 17:56:13.559 [Info] [main] [Environment.swift:71] init() > WebSocket: connected with headers: ["Content-Type": "application/octet-stream", "Connectio
n": "upgrade", "Sec-WebSocket-Accept": "Z2OGWnybF3xoqPFrK4t7UDvCHjU=", "Date": "Fri, 20 May 2022 15:56:13 GMT", "Upgrade": "websocket", "Server": "Python/3.9 ai
ohttp/3.8.1", "Sec-WebSocket-Extensions": "permessage-deflate"]
2022-05-20 17:56:13.559 [Info] [main] [Environment.swift:71] init() > WebSocket: phase transition to auth
HomeAssistant-Extensions-PushProvider.txt
:
2022-05-20 17:53:28.421 [Info] [main] [Environment.swift:71] init() > WebSocket: Ping
2022-05-20 17:53:43.563 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"id":2136,"type":"ping"}
2022-05-20 17:53:43.571 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Received: result success HARequestIdentifier(rawValue: 2136)
2022-05-20 17:54:39.405 [Info] [main] [Environment.swift:71] init() > WebSocket: Ping
2022-05-20 17:55:16.442 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"id":2137,"type":"ping"}
2022-05-20 17:55:16.503 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Received: result success HARequestIdentifier(rawValue: 2137)
2022-05-20 17:56:01.785 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Received: event: for HARequestIdentifier(rawValue: 2097)
2022-05-20 17:56:01.789 [Debug] [main] [LocalPushManager.swift:161] handle(event:) > handling LocalPushEvent(confirmID: Optional("REDACTED"), identifier: "REDACTED", contentWithoutServer: <UNNotificationContent: 0x13be72620; title: System, subtitle: (null), body: Systems shut down prior to loadshedding. (547), summaryArgument: , summaryArgumentCount: 0, categoryIdentifier: , launchImageName: , threadIdentifier: system-general, attachments: (
), badge: (null), sound: <UNNotificationSound: 0x13be620c0>, realert: 0, interruptionLevel: 1, relevanceScore: 0.00)
2022-05-20 17:56:01.799 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Sending: {"confirm_id":"REDACTED","id":2138,"type":"mobile_app\/push_notification_confirm","webhook_id":"REDACTED"}
2022-05-20 17:56:01.807 [Info] [main] [PushProvider.swift:163] localPushManager(_:didReceiveRemoteNotification:) > failed: notCommand
2022-05-20 17:56:01.808 [Info] [hakit-work-queue] [Environment.swift:71] init() > WebSocket: Received: result failure HARequestIdentifier(rawValue: 2138): external(HAKit.HAError.ExternalError(code: "not_found", message: "Push notification channel not found")) via {"id":2138,"type":"result","success":false,"error":{"code":"not_found","message":"Push notification channel not found"}}
2022-05-20 17:56:01.808 [Error] [main] [NotificationAttachmentManager.swift:47] content(from:api:) > failed at getting attachment info: noAttachment
2022-05-20 17:56:01.808 [Info] [main] [NotificationAttachmentManager.swift:74] content(from:api:) > delivering content <UNMutableNotificationContent: 0x13bf60b10; title: <redacted>, subtitle: (null), body: <redacted>, summaryArgument: , summaryArgumentCount: 0, categoryIdentifier: , launchImageName: , threadIdentifier: system-general, attachments: (
), badge: (null), sound: <UNNotificationSound: 0x13be620c0>, realert: 0, interruptionLevel: 1, relevanceScore: 0.00
2022-05-20 17:56:01.817 [Error] [main] [LocalPushManager.swift:172] handle(event:) > failed to confirm local push: external(HAKit.HAError.ExternalError(code: "not_found", message: "Push notification channel not found"))
2022-05-20 17:56:01.837 [Info] [main] [LocalPushManager.swift:188] handle(event:) > added local notification
~
This seems to be the key to the issue:
2022-05-20 17:56:01.807 [Info] [main] [PushProvider.swift:163] localPushManager(_:didReceiveRemoteNotification:) > failed: notCommand
It seems like the local push fails and then the notification gets sent externally.
What version of Home Assistant Core has the issue?
core-2022.5.4
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
notify
Link to integration documentation on our website
https://www.home-assistant.io/integrations/notify/
Diagnostics information
I’d be happy to share the ZIP file of the companion app logs, but I don’t know how to easily sanitise it.
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
Issue Analytics
- State:
- Created a year ago
- Comments:13 (1 by maintainers)
I think the notable error is actually:
It seems like the confirmation code response handler is having an issue finding the pending response, but it’s also still doing the 10 second wait and firing through the HTTP call, making me think it’s failing to add the “cancel this retry” value to the dictionary.
This is still an ongoing issue. I’ve even had a case recently where the notification showed in triplicate. It really is the same notification, as was indicated by the logs before, but also since one can see in this screen capture chat clearing the one clears them all.
https://user-images.githubusercontent.com/743320/209689288-7b5d734a-2cf2-4316-b251-c31e270b0d33.mov