update README, add geyser sample (as per quickstart in README)

This commit is contained in:
Chris Oloff 2025-12-15 13:34:44 +02:00
parent b52e70e918
commit 39a17e688b
2 changed files with 65 additions and 8 deletions

23
geyser_on_off.py Normal file
View file

@ -0,0 +1,23 @@
import os
import panel
from typing import Any
from watt42_viewlib import attach_w42_state
SYSTEM_ID = os.environ.get("WATT42_SYSTEM_ID", "invalid-system-id")
API_TOKEN = os.environ.get("WATT42_API_TOKEN", "invalid-api-token")
w42_state = panel.rx(None)
attach_w42_state(rx_var=w42_state, system_id=SYSTEM_ID, token=API_TOKEN)
def get_geyser_state(state: dict[str, Any]) -> bool:
if not state:
return False
return state.get("is_geyser_on", False)
geyser_state = panel.rx(get_geyser_state)(w42_state)
indicator = panel.indicators.BooleanStatus(value=geyser_state, name="W42 Connected", color="success")
_ = indicator.servable()