RFC0014 - Presets¶
A UI-first alternative to the DELIVERY_CUSTOMIZE_SCHEMA used by scenario, delivery and transport defaults, only with the delivery selection, media attachments and mobile action groups.
A preset is almost everything a user might select on a supernotify.notify call, canned and reusable for multiple future notifications. It can be the entire thing, or just one field. The analogy is to presets on radios or home appliances like microwaves.
These may have a subset of the full power available to the YAML based concepts where not feasible to deliver in ConfigFlow UI or complexity compromises usability.
They will also be selectable on supernotify.notify calls, so a user can select a single preset, a collection of presets, or one or more presets plus the regular fields (the latter taking precedence).
Enhancements¶
- Support the Seasonal Greetings pattern.
- Consider alternative way of doing chime replacement that doesn't need change to underlying delivery
- Allow direct swap of chime tune, e.g.
amzn_sfx_doorbell_chime_02tochristmas_05 - Support randomization, possibly using HA
randomhelper - Randomly select if override applied, with chosen % of calls
- Randomly choose from a list of alternatives, so people not driven mad by sleigh bells
- Combine those two random effects
- Allow direct swap of chime tune, e.g.
Selecting versus Changing Deliveries¶
A scenario uses one entry per delivery for two different jobs, choosing deliveries and changing them. The job is decided by enabled: true or no key switches the delivery on, and a key with no value only changes it when something else has already selected it. Leaving the key out and leaving its value empty look almost the same in YAML, but do opposite things. In #357 this meant a Christmas chime tune was meant to change chime_person, but switched it on, so it chimed on every notification, including Home Assistant restarts.
Presets don't carry this over. Choosing a delivery and changing one are separate fields:
- Add deliveries - deliveries to send through as well, whatever else selected them
- Remove deliveries - deliveries not to send through, even if something else selected them
- Delivery changes - data, targets and so on for named deliveries (or patterns), applied only when that delivery is selected by something else. A change never selects a delivery.
A preset that both adds a delivery and changes it, like a red alert siren with its own tune, lists it in both places. Nothing is implied by leaving something out, so there's no hidden default for a UI or a script to get wrong. In the ConfigFlow UI these are two delivery multi-selects and a list of changes, so the screen shows what the preset does.
Where a scenario is shown as, or converted to, a preset, enabled: true or no enabled key becomes Add plus Delivery changes, enabled: false becomes Remove, and an empty enabled: becomes Delivery changes only. The behaviour stays the same, and now shows on the screen.
Precedence¶
Presets have no rank other than the order of application, so a list of presets in an action call is has meaningful order. For rules, the rank is applied to the rule not the preset - for each rule, the presets are applied in the order provided inside the rule, with later presets overriding earlier ones.
Use Cases¶
- Define what transports to use, and configuration for those transports
- Set up a list of targets that can be
- This might be sufficient such that RFC0008 - Target Groups can be shelved
- Set a priority
- Move a camera to a PTZ location and take a snapshot to attach to notification
Example Call¶
- action: supernotify.notify
data:
title: Security Notification
message: Motion at porch in night
preset: red_alert
- action: supernotify.notify
data:
title: Security Notification
message: Person at porch in night
preset:
- red_alert
- snap_porch_cam
- alexa_announce
- action: supernotify.notify
data:
title: Security Notification
message: Person at porch in night
priority: critical
preset:
- red_alert
media:
camera_entity_id: camera.porch
camera_ptz_preset: zoomed_out
camera_delay: 10
jpeg_opts:
progressive: true
optimize: true
quality: 50
Phasing¶
Phase 1 - Rules¶
Presets will first be made available as part of RFC0013 - Rules as the way to define what a rule does, for those rules that don't delegate this to a script or AI Task.
Phase 2 - Actions¶
Implement preset as top level action keyword, taking a single value or list (no mapping supported).
Direction¶
They may prove able to do a sufficiently large amount of what the YAML delivery can do that they are all that's needed in Configflow, and delivery, like scenario remains supported as YAML-first full power options for experienced and motivated users.