Add Baby Tracker client and Home Assistant integration
Python client for the Baby Tracker sync server, reverse engineered from the Android app (4.53), and a HACS-installable Home Assistant integration built on it. Each baby gets a log calendar and summary sensors, and actions add entries that sync back to the group. Reading has been run against the real server. Uploading and running inside real Home Assistant have not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
6466f002e0
51 files changed
+5199
No files matched your search
@@ -0,0 +1,63 @@
|
||||
from enum import Enum
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from .data_entry_flow import AbortFlow
|
||||
|
||||
_T = TypeVar("_T")
|
||||
ConfigFlowResult = dict
|
||||
|
||||
|
||||
class ConfigEntryState(Enum):
|
||||
LOADED = "loaded"
|
||||
NOT_LOADED = "not_loaded"
|
||||
|
||||
|
||||
class ConfigEntry(Generic[_T]):
|
||||
def __init__(self, data, unique_id, title="entry"):
|
||||
self.data = dict(data)
|
||||
self.unique_id = unique_id
|
||||
self.title = title
|
||||
self.state = ConfigEntryState.NOT_LOADED
|
||||
self.runtime_data = None
|
||||
self.unloads = []
|
||||
|
||||
def async_on_unload(self, func):
|
||||
self.unloads.append(func)
|
||||
|
||||
|
||||
class ConfigFlow:
|
||||
def __init_subclass__(cls, domain=None, **kwargs):
|
||||
super().__init_subclass__(**kwargs)
|
||||
cls.domain = domain
|
||||
|
||||
def __init__(self):
|
||||
self.hass = None
|
||||
self.unique_id = None
|
||||
self.existing_unique_ids = set()
|
||||
self.reauth_entry = None
|
||||
self.updated = None
|
||||
|
||||
def async_show_form(self, step_id, data_schema=None, errors=None, description_placeholders=None):
|
||||
return {"type": "form", "step_id": step_id, "errors": errors or {}, "schema": data_schema,
|
||||
"description_placeholders": description_placeholders}
|
||||
|
||||
def async_create_entry(self, title, data):
|
||||
return {"type": "create_entry", "title": title, "data": data}
|
||||
|
||||
async def async_set_unique_id(self, unique_id):
|
||||
self.unique_id = unique_id
|
||||
|
||||
def _abort_if_unique_id_configured(self):
|
||||
if self.unique_id in self.existing_unique_ids:
|
||||
raise AbortFlow("already_configured")
|
||||
|
||||
def _abort_if_unique_id_mismatch(self, reason="unique_id_mismatch"):
|
||||
if self.reauth_entry.unique_id != self.unique_id:
|
||||
raise AbortFlow(reason)
|
||||
|
||||
def _get_reauth_entry(self):
|
||||
return self.reauth_entry
|
||||
|
||||
def async_update_reload_and_abort(self, entry, data_updates=None):
|
||||
entry.data.update(data_updates or {})
|
||||
return {"type": "abort", "reason": "reauth_successful"}
|
||||
Reference in new issue
Block a user