Repository navigation
Description
Problem
A person's mobile_push delivery fans out to every enabled mobile device: phone, tablet,
laptop, watch. Each one gets its own push, whether or not anyone is using it:
- macOS laptop asleep / lid closed: APNs queues the push and delivers it on wake,
often hours later, as a stale alert. - Watch not on the wrist: the alert is pointless, and when it's back on it
duplicates what the phone already showed. - Tablet left on a desk: it lights up and chimes in an empty room.
Today the only per-device control is the static enabled flag in mobile_devices
(MOBILE_DEVICE_SCHEMA). Device snoozes (#269) cover manual, time-based muting, but not "only when the device is actually in use". The workaround is to switch off discovery and build one
mobile_push delivery per device, each with its own conditions and explicit target.
That multiplies deliveries, duplicates scenario wiring, and makes the trace harder to read.
The Companion apps already expose the state we need:
| Device | Entity | Meaning |
|---|---|---|
| macOS | binary_sensor.<mac>_active |
off on sleep, screensaver, display off, locked |
| Android | binary_sensor.<phone>_interactive |
screen on |
| Wear OS | binary_sensor.<watch>_on_body |
watch worn |
| iOS / iPadOS | no direct equivalent | could use Focus, battery state or a user template |
Proposal
Add optional conditions to MOBILE_DEVICE_SCHEMA, using the same HA condition syntax
already used by deliveries and scenarios:
recipients:
- person: person.lorenzo
mobile_devices:
- mobile_app_id: mobile_app_macbook
conditions:
- condition: state
entity_id: binary_sensor.macbook_active
state: "on"
- mobile_app_id: mobile_app_orologio
conditions:
- condition: state
entity_id: binary_sensor.orologio_on_body
state: "on"Behaviour:
- The conditions are evaluated per notification, at target resolution, with the same
ConditionVariablesthe delivery gets. That gives access topriority, so
priority: criticalcan bypass a device filter if the user wants. - A device whose conditions fail is dropped from that envelope's
mobile_app_ids. The
enabledflag stays as the static on/off switch. - Fail-open: if evaluation raises or a referenced entity is
unavailable/unknown,
deliver anyway. Losing a notification is worse than an extra one. - Merge with discovery: as with the other
mobile_deviceskeys,conditionson a
configured entry is overlaid onto the discovered device with the samemobile_app_id,
so discovery can stay on. - Debug trace / archive: record skipped devices with a reason, e.g.
mobile_app_orologio: skipped (device conditions), so cards and diagnostics can
explain why a device got nothing. - If all devices are filtered out, the delivery reports "no targets" as it does
today for an empty target, rather than "failed" (and, in line with Outcome is partial_delivery (logbook: 'partly sent') whenever any delivery is skipped, even for condition / disabled / no-target skips #232, shouldn't turn the outcome into a partial delivery).
Open questions
- Skip vs. downgrade. For iOS, sending with
interruption-level: passivemight be
better than skipping, since the alert stays in Notification Centre without waking the
device. Should a device be able to saywhen_unavailable: skip | passive? This could
be a follow-up. - Auto-mapping. Should SuperNotify detect
_active,_interactiveand_on_bodyin
the device registry and offer them as defaults? I'd keep v1 explicit and opt-in. - Phone-only fallback. Should there be a guard so the primary device is never filtered
out, or is that left to the user's conditions plus priority?
I'm happy to implement this. It touches schema.py (MOBILE_DEVICE_SCHEMA),
people.py (keeping compiled conditions per device, merging on discovery) and the
target resolution for mobile_push, plus tests and docs.
Generated by Claude Code
Activity
jeyrb commentedon Oct 24, 2026
Auto-mapping should work, since the device is discovered for the mobile app, and the device has these entities. That could mean no conditions, which makes it simpler for users and easier to move recipient to configflow.
So could default to only sending to active devices, and use the device's entities to work out which state represents that. Then recipient config, or notification action data, only needed to override that and say send it even if device isn't worn/active or unknown state.
Other options here, some of which come up before - only target a subset of classes, e.g. phone only or everything except iPad, and the fallback idea you have, where there's an order based on type of device, or user picked out order.
I don't trust iCloud integration, so haven't had full range of sensor entities on my devices. I do however have the annoyance of occasionally using an iPad and having lots of old notifications appear.
lollox80 commentedon Nov 7, 2026
Agreed, auto-mapping is better than hand-written conditions: no YAML, and it fits the recipient editor in 2.18.
A proposal for a first version:
_activeoff on macOS,_interactiveoff on Android,_on_bodyoff on a watch). I'd find it among the device's own entities in the registry, not by name.unknown/unavailable, gets the notification as today. An extra notification is better than a lost one.I'd keep the other ideas (only some classes of device, fallback order) for a second step. Your iPad case - old notifications when you pick it up again - I think is better solved by "everything except iPad" than by a sensor.
If that works for you, I'll prepare the PR.
jeyrb commentedon Nov 19, 2026
Sorry, missed this when travelling.
Yes, please go ahead with PR.
Related thing is "notify once with best method" which is missing and hard to do well because of fire-and-forget notifications ( although it could use the wait for response type HA action call to make it a bit more reliable ).
lollox80 commentedon Nov 23, 2026
PR is up: #336, with the change discussed above (Android's
is_interactiveisn't auto-mapped, since it's only "screen on" and a phone in a pocket would count as idle - the PR description explains).On "notify once with best method", I tried the one piece that would make it reliable rather than fire-and-forget: the Android Companion app's receipt confirmation.
Sending to a phone with
data: confirmation: true, the app firesmobile_app_notification_receivedback to HA when the notification actually arrives on the device. On my phone it came back within a second or two, carrying thetag,titleandmessagethat were sent plus thedevice_idandwebhook_idof the device that got it:(it's in
MessagingManager.kt, only fired whenconfirmationis set)So on Android "notify once" could be: send to the best device with
confirmation: trueand a tag, wait a few seconds for that event matching tag +device_id, and if it doesn't come, move on to the next device or delivery. That's the same shape as the per-deliveryfallbackfrom #256, which today only triggers on an error - it would just add "no receipt" as a trigger.iOS has no equivalent: I couldn't find any received-event in the iOS app source, only the action events. So there it stays fire-and-forget, or fallback on error only. An action with a response wouldn't help either, as
notify.mobile_app_*returns nothing about delivery.Happy to sketch it as a separate issue if you think it's worth it.
feat: leave out a recipient's mobile devices nobody is using (#299)
jeyrb commentedon Nov 24, 2026
Thanks for #336 and the testing.
Yes please, sketch receipt-confirmation as a separate issue: Android-only is fine as long as iOS degrades to today's behaviour, and it fits with the fallback trigger from #256.