Restart the add-on when disconnected from the hub or Home Assistant

This commit is contained in:
Adrian Jagielak
2025-07-28 16:14:36 +02:00
parent 0d993643fb
commit e0b18b304c
5 changed files with 27 additions and 2 deletions

View File

@@ -124,11 +124,14 @@ export class DemoFimpMqttClient implements IMqttClient {
once(event: 'connect', handler: () => void): void;
once(event: 'error', handler: OnErrorCallback): void;
once(event: 'disconnect', handler: () => void): void;
once(event: any, handler: any): void {
if (event === 'connect') {
this.onceConnectHandlers.push(handler);
} else if (event === 'error') {
this.onceErrorHandlers.push(handler);
} else if (event === 'disconnect') {
// not possible in demo mode
}
}

View File

@@ -40,4 +40,5 @@ export interface IMqttClient {
once(event: 'connect', handler: () => void): void;
once(event: 'error', handler: OnErrorCallback): void;
once(event: 'disconnect', handler: () => void): void;
}

View File

@@ -62,6 +62,7 @@ export class RealMqttClient implements IMqttClient {
once(event: 'connect', handler: () => void): void;
once(event: 'error', handler: OnErrorCallback): void;
once(event: 'disconnect', handler: () => void): void;
once(event: any, handler: any): void {
this.client.once(event, handler);
}