Skip to content

Commit 08687d5

Browse files
author
Fabian Kirchweger
committed
v3.0.2: add login retry limit (3 attempts) + retry button, update Discord link
- After 3 failed token logins, connection stops (prevents HA IP ban) - Retry button in UI for manual reconnection after token fix - Error message shown to user on login failure - Discord invite link updated to new server - Version bump: 3.0.1 → 3.0.2
1 parent e7db2a5 commit 08687d5

12 files changed

Lines changed: 122 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [v3.0.2] - 2026-05-12
4+
- 🔒 **Login-Retry-Limit:** Nach 3 fehlgeschlagenen Token-Logins wird die Verbindung gestoppt (verhindert HA IP-Ban)
5+
- 🔄 **Retry-Button:** Manuelles Neuverbinden nach Token-Korrektur über Einstellungen
6+
- 🔗 **Discord-Link aktualisiert:** Neuer Server-Invite-Link (discord.gg/7G2SqpXpsC)
7+
38
## [v3.0.7] - 2026-04-22
49
- 📖 **Doku aktualisiert:** README_EN komplett auf v3.0-Stand gebracht
510
- 📷 **Webcam-Sensor** korrekt dokumentiert

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.7
1+
3.0.2

src/HaDeskLink/DeskLinkApp.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ private void StartWebSocket(Config config, HaApiClient api)
7777
cmd => { try { _ = CommandHandler.ExecuteAsync(cmd); } catch { } }
7878
);
7979

80+
// Pass WS to MainWindow for retry button
81+
if (desktop.MainWindow is Views.MainWindow mw)
82+
mw.SetWebSocketClient(_ws);
83+
8084
_ = Task.Run(async () =>
8185
{
8286
try { await _ws.ConnectAsync(); }

src/HaDeskLink/HaDeskLink.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetFramework>net8.0</TargetFramework>
66
<AssemblyName>HA_DeskLink</AssemblyName>
77
<RootNamespace>HaDeskLink</RootNamespace>
8-
<Version>3.0.7</Version>
8+
<Version>3.0.2</Version>
99
<Nullable>enable</Nullable>
1010
<RuntimeIdentifier>osx-arm64</RuntimeIdentifier>
1111
</PropertyGroup>

src/HaDeskLink/HaWebSocketClient.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ public class HaWebSocketClient : IDisposable
3939

4040
public bool IsConnected => _connected;
4141

42+
private int _authFailCount;
43+
private const int MaxAuthFailures = 3;
44+
/// <summary>Whether retries are blocked due to too many login failures.</summary>
45+
public bool IsBlocked => _authFailCount >= MaxAuthFailures;
46+
/// <summary>Reset the login block so the WebSocket can attempt to reconnect.</summary>
47+
public void ResetLoginBlock()
48+
{
49+
_authFailCount = 0;
50+
_connected = false;
51+
}
52+
4253
public HaWebSocketClient(string haUrl, string token, string webhookId, object? trayIcon, Action<string>? onCommand = null)
4354
{
4455
_haUrl = haUrl.TrimEnd('/');
@@ -54,6 +65,14 @@ public async Task ConnectAsync()
5465

5566
while (!_cts.Token.IsCancellationRequested)
5667
{
68+
// Check if login is blocked before attempting connection
69+
if (IsBlocked)
70+
{
71+
Console.WriteLine($"⛔ Login blockiert nach {MaxAuthFailures} fehlgeschlagenen Versuchen. Token zurücksetzen oder Einstellungen prüfen.");
72+
await Task.Delay(60000, _cts.Token);
73+
continue;
74+
}
75+
5776
try
5877
{
5978
_ws = new ClientWebSocket();
@@ -68,8 +87,18 @@ public async Task ConnectAsync()
6887

6988
msg = await ReceiveMessage();
7089
if (msg == null || !msg.Contains("auth_ok"))
71-
throw new Exception("Auth failed");
90+
{
91+
// Auth failed – this is likely an invalid token
92+
_authFailCount++;
93+
if (_authFailCount >= MaxAuthFailures)
94+
{
95+
Console.WriteLine($"⛔ {MaxAuthFailures} fehlgeschlagene Login-Versuche. Verbindung gestoppt. Bitte Token in Einstellungen prüfen.");
96+
}
97+
throw new Exception("Auth failed: " + (msg ?? "no response"));
98+
}
7299

100+
// Auth succeeded – reset failure count
101+
_authFailCount = 0;
73102
_connected = true;
74103

75104
await SendMessage(new

src/HaDeskLink/Lang/de.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,7 @@
5959
"screenshot_saved": "Screenshot saved",
6060
"webcam_active": "Webcam Active",
6161
"notification_action_executed": "Action executed",
62-
"ha_desklink_version": "HA DeskLink Version"
62+
"ha_desklink_version": "HA DeskLink Version",
63+
"login_failed": "Login fehlgeschlagen. Token ungültig. Bitte überprüfe deinen Home Assistant Token in den Einstellungen.",
64+
"retry_connect": "Erneut verbinden"
6365
}

src/HaDeskLink/Lang/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,7 @@
5959
"screenshot_saved": "Screenshot saved",
6060
"webcam_active": "Webcam Active",
6161
"notification_action_executed": "Action executed",
62-
"ha_desklink_version": "HA DeskLink Version"
62+
"ha_desklink_version": "HA DeskLink Version",
63+
"login_failed": "Login failed. Invalid token. Please check your Home Assistant token in settings.",
64+
"retry_connect": "Retry connection"
6365
}

src/HaDeskLink/Lang/es.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,7 @@
5959
"screenshot_saved": "Screenshot saved",
6060
"webcam_active": "Webcam Active",
6161
"notification_action_executed": "Action executed",
62-
"ha_desklink_version": "HA DeskLink Version"
62+
"ha_desklink_version": "HA DeskLink Version",
63+
"login_failed": "Error de inicio de sesión. Token no válido. Verifica tu token de Home Assistant en la configuración.",
64+
"retry_connect": "Reintentar conexión"
6365
}

src/HaDeskLink/Lang/fr.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,7 @@
5959
"screenshot_saved": "Screenshot saved",
6060
"webcam_active": "Webcam Active",
6161
"notification_action_executed": "Action executed",
62-
"ha_desklink_version": "HA DeskLink Version"
62+
"ha_desklink_version": "HA DeskLink Version",
63+
"login_failed": "Échec de connexion. Token invalide. Vérifiez votre token Home Assistant dans les paramètres.",
64+
"retry_connect": "Réessayer"
6365
}

src/HaDeskLink/Lang/ja.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,7 @@
5959
"screenshot_saved": "Screenshot saved",
6060
"webcam_active": "Webcam Active",
6161
"notification_action_executed": "Action executed",
62-
"ha_desklink_version": "HA DeskLink Version"
62+
"ha_desklink_version": "HA DeskLink Version",
63+
"login_failed": "ログイン失敗。トークンが無効です。設定でHome Assistantトークンを確認してください。",
64+
"retry_connect": "再接続"
6365
}

0 commit comments

Comments
 (0)