Skip to content

Commit

Permalink
Reverted polling option changes
Browse files Browse the repository at this point in the history
  • Loading branch information
LeLunZ committed May 31, 2024
1 parent 2558a4d commit 7da9df6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
7 changes: 0 additions & 7 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { HiSenseTVAccessory } from './platformAccessory';
interface DeviceConfig {
id: string;
name: string;
pollingInterval: number;
ipaddress: string;
macaddress: string;
}
Expand Down
10 changes: 2 additions & 8 deletions src/platformAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);

}

Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -327,7 +322,6 @@ export class HiSenseTVAccessory {
socket.destroy();

if (!this.deviceState.hasFetchedInputs) {
this.deviceState.hasFetchedInputs = true;
this.getSources();
} else {
this.getCurrentInput();
Expand Down

0 comments on commit 7da9df6

Please sign in to comment.