- Suppress ConnectionError log noise from in-flight requests draining after a session close (poll_scheduler + keepalive log at DEBUG). - Null KeepaliveTask.on_unreachable during a forced reconnect so the dying session's keepalive can't flip HA availability offline after the new session is already healthy. Ported into PR #5's _maybe_force_reconnect flow. Drops the _session_stop / publish-health force-close mechanism from the original PR — PR #5's last_success_ts + _maybe_force_reconnect already covers the 'session dead, restart it' goal via a different path, and running both means two paths force-closing the same session on the same failure.
36 lines
944 B
Python
36 lines
944 B
Python
"""Appliance descriptors registry.
|
|
|
|
Adding a new appliance class:
|
|
1. Write `appliances/<class>.py` with an ApplianceDescriptor named
|
|
after the class (uppercase, e.g. OVEN).
|
|
2. Add it to DESCRIPTORS below.
|
|
3. Set DEVICE_CLASS=<class> in the per-device .env.
|
|
|
|
main.py imports get_descriptor(name) to look up the descriptor at
|
|
startup; the bridge itself stays class-agnostic.
|
|
"""
|
|
from .base import ApplianceDescriptor
|
|
from .dryer import DRYER
|
|
from .oven import OVEN
|
|
from .fridge import FRIDGE
|
|
|
|
|
|
|
|
DESCRIPTORS: dict[str, ApplianceDescriptor] = {
|
|
DRYER.name: DRYER,
|
|
OVEN.name: OVEN,
|
|
FRIDGE.name: FRIDGE,
|
|
}
|
|
|
|
|
|
def get_descriptor(name: str) -> ApplianceDescriptor:
|
|
try:
|
|
return DESCRIPTORS[name]
|
|
except KeyError:
|
|
raise ValueError(
|
|
f"unknown DEVICE_CLASS={name!r}; "
|
|
f"available: {sorted(DESCRIPTORS)}") from None
|
|
|
|
|
|
__all__ = ['ApplianceDescriptor', 'DESCRIPTORS', 'get_descriptor']
|