mqtt-discovery-types
Version:
Typescript Types For HomeAssistant MQTT Discovery
74 lines (65 loc) • 2.48 kB
TypeScript
export interface AvailabilityItem {
/**
* The MQTT topic subscribed to receive availability (online/offline) updates.
*/
topic: string;
/**
* The payload that represents the available state.
*
* @defaultValue 'online'
*/
payload_available?: string;
/**
* The payload that represents the unavailable state.
*
* @defaultValue 'offline'
*/
payload_not_available?: string;
/**
* Defines a template to extract device's availability from the topic.
* To determine the devices’s availability result of this template will be
* compared to `payload_available` and `payload_not_available`
*/
value_template?: string;
}
export interface AvailabilityDiscovery {
/**
* When `availability` is configured, this controls the conditions needed to set the entity to `available`.
* Valid entries are `all`, `any`, and `latest`. If set to `all`, `payload_available` must be received on all
* configured availability topics before the entity is marked as online. If set to `any`, `payload_available`
* must be received on at least one configured availability topic before the entity is marked as online. If
* set to `latest`, the last `payload_available` or `payload_not_available` received on any configured
* availability topic controls the availability.
*
* @defaultValue 'latest'
*/
availability_mode?: 'all' | 'any' | 'latest';
/**
* A list of MQTT topics subscribed to receive availability (online/offline) updates.
* Must not be used together with `availability_topic`.
*/
availability?: AvailabilityItem[];
/**
* The MQTT topic subscribed to receive availability (online/offline) updates.
* Must not be used together with `availability`.
*/
availability_topic?: string;
/**
* Defines a template to extract device's availability from the topic.
* To determine the devices’s availability result of this template will be
* compared to `payload_available` and `payload_not_available`
*/
availability_template?: string;
/**
* The payload that represents the available state.
*
* @defaultValue 'online'
*/
payload_available?: string; // default 'online'
/**
* The payload that represents the unavailable state.
*
* @defaultValue 'offline'
*/
payload_not_available?: string; // default 'offline'
}