Files
home-assistant-futurehome/futurehome/src/ha/mqtt_components/text.ts
2025-07-24 15:54:47 +02:00

266 lines
7.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Represents a MQTT Text component for Home Assistant MQTT Discovery.
*
* The `mqtt` Text platform allows you to integrate devices that show text that can be set remotely.
* Optionally the text state can be monitored too using MQTT.
*
* For detailed documentation see:
* https://www.home-assistant.io/integrations/text.mqtt/
*/
export interface TextComponent {
/**
* Must be `text`.
* Only allowed and required in [MQTT auto discovery device messages](https://www.home-assistant.io/integrations/mqtt/#device-discovery-payload).
*/
platform: 'text';
/**
* An ID that uniquely identifies this text entity.
* If two text entities have the same unique ID, Home Assistant will raise an exception.
* Required when used with device-based discovery.
*/
unique_id?: string;
/**
* The MQTT topic to publish the text value that is set.
*/
command_topic: string;
/**
* The MQTT topic subscribed to receive text state updates.
* Text state updates should match the `pattern` (if set) and meet the size constraints `min` and `max`.
* Can be used with `value_template` to render the incoming payload to a text update.
*/
state_topic?: string;
/**
* Defines a [template](https://www.home-assistant.io/docs/configuration/templating/#using-command-templates-with-mqtt)
* to generate the payload to send to `command_topic`.
*/
command_template?: string;
/**
* Defines a [template](https://www.home-assistant.io/docs/configuration/templating/#using-value-templates-with-mqtt)
* to extract the text state value from the payload received on `state_topic`.
*/
value_template?: string;
/**
* The name of the text entity.
* Can be set to `null` if only the device name is relevant.
* Default: "MQTT Text"
*/
name?: string | null;
/**
* Used instead of `name` for automatic generation of `entity_id`.
*/
object_id?: string;
/**
* The maximum size of a text being set or received (maximum is 255).
* Default: 255
*/
max?: number;
/**
* The minimum size of a text being set or received.
* Default: 0
*/
min?: number;
/**
* The mode off the text entity.
* Must be either `text` or `password`.
* Default: text
*/
mode?: 'text' | 'password';
/**
* A valid regular expression the text being set or received must match with.
*/
pattern?: string;
/**
* The encoding of the payloads received and published messages.
* Set to `""` to disable decoding of incoming payload.
* Default: "utf-8"
*/
encoding?: string;
/**
* Flag which defines if the entity should be enabled when first added.
* Default: true
*/
enabled_by_default?: boolean;
/**
* The [category](https://developers.home-assistant.io/docs/core/entity#generic-properties) of the entity.
*/
entity_category?: string;
/**
* Picture URL for the entity.
*/
entity_picture?: string;
/**
* Defines a [template](https://www.home-assistant.io/docs/configuration/templating/#using-value-templates-with-mqtt)
* to extract the JSON dictionary from messages received on the `json_attributes_topic`.
*/
json_attributes_template?: string;
/**
* The MQTT topic subscribed to receive a JSON dictionary payload and then set as entity attributes.
* Implies `force_update` of the current select state when a message is received on this topic.
*/
json_attributes_topic?: string;
/**
* A list of MQTT topics subscribed to receive availability (online/offline) updates.
* Must not be used together with `availability_topic`.
*/
availability?: Array<{
/**
* An MQTT topic subscribed to receive availability (online/offline) updates.
*/
topic: string;
/**
* The payload that represents the available state.
* Default: "online"
*/
payload_available?: string;
/**
* The payload that represents the unavailable state.
* Default: "offline"
*/
payload_not_available?: string;
/**
* Defines a [template](https://www.home-assistant.io/docs/configuration/templating/#using-value-templates-with-mqtt)
* to extract device's availability from the `topic`.
* To determine the device's availability, result of this template will be compared to `payload_available` and `payload_not_available`.
*/
value_template?: string;
}>;
/**
* When `availability` is configured, this controls the conditions needed to set the entity to `available`.
* Valid values: "all", "any", "latest"
* Default: "latest"
*/
availability_mode?: 'all' | 'any' | 'latest';
/**
* Defines a [template](https://www.home-assistant.io/docs/configuration/templating/#using-value-templates-with-mqtt)
* to extract device's availability from the `availability_topic`.
* To determine the device's availability, result of this template will be compared to `payload_available` and `payload_not_available`.
*/
availability_template?: string;
/**
* The MQTT topic subscribed to receive availability (online/offline) updates.
* Must not be used together with `availability`.
*/
availability_topic?: string;
/**
* The string that represents the `online` state.
* Default: "online"
*/
payload_available?: string;
/**
* The string that represents the `offline` state.
* Default: "offline"
*/
payload_not_available?: string;
/**
* The maximum QoS level to be used when receiving and publishing messages.
* Default: 0
*/
qos?: number;
/**
* If the published message should have the retain flag on or not.
* Default: false
*/
retain?: boolean;
/**
* Information about the device this of text capability is a part of to tie it into the [device registry](https://developers.home-assistant.io/docs/en/device_registry_index.html).
* Only works when [`unique_id`](#unique_id) is set.
* At least one of identifiers or connections must be present to identify the device.
*/
device?: {
/**
* A link to the webpage that can manage the configuration of this device.
* Can be either an `http://`, `https://` or an internal `homeassistant://` URL.
*/
configuration_url?: string;
/**
* A list of connections of the device to the outside world as a list of tuples `[connection_type, connection_identifier]`.
* For example the MAC address of a network interface:
* `"connections": [["mac", "02:5b:26:a8:dc:12"]]`.
*/
connections?: Array<[string, string]>;
/**
* The hardware version of the device.
*/
hw_version?: string;
/**
* A list of IDs that uniquely identify the device.
* For example a serial number.
*/
identifiers?: string[];
/**
* The manufacturer of the device.
*/
manufacturer?: string;
/**
* The model of the device.
*/
model?: string;
/**
* The model identifier of the device.
*/
model_id?: string;
/**
* The name of the device.
*/
name?: string;
/**
* The serial number of the device.
*/
serial_number?: string;
/**
* Suggest an area if the device isnt in one yet.
*/
suggested_area?: string;
/**
* The firmware version of the device.
*/
sw_version?: string;
/**
* Identifier of a device that routes messages between this device and Home Assistant.
* Examples of such devices are hubs, or parent devices of a sub-device.
* This is used to show device topology in Home Assistant.
*/
via_device?: string;
};
}