feat: add WLED device status check (online/offline, LEDs, version)
- Query WLED JSON API (/json/info) for device info - Show online/offline status dot, LED count and firmware version - Auto-check all devices on page load - Button to manually check individual or all devices - Fix hostname placeholder to volksheimstaette.de Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -24,3 +24,24 @@ def call_wled(url):
|
||||
except requests.exceptions.RequestException as e:
|
||||
logger.warning("WLED nicht erreichbar: %s - %s", url, e)
|
||||
return False, str(e)
|
||||
|
||||
|
||||
def get_wled_info(hostname):
|
||||
"""Query WLED JSON API for device info. Returns dict or None."""
|
||||
try:
|
||||
r = requests.get(f"http://{hostname}/json/info", timeout=TIMEOUT)
|
||||
if r.status_code == 200:
|
||||
data = r.json()
|
||||
return {
|
||||
"online": True,
|
||||
"name": data.get("name", ""),
|
||||
"version": data.get("ver", ""),
|
||||
"brand": data.get("brand", "WLED"),
|
||||
"mac": data.get("mac", ""),
|
||||
"ip": data.get("ip", ""),
|
||||
"leds": data.get("leds", {}).get("count", 0),
|
||||
"power_on": data.get("state", {}).get("on", False) if "state" not in data else None,
|
||||
}
|
||||
return {"online": False}
|
||||
except requests.exceptions.RequestException:
|
||||
return {"online": False}
|
||||
|
||||
Reference in New Issue
Block a user