import type { CommandEntityDiscovery } from "./BaseEntityDiscovery.js";

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

export interface FanDiscovery extends CommandEntityDiscovery {
    /**
     * The MQTT topic subscribed to receive state updates.
     */
    state_topic: string;

    /**
     * Defines a template to extract a value from the payload.
     */
    state_value_template?: string;

    /**
     * Flag that defines if the fan works in optimistic mode.
     * @defaultValue true if no state_topic defined, else false.
     */
    optomistic?: boolean;

    /**
     * Defines a template to generate the payload to send to `direction_command_topic`.
     * Entity variable `value` will be either `forward` or `reverse`.
     */
    direction_command_template?: string;

    /**
     * The topic to publish direction commands to.
     */
    direction_command_topic?: string;

    /**
     * The topic to listen to for direction state updates.
     */
    direction_state_topic?: string;

    /**
     * Defines a template to extract a direction (`forward` or `reverse`) from 
     * the values delivered to`direction_state_topic`.
     */
    direction_value_template?: string;

    /**
     * The topic to publish oscillation commands to.
     */
    oscillation_command_topic?: string;

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

    /**
     * The topic to listen to for oscillation state updates.
     */
    oscillation_state_topic?: string;

    /**
     * Defines a template to extract the oscillation state (as defined in `payload_oscillation_on` and `payload_oscillation_off`) from 
     * the values delivered to`oscillation_state_topic`.
     */
    oscillation_value_template?: string;

    /**
     * @defaultValue 'OFF'
     */
    payload_off?: string;

    /**
     * @defaultValue 'ON'
     */
    payload_on?: string;

    /**
     * @defaultValue 'oscillate_off'
     */
    payload_osciallation_off?: string;

    /**
     * @defaultValue 'oscillate_on'
     */
    payload_osciallation_on?: string;

    /**
     * A special payload that resets the perceentage state attribute to unknown when received at the `percentage_state_topic`.
     * @defaultValue 'None'
     */
    payload_reseet_percentage?: string;

    percentage_command_template?: string;
    percentage_command_topic?: string;
    percentage_state_topic?: string;
    percentage_value_template?: string;

    preset_mode_command_template?: string;
    preset_mode_command_topic?: string;
    preset_mode_state_topic?: string;
    preset_mode_value_template?: string;
    preset_modes?: string[];

    /** 
    * The minimum of numeric output range (representing 0 %).   
    * @defaultValue 1
    */
    speed_range_min?: number;

    /** 
     * The maximum of numeric output range (representing 100 %).
     * The number of speeds within the speed_range / 100 will determine the percentage_step.
     * @defaultValue 100
     * */
    speed_range_max?: number;
}