tags: - developer - classes description: Notification class descriptions in Supernotify for Home Assistant
Notification Classes¶
Info
See the Class Diagram for how these relate to each other.
custom_components.supernotify.notification.Notification ¶
Bases: ArchivableObject
flowchart TD
custom_components.supernotify.notification.Notification[Notification]
custom_components.supernotify.archive.ArchivableObject[ArchivableObject]
custom_components.supernotify.archive.ArchivableObject --> custom_components.supernotify.notification.Notification
click custom_components.supernotify.notification.Notification href "" "custom_components.supernotify.notification.Notification"
click custom_components.supernotify.archive.ArchivableObject href "" "custom_components.supernotify.archive.ArchivableObject"
| METHOD | DESCRIPTION |
|---|---|
apply_enabled_scenarios | Set media and action_groups from scenario if defined, first come first applied |
base_filename | ArchiveableObject implementation |
contents | ArchiveableObject implementation |
convert_notify_entities | Short circuit supernotify notify entities so they're handled directly so not |
diagnostics_selected | A notification sent with |
initialize | Async post-construction initialization |
media_requirements | If no media defined, look for iOS / Android actions that have media defined |
record_result | Debugging (and unit test) support for notifications that failed or were skipped |
apply_enabled_scenarios() ¶
Set media and action_groups from scenario if defined, first come first applied
base_filename() ¶
ArchiveableObject implementation
contents(diagnostics=False, **_kwargs) ¶
ArchiveableObject implementation
convert_notify_entities(target=None) ¶
Short circuit supernotify notify entities so they're handled directly so not going round in circles via calls to notify.send_message. A genuine other-integration notify entity is left alone for NotifyEntityTransport to handle normally.
Defined here rather than in models/Target since requires access to registries.
supernotify.notify's target: field also accepts the dict shape Home Assistant's own target selector produces, e.g. {"entity_id": ["person.jey", "notify.recipient_alice"]} - unlike this integration's other dict-shaped targets (recipient/delivery config), that entity_id list is Home Assistant's raw picker output, not pre-sorted by category: a person entity picked that way still needs to end up as a person_id, same as if it had been typed directly into notify.supernotify's flat target list, or it would otherwise be silently dropped by Target() (whose entity_id category explicitly excludes the person domain - see Target.is_entity_id/is_person_id in model.py).
diagnostics_selected(outcome_policy) ¶
A notification sent with debug: true asked for its trace, so it is archived with the full diagnostic content whatever the configured diagnostics outcomes
initialize() async ¶
Async post-construction initialization
media_requirements(data) ¶
If no media defined, look for iOS / Android actions that have media defined
Example is the Frigate blueprint, which generates image, video etc in the data section, that can also be used for email attachments
record_result(delivery, envelope=None, targets=None, suppression_reason=None) ¶
Debugging (and unit test) support for notifications that failed or were skipped
custom_components.supernotify.envelope.Envelope ¶
Bases: DupeCheckable
flowchart TD
custom_components.supernotify.envelope.Envelope[Envelope]
custom_components.supernotify.common.DupeCheckable[DupeCheckable]
custom_components.supernotify.common.DupeCheckable --> custom_components.supernotify.envelope.Envelope
click custom_components.supernotify.envelope.Envelope href "" "custom_components.supernotify.envelope.Envelope"
click custom_components.supernotify.common.DupeCheckable href "" "custom_components.supernotify.common.DupeCheckable"
Wrap a notification with a specific set of targets and service data possibly customized for those targets
| METHOD | DESCRIPTION |
|---|---|
__eq__ | Specialized equality check for subset of attributes |
__repr__ | Return a concise string representation of the Envelope. |
core_action_data | Build the core set of |
customize_data | Return data filtered by delivery data_keys_select option, pruning empty maps by default. |
grab_image | Grab an image from a camera, snapshot URL, MQTT Image etc |
hash | Alpha hash to reduce noise from messages with timestamps or incrementing counts |
record_recipient_notifications | Update every involved recipient's notify.recipient_ |
__eq__(other) ¶
Specialized equality check for subset of attributes
__repr__() ¶
Return a concise string representation of the Envelope.
The returned string includes the envelope's message, title, and delivery name in the form: Envelope(message={message},title={title},delivery={delivery_name}).
Primarily intended for debugging and logging; note that attribute values are inserted directly and may not be quoted or escaped.
core_action_data(force_message=True) ¶
Build the core set of service_data dict to pass to underlying notify service
customize_data(data, prune_empty=True) ¶
Return data filtered by delivery data_keys_select option, pruning empty maps by default.
grab_image() async ¶
Grab an image from a camera, snapshot URL, MQTT Image etc
hash() ¶
Alpha hash to reduce noise from messages with timestamps or incrementing counts
record_recipient_notifications(recorded_person_ids) ¶
Update every involved recipient's notify.recipient_
recorded_person_ids are the recipients already recorded by the notification's other envelopes, which this adds to, so a recipient reached by several deliveries is only recorded once - each is a state write, and would otherwise show up in the logbook as several identical entries at the same moment.
custom_components.supernotify.target.Target ¶
| METHOD | DESCRIPTION |
|---|---|
__add__ | Create a new target by adding another to this one |
__eq__ | Compare two targets |
__len__ | How many targets, whether direct or indirect |
__sub__ | Create a new target by removing another from this one, ignoring target_data |
select | Narrow this target to what a delivery can use, leaving this one untouched |
__add__(other) ¶
Create a new target by adding another to this one
__eq__(other) ¶
Compare two targets
__len__() ¶
How many targets, whether direct or indirect
__sub__(other) ¶
Create a new target by removing another from this one, ignoring target_data
select(categories, own_names, hass_api, target_selector=None) ¶
Narrow this target to what a delivery can use, leaving this one untouched
categories are the delivery's declared target categories, and own_names its own name and its transport's. A target category named after either is always destined for that delivery. The two serve different purposes and both stay available: - the TRANSPORT name (sms:value) reaches every delivery of that transport, so scenario/time/occupancy selection logic can still decide which one actually fires - the same as it would for a plain, auto-matched value - a specific DELIVERY name (shortcode_sms:value) pins the target to just that one delivery, for when two deliveries of the same transport must stay distinct (e.g. email vs html_email)
person_ids are always kept, whatever the delivery declares, since they aren't delivered to but are the link back to the recipients a delivery reaches (see Notification.generate_targets(), which narrows them to those actually in each envelope). They are kept out of the target_selector too, as it's for choosing between values a transport can address.
custom_components.supernotify.model.TargetType ¶
Bases: StrEnum
flowchart TD
custom_components.supernotify.model.TargetType[TargetType]
click custom_components.supernotify.model.TargetType href "" "custom_components.supernotify.model.TargetType"
custom_components.supernotify.snoozer.Snooze ¶
| METHOD | DESCRIPTION |
|---|---|
__eq__ | Check if two snoozes for the same thing |
__repr__ | Return a string representation of the object. |
to_storage_dict | Full-fidelity serialization for persistence (unlike export(), which is a display |