tags: - developer - classes description: Core class descriptions for the core classes of Supernotify for Home Assistant
Core Classes¶
Info
See the Class Diagram for how these relate to each other.
custom_components.supernotify.transport.Transport ¶
Base class for delivery transports.
Sub classes integrste with Home Assistant notification services or alternative notification mechanisms.
| METHOD | DESCRIPTION |
|---|---|
deliver | Delivery implementation |
initialize | Async post-construction initialization |
log_delivery_failure | Log a delivery failure, passing the exception caught in the caller's except block. |
log_delivery_recovered | Call on a successful delivery - logs once if this transport was previously |
simplify | Simplify text for delivery transports with speaking or plain text interfaces |
validate_action | Override in subclass if transport has fixed action or doesn't require one |
deliver(envelope, debug_trace=None) abstractmethod async ¶
Delivery implementation
envelope (Envelope): envelope to be delivered
debug_trace (DebugTrace): debug info collector
initialize() async ¶
Async post-construction initialization
log_delivery_failure(err, message, *args) ¶
Log a delivery failure, passing the exception caught in the caller's except block.
Logged at ERROR (with traceback) the first time this transport becomes unavailable, then downgraded to DEBUG for consecutive failures until it recovers - avoids spamming the log every notification while an external service/device stays down. Call alongside record_error(), which keeps tracking the lifetime error count regardless of log level.
log_delivery_recovered() ¶
Call on a successful delivery - logs once if this transport was previously flagged unavailable, then clears the flag.
simplify(text, strip_urls=False) ¶
Simplify text for delivery transports with speaking or plain text interfaces
validate_action(action) ¶
Override in subclass if transport has fixed action or doesn't require one
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 |
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
Defined here rather than in models/Target since requires access to registries
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 |
__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=
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
custom_components.supernotify.scenario.Scenario ¶
| METHOD | DESCRIPTION |
|---|---|
attributes | Return scenario attributes |
contents | Archive friendly view of scenario |
evaluate | Evaluate scenario conditions |
trace | Trace scenario condition execution |
validate | Validate Home Assistant conditiion definition at initiation |
attributes(include_condition=True, include_trace=False) ¶
Return scenario attributes
contents(minimal=False, **_kwargs) ¶
Archive friendly view of scenario
evaluate(condition_variables) ¶
Evaluate scenario conditions
trace(condition_variables) async ¶
Trace scenario condition execution
validate(valid_action_group_names=None) async ¶
Validate Home Assistant conditiion definition at initiation
custom_components.supernotify.model.Target ¶
custom_components.supernotify.model.DeliveryConfig ¶
custom_components.supernotify.model.TransportConfig ¶
custom_components.supernotify.snoozer.Snooze ¶
custom_components.supernotify.model.ConditionVariables dataclass ¶
Variables presented to all condition evaluations
Attributes¶
applied_scenarios (list[str]): Scenarios that have been applied
required_scenarios (list[str]): Scenarios that must be applied
constrain_scenarios (list[str]): Only scenarios in this list, or in explicit apply_scenarios, can be applied
notification_priority (str): Priority of the notification
notification_message (str): Message of the notification
notification_title (str): Title of the notification
occupancy (list[str]): List of occupancy scenarios
notification_data (dict[str,Any]): Additional data passed on notify action call
custom_components.supernotify.people.PeopleRegistry ¶
| METHOD | DESCRIPTION |
|---|---|
mobile_devices_for_person | Auto detect mobile_app targets for a person. |
mobile_devices_for_person(person_entity_id) ¶
Auto detect mobile_app targets for a person.
Targets not currently validated as async registration may not be complete at this stage
person_entity_id (str): _description_
list: mobile target actions for this person