fix: HA Passwort-Auth loggt nicht mehr aus, Radio-Layout korrigiert

- Backend gibt 400 statt 401 bei falschen HA-Credentials zurück, damit
  der globale api.js-Logout-Handler nicht ausgelöst wird
- Null-Guard im JS nach api.post verhindert den "calendars of null"-Crash
- Radio-Buttons für Anmeldemethode nicht mehr in form-group, damit
  input[type=radio] kein width:100% bekommt und sauber nebeneinander liegt
This commit is contained in:
Scarriffle
2026-04-24 11:26:50 +02:00
parent 7c55a6043d
commit a41e76b1bf
3 changed files with 10 additions and 9 deletions

View File

@@ -39,7 +39,7 @@ def _ha_login(url: str, username: str, password: str) -> tuple:
except http_requests.exceptions.Timeout:
raise HTTPException(503, "Home Assistant antwortet nicht (Timeout)")
if resp.status_code in (400, 401):
raise HTTPException(401, "Ungültige Anmeldedaten")
raise HTTPException(400, "Ungültige Anmeldedaten")
resp.raise_for_status()
data = resp.json()
return data["access_token"], data.get("refresh_token", ""), data.get("expires_in", 1800)
@@ -99,7 +99,7 @@ def _ha_get_calendars(url: str, token: str) -> list:
raise HTTPException(503, "Home Assistant antwortet nicht (Timeout)")
except http_requests.exceptions.HTTPError as e:
if e.response is not None and e.response.status_code == 401:
raise HTTPException(401, "Ungültiger Access Token")
raise HTTPException(400, "Ungültiger Access Token")
raise HTTPException(502, f"Home Assistant Fehler: {e}")

View File

@@ -416,14 +416,14 @@
<label>Home Assistant URL</label>
<input type="url" id="ha-account-url" placeholder="http://homeassistant.local:8123" />
</div>
<div class="form-group">
<label>Anmeldemethode</label>
<div style="display:flex;gap:16px">
<label class="toggle-label">
<input type="radio" name="ha-auth-method" value="token" id="ha-auth-token" checked /> Long-Lived Token
<div style="margin-bottom:16px">
<div style="font-size:12px;font-weight:500;text-transform:uppercase;letter-spacing:.5px;color:var(--text-2);margin-bottom:8px">Anmeldemethode</div>
<div style="display:flex;gap:20px">
<label style="display:flex;align-items:center;gap:6px;cursor:pointer;color:var(--text-1);font-size:14px">
<input type="radio" name="ha-auth-method" value="token" id="ha-auth-token" checked style="width:auto;accent-color:var(--primary)" /> Long-Lived Token
</label>
<label class="toggle-label">
<input type="radio" name="ha-auth-method" value="password" id="ha-auth-password" /> Benutzername/Passwort
<label style="display:flex;align-items:center;gap:6px;cursor:pointer;color:var(--text-1);font-size:14px">
<input type="radio" name="ha-auth-method" value="password" id="ha-auth-password" style="width:auto;accent-color:var(--primary)" /> Benutzername/Passwort
</label>
</div>
</div>

View File

@@ -1325,6 +1325,7 @@ function bindHAAccountModal() {
saveBtn.textContent = 'Verbinde…';
try {
const account = await api.post('/homeassistant/accounts', body);
if (!account) return;
state.haAccounts.push(account);
renderCalendarList();
closeModal('modal-ha-account');