From a6e7546142115432e1815f7a4c36608bbd85fe1a Mon Sep 17 00:00:00 2001 From: Manu <4445816+tr4nt0r@users.noreply.github.com> Date: Wed, 21 Jan 2026 18:41:46 +0100 Subject: [PATCH] Add support for sequence ID to publish action in ntfy integration (#161342) --- homeassistant/components/ntfy/notify.py | 2 ++ homeassistant/components/ntfy/services.yaml | 5 +++++ homeassistant/components/ntfy/strings.json | 8 ++++++++ tests/components/ntfy/conftest.py | 2 ++ tests/components/ntfy/snapshots/test_event.ambr | 1 + tests/components/ntfy/test_event.py | 1 + tests/components/ntfy/test_services.py | 3 +++ 7 files changed, 22 insertions(+) diff --git a/homeassistant/components/ntfy/notify.py b/homeassistant/components/ntfy/notify.py index 4c7c07e640e..e4384f58269 100644 --- a/homeassistant/components/ntfy/notify.py +++ b/homeassistant/components/ntfy/notify.py @@ -43,6 +43,7 @@ ATTR_ICON = "icon" ATTR_MARKDOWN = "markdown" ATTR_PRIORITY = "priority" ATTR_TAGS = "tags" +ATTR_SEQUENCE_ID = "sequence_id" SERVICE_PUBLISH_SCHEMA = cv.make_entity_service_schema( { @@ -60,6 +61,7 @@ SERVICE_PUBLISH_SCHEMA = cv.make_entity_service_schema( vol.Optional(ATTR_EMAIL): vol.Email(), vol.Optional(ATTR_CALL): cv.string, vol.Optional(ATTR_ICON): vol.All(vol.Url(), vol.Coerce(URL)), + vol.Optional(ATTR_SEQUENCE_ID): cv.string, } ) diff --git a/homeassistant/components/ntfy/services.yaml b/homeassistant/components/ntfy/services.yaml index 2c8e00746e5..21f23904832 100644 --- a/homeassistant/components/ntfy/services.yaml +++ b/homeassistant/components/ntfy/services.yaml @@ -88,3 +88,8 @@ publish: type: url autocomplete: url example: https://example.org/logo.png + sequence_id: + required: false + selector: + text: + example: "Mc3otamDNcpJ" diff --git a/homeassistant/components/ntfy/strings.json b/homeassistant/components/ntfy/strings.json index 41b4f20b85b..80601187f37 100644 --- a/homeassistant/components/ntfy/strings.json +++ b/homeassistant/components/ntfy/strings.json @@ -1,6 +1,7 @@ { "common": { "add_topic_description": "Set up a topic for notifications.", + "sequence_id": "Sequence ID", "topic": "Topic" }, "config": { @@ -171,6 +172,9 @@ "icon": { "name": "Icon" }, "message": { "name": "Message" }, "priority": { "name": "Priority" }, + "sequence_id": { + "name": "[%key:component::ntfy::common::sequence_id%]" + }, "tags": { "name": "Tags" }, "time": { "name": "Time" }, "title": { "name": "Title" }, @@ -356,6 +360,10 @@ "description": "All messages have a priority that defines how urgently your phone notifies you, depending on the configured vibration patterns, notification sounds, and visibility in the notification drawer or pop-over.", "name": "Message priority" }, + "sequence_id": { + "description": "Enter a message or sequence ID to update an existing notification, or specify a sequence ID to reference later when updating, clearing (mark as read and dismiss), or deleting a notification.", + "name": "[%key:component::ntfy::common::sequence_id%]" + }, "tags": { "description": "Add tags or emojis to the notification. Emojis (using shortcodes like smile) will appear in the notification title or message. Other tags will be displayed below the notification content.", "name": "Tags/Emojis" diff --git a/tests/components/ntfy/conftest.py b/tests/components/ntfy/conftest.py index 91e2e1ee5f8..45b509c1e8e 100644 --- a/tests/components/ntfy/conftest.py +++ b/tests/components/ntfy/conftest.py @@ -57,6 +57,7 @@ def mock_aiontfy() -> Generator[AsyncMock]: actions=[], attachment=None, content_type=None, + sequence_id="Mc3otamDNcpJ", ) resp.to_dict.return_value = { @@ -74,6 +75,7 @@ def mock_aiontfy() -> Generator[AsyncMock]: "actions": [], "attachment": None, "content_type": None, + "sequence_id": "Mc3otamDNcpJ", } async def mock_ws( diff --git a/tests/components/ntfy/snapshots/test_event.ambr b/tests/components/ntfy/snapshots/test_event.ambr index 40c5f4f4122..e25afa988bf 100644 --- a/tests/components/ntfy/snapshots/test_event.ambr +++ b/tests/components/ntfy/snapshots/test_event.ambr @@ -59,6 +59,7 @@ 'id': 'h6Y2hKA5sy0U', 'message': 'Hello', 'priority': 3, + 'sequence_id': 'Mc3otamDNcpJ', 'tags': list([ 'octopus', ]), diff --git a/tests/components/ntfy/test_event.py b/tests/components/ntfy/test_event.py index 7758f681332..7b03b799a98 100644 --- a/tests/components/ntfy/test_event.py +++ b/tests/components/ntfy/test_event.py @@ -101,6 +101,7 @@ async def test_event( "time": datetime(2025, 3, 28, 17, 58, 46, tzinfo=UTC), "title": "Title", "topic": "mytopic", + "sequence_id": "Mc3otamDNcpJ", } diff --git a/tests/components/ntfy/test_services.py b/tests/components/ntfy/test_services.py index d07df40264f..00c338c4412 100644 --- a/tests/components/ntfy/test_services.py +++ b/tests/components/ntfy/test_services.py @@ -22,6 +22,7 @@ from homeassistant.components.ntfy.notify import ( ATTR_ICON, ATTR_MARKDOWN, ATTR_PRIORITY, + ATTR_SEQUENCE_ID, ATTR_TAGS, SERVICE_PUBLISH, ) @@ -60,6 +61,7 @@ async def test_ntfy_publish( ATTR_MARKDOWN: True, ATTR_PRIORITY: "5", ATTR_TAGS: ["partying_face", "grin"], + ATTR_SEQUENCE_ID: "Mc3otamDNcpJ", }, blocking=True, ) @@ -76,6 +78,7 @@ async def test_ntfy_publish( markdown=True, icon=URL("https://example.org/logo.png"), delay="86430.0s", + sequence_id="Mc3otamDNcpJ", ) )