From 5cbebd8beb68f800f84a6e0e8e4a87e9cb420b5f Mon Sep 17 00:00:00 2001 From: Luis Nachtigall <31982496+LeLunZ@users.noreply.github.com> Date: Mon, 3 Jun 2024 18:12:11 +0200 Subject: [PATCH] Fix crashes (#61) * fix for possible crash --- src/platformAccessory.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/platformAccessory.ts b/src/platformAccessory.ts index bae94c4..3f7ef9a 100644 --- a/src/platformAccessory.ts +++ b/src/platformAccessory.ts @@ -83,7 +83,6 @@ export class HiSenseTVAccessory { setInterval(() => { this.checkTVStatus(); }, 10000); - } async getOn(): Promise { @@ -236,6 +235,7 @@ export class HiSenseTVAccessory { this.platform.log.debug('Fetching input sources...'); if (!this.deviceState.isConnected) { this.platform.log.info('Unable to fetch input sources because the TV is off. Will retry as soon as the device comes back online.'); + this.deviceState.hasFetchedInputs = false; return; } @@ -279,6 +279,7 @@ export class HiSenseTVAccessory { this.getCurrentInput(); } catch (error) { this.platform.log.error('An error occurred while fetching inputs: ' + error); + this.deviceState.hasFetchedInputs = false; } } @@ -327,6 +328,7 @@ export class HiSenseTVAccessory { socket.destroy(); if (!this.deviceState.hasFetchedInputs) { + this.deviceState.hasFetchedInputs = true; this.getSources(); } else { this.getCurrentInput();