import type { CommandComponentDiscovery } from "./BaseEntityDiscovery.ts";
import {MakeEntity} from './utils';

/**
 * @see https://www.home-assistant.io/integrations/humidifier.mqtt/
 * */

export interface HumidifierComponentDiscovery extends CommandComponentDiscovery {
	platform: 'humidifier';
	/**
	 * A template to render the value received on the `action_topic` with.
	 */
	action_template?: string;

	/**
	 * The MQTT topic subscribed for changes of the current action.
	 * Valid values are `off`, 'humidifying', 'drying', 'idle'.
	 */
	action_topic?: string;

	/**
	 * A template with which the payload of the `current_humidity_topic` will be rendered.
	 */
	current_humidity_template?: string;
	/**
	 * The MQTT topic subscribed for changes of the current humidity.
	 * A "None" value will reset the current humidity.
	 * Empty values will be ignored.
	 */
	current_humidity_topic?: string;

	/**
	 * The maximum target humidity percentage that can be set.
	 * @defaultValue 100
	 */
	max_humidity?: number;

	/**
	 * The minimum target humidity percentage that can be set.
	 * @defaultValue 0
	 */
	min_humidity?: number;

	/**
	 * Flag that defines if the humidifier works in optimistic mode.
	 */
	optimistic?: boolean;

	/**
	 * Payload that represents the `off` state.
	 */
	payload_off?: string;

	/**
	 * Payload that represents the `on` state.
	 */
	payload_on?: string;

	/**
	 * A special payload that resets the `target_humidity` state attriibute to
	 * an unknown state when received at the `target_humidity_state_topic`.
	 * When received at the `target_humidity_state_topic` it will reset the
	 * the current humidity to an unknown state.
	 * @defaultValue 'None'
	 */
	payload_reset_humidity?: string;

	/**
	 * A special payload that resets the `mode` state attriibute to
	 * an unknown state when received at the `mode_state_topic`.
	 * @defaultValue 'None'
	 */
	payload_reset_mode?: string;

	/**
	 * Defines a template to generate the payload to send to `target_humidity_command_topic`.
	 */
	target_humidity_command_template?: string;

	/**
	 * The MQTT topic to publish commands to change the humidifier target humidity state 
	 * based on a percentage.
	 */
	target_humidity_command_topic: string;

	/**
	 * Defines a template to extract a value for the `target_humidity` state attribute.
	 */
	target_humidity_state_template?: string;

	/**
	 * The MQTT topic subscribed for changes of the target humidity.
	 */
	target_humidity_state_topic?: string;

	/**
	 * Defines a template to generate the payload to send to `mode_command_topic`.
	 */
	mode_command_template?: string;

	/**
	 * The MQTT topic to publish commands to change the humidifier mode.
	 */
	mode_command_topic?: string;

	/**
	 * Defines a template to extract a value for the `mode` state attribute.
	 */
	mode_state_template?: string;

	/**
	 * The MQTT topic subscribed for changes of the mode.
	 */
	mode_state_topic?: string;

	/**
	 * A list of supported modes this humidifier is capable of running at.
	 * Common examples are `normal`, `eco`, `away`, `boost`, `comfort`, `home`, `sleep`.
	 */
	modes?: string[];

	/**
	 * The MQTT topic subscribed for changes of the current state.
	 */
	state_topic?: string;

	/**
	 * Defines a template to extract a value for the `state` state attribute.
	 */
	state_value_template?: string;
}

export type HumidifierDiscovery = MakeEntity<HumidifierComponentDiscovery>;
