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>
22 lines
475 B
Python
22 lines
475 B
Python
from datetime import datetime, timezone
|
|
|
|
DEFAULT_TIME_ZONE = timezone.utc
|
|
|
|
|
|
def utcnow():
|
|
return datetime.now(timezone.utc)
|
|
|
|
|
|
def as_utc(value):
|
|
if value.tzinfo is None:
|
|
value = value.replace(tzinfo=DEFAULT_TIME_ZONE)
|
|
return value.astimezone(timezone.utc)
|
|
|
|
|
|
def as_local(value):
|
|
return value.astimezone(DEFAULT_TIME_ZONE)
|
|
|
|
|
|
def start_of_local_day():
|
|
return utcnow().astimezone(DEFAULT_TIME_ZONE).replace(hour=0, minute=0, second=0, microsecond=0)
|