Repo-specific guidance for maintaining the Marstek integration (UDP Open API, polling, discovery/scanner) in a Home Assistant-friendly way
This skill focuses on changes that must preserve the intent of this repository: a robust local UDP Open API integration for Marstek energy storage devices, while remaining safe and compatible with Home Assistant.
marstek.Polling is tiered to reduce device load (configurable via options flow):
| Tier | Default | Commands |
|------|---------|----------|
| Fast | 30s | ES.GetMode, ES.GetStatus, EM.GetStatus (real-time power) |
| Medium | 60s | PV.GetStatus (solar data, Venus A/D only) |
| Slow | 300s | Wifi.GetStatus, Bat.GetStatus (diagnostics) |
Request delay: 5 seconds between API calls during a polling cycle (device stability).
The IP-change scanner runs separately (scanner.py, 10 min interval as backup).
Avoid shortening intervals without validating device/network stability. The device can be sensitive to request bursts.
The scanner uses an event-driven approach for IP change detection:
MarstekScanner.async_request_scan() to trigger immediate discoveryThis pattern avoids aggressive polling while still detecting IP changes quickly (~30s after connection failure).
# In coordinator.py - on failure threshold:
if self.consecutive_failures >= failure_threshold:
scanner = MarstekScanner.async_get(self.hass)
scanner.async_request_scan() # Immediate scan, debounced
raise UpdateFailed(...)
Best practice: Prefer event-driven triggers over shortening scan intervals.
config_flow.py; prefer selectors over raw text where it improves UX.async_on_unload(entry.add_update_listener(...)) to reload on change.translations/en.json and keep keys stable.custom_components/marstek/strings.json and custom_components/marstek/translations/en.json in sync.marstek logger.pytest-homeassistant-custom-component; keep manifests hassfest/HACS-clean and requirements pinned.After every code modification, run both checks:
# 1. Type checking (strict mode)
python3 -m mypy --strict custom_components/marstek/
# 2. All tests
pytest tests/ -q
Both must pass before considering any change complete. The repository enforces strict typing with mypy --strict:
dict[str, Any], Future[None])cast() for type narrowing with mocked objects下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer