From 6d9d49523b92b6ebdc65fd5749f7bf5d27c4f14e Mon Sep 17 00:00:00 2001 From: lollox80 Date: Fri, 27 Mar 2026 23:43:11 +0100 Subject: [PATCH 1/3] fix: action call data takes precedence over scenario data - envelope_data now built in correct priority order: delivery.data < scenario.data < action_call.data < target.data - action call overrides (volume, message_template, etc.) now correctly override scenario-level data (e.g. late_night volume=0 whisper) - ATTR_CHANNEL_MESSAGE added to const.py and imports - ATTR_SPOKEN_MESSAGE removed (obsolete, replaced by channel_message) --- custom_components/supernotify/const.py | 1 + custom_components/supernotify/notification.py | 23 ++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/custom_components/supernotify/const.py b/custom_components/supernotify/const.py index e953da343..2ae6801a1 100644 --- a/custom_components/supernotify/const.py +++ b/custom_components/supernotify/const.py @@ -83,6 +83,7 @@ ATTR_SCENARIOS_REQUIRE = "require_scenarios" ATTR_SCENARIOS_APPLY = "apply_scenarios" ATTR_FORCE_RESEND: Final[str] = "force_resend" +ATTR_CHANNEL_MESSAGE: Final[str] = "channel_message" ATTR_SCENARIOS_CONSTRAIN = "constrain_scenarios" ATTR_DELIVERY = "delivery" ATTR_DEFAULT = "default" diff --git a/custom_components/supernotify/notification.py b/custom_components/supernotify/notification.py index b09b84abd..33ed64d0e 100644 --- a/custom_components/supernotify/notification.py +++ b/custom_components/supernotify/notification.py @@ -29,7 +29,7 @@ ATTR_SCENARIOS_APPLY, ATTR_SCENARIOS_CONSTRAIN, ATTR_SCENARIOS_REQUIRE, - ATTR_SPOKEN_MESSAGE, + ATTR_CHANNEL_MESSAGE, DELIVERY_SELECTION_EXPLICIT, DELIVERY_SELECTION_FIXED, DELIVERY_SELECTION_IMPLICIT, @@ -72,7 +72,7 @@ KEY_SKIPPED = "skipped" # supernotify specific data items not to be passed to transports in data -INTERNAL_DATA_KEYS = (ATTR_FORCE_RESEND, ATTR_SPOKEN_MESSAGE) +INTERNAL_DATA_KEYS = (ATTR_FORCE_RESEND, ATTR_SPOKEN_MESSAGE, ATTR_CHANNEL_MESSAGE) type t_delivery_name = str type t_outcome = str @@ -601,12 +601,8 @@ def base_filename(self) -> str: """ArchiveableObject implementation""" return f"{self.created.isoformat()[:16].replace(':', '-')}_{self.id}" - def delivery_data(self, delivery: Delivery) -> dict[str, Any]: - if delivery is None: - return {} - delivery_override: DeliveryCustomization | None = self.delivery_overrides.get(delivery.name) - if delivery_override is None: - delivery_override = self.delivery_overrides.get(delivery.transport.name) + def delivery_data(self, delivery_name: str) -> dict[str, Any]: + delivery_override: DeliveryCustomization | None = self.delivery_overrides.get(delivery_name) return delivery_override.data if delivery_override and delivery_override.data else {} @property @@ -793,16 +789,17 @@ def generate_envelopes(self, delivery: Delivery, targets: list[Target]) -> list[ if target.has_resolved_target() or delivery.target_required != TargetRequired.ALWAYS: envelope_data = {} envelope_data.update(delivery.data) - envelope_data.update({ - k: v for k, v in self.extra_data.items() if k not in INTERNAL_DATA_KEYS - }) # action call data - if target.target_data: - envelope_data.update(target.target_data) # scenario applied at cross-delivery level in apply_enabled_scenarios for scenario in self.enabled_scenarios.values(): customization: DeliveryCustomization | None = scenario.delivery_customization(delivery.name) if customization and customization.data: envelope_data.update(customization.data) + # action call data overrides scenario data + envelope_data.update({ + k: v for k, v in self.extra_data.items() if k not in INTERNAL_DATA_KEYS + }) # action call data + if target.target_data: + envelope_data.update(target.target_data) envelopes.append(Envelope(delivery, self, target, envelope_data, context=self.context)) return envelopes From 11b0a5c726356d520e031a1f92d56aa41a74e704 Mon Sep 17 00:00:00 2001 From: lollox80 Date: Sat, 28 Mar 2026 00:45:11 +0100 Subject: [PATCH 2/3] fix: add missing ATTR_SPOKEN_MESSAGE import ATTR_SPOKEN_MESSAGE was removed from imports when ATTR_CHANNEL_MESSAGE was added, but INTERNAL_DATA_KEYS still references it. Add both imports. --- custom_components/supernotify/notification.py | 1 + 1 file changed, 1 insertion(+) diff --git a/custom_components/supernotify/notification.py b/custom_components/supernotify/notification.py index 33ed64d0e..71325bcbb 100644 --- a/custom_components/supernotify/notification.py +++ b/custom_components/supernotify/notification.py @@ -30,6 +30,7 @@ ATTR_SCENARIOS_CONSTRAIN, ATTR_SCENARIOS_REQUIRE, ATTR_CHANNEL_MESSAGE, + ATTR_SPOKEN_MESSAGE, DELIVERY_SELECTION_EXPLICIT, DELIVERY_SELECTION_FIXED, DELIVERY_SELECTION_IMPLICIT, From dfee86b1ada4d272c19d85a7674ebaa447994e7b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 27 Mar 2026 23:45:32 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- custom_components/supernotify/notification.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/supernotify/notification.py b/custom_components/supernotify/notification.py index 71325bcbb..faed1cf9a 100644 --- a/custom_components/supernotify/notification.py +++ b/custom_components/supernotify/notification.py @@ -15,6 +15,7 @@ from .const import ( ATTR_ACTION_GROUPS, ATTR_ACTIONS, + ATTR_CHANNEL_MESSAGE, ATTR_DEBUG, ATTR_DELIVERY, ATTR_DELIVERY_SELECTION, @@ -29,7 +30,6 @@ ATTR_SCENARIOS_APPLY, ATTR_SCENARIOS_CONSTRAIN, ATTR_SCENARIOS_REQUIRE, - ATTR_CHANNEL_MESSAGE, ATTR_SPOKEN_MESSAGE, DELIVERY_SELECTION_EXPLICIT, DELIVERY_SELECTION_FIXED,