Skip to main content

franklinwh-ha-notify

Home Assistant notifications with buttons, shared by the FranklinWH bridges (the Direct Connect bridge and the Modbus bridge). It finds the targets that can receive notifications, sends them with buttons, receives the taps, and keeps a record of both.

It holds no FranklinWH device code. What a button does is up to the bridge.

The design, decisions and plan are in docs/DESIGN.md.

What it does

Piece Module
Find each HA instance's notify.* targets; mark which can show buttons (notify.mobile_app_*) targets
Send one notification to many targets, with a delivery count send
Receive taps over HA's WebSocket (mobile_app_notification_action), reconnecting listener
Single-use, expiring requests; wait for an answer with a timeout actions
Title and message templates per event, with variables and reset templates
A record of every send and tap, kept for a number of days ledger
All of the above behind one object Notifier

The button contract

A button's action id is FWH_<VERB>_<request id>, for example FWH_YES_3f9c0a1b2c3d4e5f. The request id is inside the action id because every Companion app echoes action back, while other data fields come back differently on iOS and Android. Buttons without the FWH_ prefix (Snooze and the like, added by the phone) are ignored.

A tap resolves as one of:

  • accepted: the bridge's handler runs;
  • unknown: never issued, or lost in a restart;
  • expired;
  • used: already answered;
  • not-allowed: a button the request didn't offer.

Every outcome is recorded.

Taps arrive only over the bridge's own authenticated WebSocket to Home Assistant. There is no webhook and nothing on the bridge accepts an unauthenticated call.

Use

import sqlite3
from franklinwh_ha_notify import (YES, NO, Button, Event, HAInstance, Ledger, Notifier,
                                  Templates, discover)

ha = HAInstance("home", "http://supervisor/core", token=lambda: os.environ["SUPERVISOR_TOKEN"])
templates = Templates()
templates.register(Event("force_left_running", "Force still running on {gateway}",
                         "A force from before the restart is still running. Release it?"))
n = Notifier({"home": ha}, Ledger(sqlite3.connect("data/bridge.db")), templates,
             enabled=lambda: settings.notifications_on)

async def release(request, answer):
    if answer.verb == YES:
        await bridge.release_force(request.gateway)     # the bridge's own gated command
        return "released"
    return "kept"

n.on("force_left_running", release)
n.listen()                                   # one tap listener per HA instance

targets = [t for t in await discover(ha) if t.buttons]
await n.ask("force_left_running", targets, [Button(YES, "Release"), Button(NO, "Keep")],
            ttl_s=900, gateway="Home")

# Or wait for the answer inline, as a scheduler step does:
answer = await n.ask_and_wait("ok_to_charge", targets, [Button(YES, "Yes"), Button(NO, "No")],
                              timeout_s=300, gateway="Home")
if answer.timed_out:
    ...                                      # the step's "if no reply" rule

Development

python3.12 -m venv .venv && .venv/bin/pip install -e ".[test]"
.venv/bin/pytest -q

The tests run against a fake Home Assistant: REST through an httpx mock transport, and a real local WebSocket server that speaks HA's auth and subscribe_events handshake.

Releases: bump version in pyproject.toml, add the CHANGELOG section, tag v<version>. The publish workflow tests, checks the tag matches, and publishes to PyPI.

Licence

MIT

Metadata

Release files for franklinwh-ha-notify 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for franklinwh-ha-notify 0.1.0
File Size Uploaded Provenance Actions
franklinwh_ha_notify-0.1.0.tar.gz 17.1 kB With provenance Details for franklinwh_ha_notify-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for franklinwh-ha-notify 0.1.0
File Interpreter ABI Platform Actions
franklinwh_ha_notify-0.1.0-py3-none-any.whl Python 3 none any Details for franklinwh_ha_notify-0.1.0-py3-none-any.whl

Total release size: 33.1 kB

Release files / franklinwh_ha_notify-0.1.0.tar.gz

Download URL franklinwh_ha_notify-0.1.0.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ee7004d25a8f513f5a06c8be7cfd31e7cfcd8ef47517f1deb2bb47045c6cfd05
BLAKE2b-256 checksum
How to use checksums
20a43a73e3de2b1ed01f673035a19b5f3547e541c1db16bc26501aec9b5f63d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / franklinwh_ha_notify-0.1.0-py3-none-any.whl

Download URL franklinwh_ha_notify-0.1.0-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7993a28b7cd42a08868a045920c79a04bb2670b4067c67143691b44a9010593
BLAKE2b-256 checksum
How to use checksums
810bd2ad1914d843609b2651614c479062009ba43b5ed16ecb8ab82ad8cbd64a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for franklinwh-ha-notify 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for franklinwh_ha_notify-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page