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

/** 
*   @see https://www.home-assistant.io/integrations/sensor/#device-class
*/
export type SensorDeviceClass = 
'None' |
'apparent_power' |
'aqi' |
'atmospheric_pressure' |
'battery' |
'carbon_dioxide' |
'carbon_monoxide' |
'current' |
'data_rate' |
'data_size' |
'date' |
'distance' |
'duration' |
'energy' |
'energy_storage' |
'enum' |
'frequency' |
'gas' |
'humidity' |
'illuminance' |
'irradiance' |
'moisture' |
'monetary' |
'nitrogen_dioxide' |
'nitrogen_monoxide' |
'nitrous_oxide' |
'ozone' |
'ph' |
'pm1' |
'pm10' |
'pm25' |
'power' |
'power_factor' |
'precipitation' |
'precipitation_intensity' |
'pressure' |
'reactive_power' |
'signal_strength' |
'sound_pressure' |
'speed' |
'sulfur_dioxide' |
'temperature' |
'timestamp' |
'volatile_organic_compounds' |
'volatile_organic_componds_parts' |
'voltage' |
'volume' |
'volume_storage' |
'water' |
'weight' |
'wind_speed';

export type SensorStateClass = 'measurement' | 'total_increasing' | 'total';

export type SensorDiscovery = MakeEntity<SensorComponentDiscovery>;

/**
 * @see https://www.home-assistant.io/integrations/sensor.mqtt/#configuration-variables
 */
export interface SensorComponentDiscovery extends StatefulComponentDiscovery {
    platform: 'sensor';
    device_class?: SensorDeviceClass;

    /**
     * If set, it defines the number of seconds after the sensor’s state expires, 
     * if it’s not updated. After expiry, the sensor’s state becomes unavailable. 
     * Default the sensors state never expires.
     */
    expire_after?: number;

    /**
     * Sends update events even if the value hasn’t changed.
     *  Useful if you want to have meaningful value graphs in history.
     */
    force_update?: boolean;

    /**
     * Defines a template to extract the last_reset. Available variables: entity_id. 
     * The entity_id can be used to reference the entity’s attributes.
     */
    last_reset_value_template?: string;

    /**
     * Number of decimals which should be used in the sensor's state after rounding.
     */
    suggested_display_precision?: number;

    /**
     * Defines the units of measurement of the sensor, if any. The unit_of_measurement can be null.
     */
    unit_of_measurement?: string;
}
