import { CharacteristicValue, PlatformAccessory } from 'homebridge'; import { HiSenseTVPlatform } from './platform.js'; import { TVState } from './interfaces/tv-state.interface.js'; import { InputSource } from './interfaces/input-source.interface.js'; import { PictureSetting } from './interfaces/picturesetting.interface.js'; import { TVApp } from './interfaces/tv-app.interface.js'; /** * Platform Accessory * An instance of this class is created for each accessory your platform registers * Each accessory may expose multiple services of different service types. */ export declare class HiSenseTVAccessory { private readonly platform; private readonly accessory; private readonly publishCallback?; private Characteristic; private Service; private log; private wol; private inputSourceSubPlatformAccessory; private service; private speakerService; private mqttHelper; private deviceConfig; /** * Counter to keep track of how many times the TV state has been checked and its not yet correct. * * When turning off the TV offCounter is set to -1, it means the TV should be off. * at the same time onCounter is set to 0, and everytime the tv is still on in the polling phase, it will be incremented. * if onCounter reaches 8, the TV will be considered on. (means the TV didn't turn off) * * The same applies for turning on the TV, but with onCounter set to -1 and increasing offCounter. * * This is done to prevent false positives/negatives when checking the TV state. */ private offCounter; private onCounter; /** * Counter threshold to determine if the TV is on or off. * 8 seconds seems reasonable, as the TV should respond faster. */ private counterThreshold; private deviceState; private inputSources; private availableApps; private isPublished; private hasReceivedInitialSources; private hasReceivedInitialApps; private readonly storagePath; constructor(platform: HiSenseTVPlatform, accessory: PlatformAccessory, publishCallback?: (() => void) | undefined); private schedulePoll; private maybePublish; setupMqtt(): void; setTVPowerStateOff(): void; setTVPowerStateOn(): void; setOn(value: CharacteristicValue): Promise; /** * Sets the power state of the TV based on the always on picture settings of the tv. * These must be configured beforehand in the Homebridge config. * There is an attached script to help with this. * @param settings */ setAlwaysOnPictureSettingsPowerState(settings: PictureSetting): void; setRemoteKey(newValue: CharacteristicValue): Promise; setMute(): Promise; setVolume(value: CharacteristicValue): Promise; setCurrentApplication(value: CharacteristicValue): Promise; /** * Save the list of inputs for the TV. * * This function takes the list of inputs from the TV and a list of apps and creates a HomeKit input. * It will automatically get the display name from each input and use that as name in HomeKit. */ createSources(sources: InputSource[], apps: TVApp[]): void; /** * Create the 'Other' source to support unknown sources being displayed on the TV. * * There are multiple cases where it is not possible to fetch the current source on the TV, * for example when running apps like Netflix. In this case, the plugin will select this input * and show that in HomeKit. * * Switching to this input is unsupported. */ createHomeSource(): void; /** * Check the current TV status by attempting to connect to the mqtt port. * * Instead of trying to reconnect the mqtt client every few seconds, it is way faster and lighter to just * try to connect to the MQTT Socket and then disconnect immediately. * If the connection succeeds, the mqtt connection will be reestablished, otherwise it will be closed. * * There is also a counter to prevent false positives/negatives when checking the TV state. * Check the documentation of the counter for more information. */ checkTVStatus(done: () => void): void; /** * Sets the current input based on the state received from the TV. * * At the moment, only the following states are supported: * - `sourceswitch`: any external input (i.e. HDMIs, AV). * - `livetv`: the tuner. * - `app`: any app running on the TV. * * Any other state will be matched as the "Unknown" input. */ setCurrentInput(input: TVState): void; /** * Get the index of the current input by matching the current input name to the * list of HomeKit inputs and apps. * * If the current input cannot be found, this function will return `0`. * * @returns The index of the current input in HomeKit. */ getCurrentInputIndex(): number; /** * Get the list of apps that should be displayed in HomeKit. * showApps needs to be enabled in the config for this to work. * If no apps are specified, all apps will be displayed. * @param apps */ getFilteredApps(apps: TVApp[]): TVApp[]; /** * Special case for always on TVs with the tvType fakeSleep. * This will set the TV to the correct state based on the state received from the TV. * @param tvState * @private */ private setAlwaysOnFakeSleepState; }