From 7da9df62f3386a86ab71c1dd79e0c797f70598e1 Mon Sep 17 00:00:00 2001 From: LeLunZ <31982496+LeLunZ@users.noreply.github.com> Date: Sat, 1 Jun 2024 01:56:16 +0200 Subject: [PATCH] Reverted polling option changes --- config.schema.json | 7 ------- src/platform.ts | 1 - src/platformAccessory.ts | 10 ++-------- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/config.schema.json b/config.schema.json index d49b7b4..7701197 100644 --- a/config.schema.json +++ b/config.schema.json @@ -43,13 +43,6 @@ "placeholder": "192.168.1.0", "description": "This plugin cannot discover TVs automatically on the local network. Make sure to set your TV with a static DHCP to the IP address you input here." }, - "pollingInterval": { - "title": "Polling interval", - "type": "integer", - "required": true, - "placeholder": 10, - "description": "This plugin needs to periodically sync with the television. The polling interval is the time between each sync. The default value is 10 seconds." - }, "macaddress": { "title": "MAC Address", "type": "string", diff --git a/src/platform.ts b/src/platform.ts index 7633fbd..b074db2 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -6,7 +6,6 @@ import { HiSenseTVAccessory } from './platformAccessory'; interface DeviceConfig { id: string; name: string; - pollingInterval: number; ipaddress: string; macaddress: string; } diff --git a/src/platformAccessory.ts b/src/platformAccessory.ts index df5c3ea..2667f4e 100644 --- a/src/platformAccessory.ts +++ b/src/platformAccessory.ts @@ -23,7 +23,6 @@ export class HiSenseTVAccessory { private inputSources: InputSource[] = []; constructor(private readonly platform: HiSenseTVPlatform, private readonly accessory: PlatformAccessory) { - let isFirstRun = true; // Start the asynchronous check of the TV status. this.checkTVStatus(); @@ -76,12 +75,8 @@ export class HiSenseTVAccessory { // Setup an interval to periodically check the TV status. setInterval(() => { - if (isFirstRun && this.deviceState.hasFetchedInputs) { - isFirstRun = false; - return; - } this.checkTVStatus(); - }, this.accessory.context.pollingInterval * 1000); + }, 10000); } @@ -275,9 +270,9 @@ export class HiSenseTVAccessory { const displayOrder = [0].concat(this.inputSources.map((_, index) => index+1)); this.service.setCharacteristic(this.platform.api.hap.Characteristic.DisplayOrder, this.platform.api.hap.encode(1, displayOrder).toString('base64')); + this.deviceState.hasFetchedInputs = true; this.getCurrentInput(); } catch (error) { - this.deviceState.hasFetchedInputs = false; this.platform.log.error('An error occurred while fetching inputs: ' + error); } } @@ -327,7 +322,6 @@ export class HiSenseTVAccessory { socket.destroy(); if (!this.deviceState.hasFetchedInputs) { - this.deviceState.hasFetchedInputs = true; this.getSources(); } else { this.getCurrentInput();