reload:
    name: Reload
    description: Reload all Versatile Thermostat entities.

set_presence:
    name: Set presence
    description: Force the presence mode in thermostat
    target:
        entity:
            integration: versatile_thermostat
    fields:
        presence:
            name: Presence
            description: Presence setting
            required: true
            advanced: false
            example: "on"
            default: "on"
            selector:
                select:
                    options:
                        - "on"
                        - "off"
                        - "home"
                        - "not_home"

set_safety:
    name: Set safety
    description: Change the safety parameters
    target:
        entity:
            integration: versatile_thermostat
    fields:
        delay_min:
            name: Delay in minutes
            description: Maximum allowed delay in minutes between two temperature mesures
            required: false
            advanced: false
            example: "30"
            selector:
                number:
                    min: 0
                    max: 9999
                    unit_of_measurement: "min"
                    mode: box
        min_on_percent:
            name: Minimal on_percent
            description: Minimal heating percent value for safety preset activation
            required: false
            advanced: false
            example: "0.5"
            default: "0.5"
            selector:
                number:
                    min: 0
                    max: 1
                    step: 0.05
                    unit_of_measurement: "%"
                    mode: slider
        default_on_percent:
            name: on_percent used in safety mode
            description: The default heating percent value in safety preset
            required: false
            advanced: false
            example: "0.1"
            default: "0.1"
            selector:
                number:
                    min: 0
                    max: 1
                    step: 0.05
                    unit_of_measurement: "%"
                    mode: slider

set_window_bypass:
    name: Set Window ByPass
    description: Bypass the window state to enable heating with window open.
    target:
        entity:
            integration: versatile_thermostat
    fields:
        window_bypass:
            name: Window ByPass
            description: ByPass value
            required: true
            advanced: false
            default: true
            selector:
                boolean:

set_auto_regulation_mode:
    name: Set Auto Regulation mode
    description: Change the mode of self-regulation (only for VTherm over climate)
    target:
        entity:
            integration: versatile_thermostat
    fields:
        auto_regulation_mode:
            name: Auto regulation mode
            description: Possible values
            required: true
            advanced: false
            default: true
            selector:
                select:
                    options:
                        - "None"
                        - "Light"
                        - "Medium"
                        - "Strong"
                        - "Slow"
                        - "Expert"

set_auto_fan_mode:
    name: Set Auto Fan mode
    description: Change the mode of auto-fan (only for VTherm over climate)
    target:
        entity:
            integration: versatile_thermostat
    fields:
        auto_fan_mode:
            name: Auto fan mode
            description: Possible values
            required: true
            advanced: false
            default: true
            selector:
                select:
                    options:
                        - "None"
                        - "Low"
                        - "Medium"
                        - "High"
                        - "Turbo"

set_hvac_mode_sleep:
    name: Set HVAC Mode to Sleep
    description: Turns a VTherm climate into seasonal sleep - OFF with valve 100% open (only for VTherm over climate with valve regulation).
    target:
        entity:
            integration: versatile_thermostat

lock:
    name: Lock
    description: "Locks the thermostat, preventing any changes to its configuration from UI or automations."
    target:
        entity:
            integration: versatile_thermostat

    fields:
        code:
            name: Lock code
            description: The optional lock code
            required: false
            advanced: false
            example: "1234"
            selector:
                text:
                    type: password

unlock:
    name: Unlock
    description: "Unlocks the thermostat, allowing changes to its configuration."
    target:
        entity:
            integration: versatile_thermostat
    fields:
        code:
            name: Lock code
            description: The optional lock code
            required: false
            advanced: false
            example: "1234"
            selector:
                text:
                    type: password

set_tpi_parameters:
    name: Set TPI parameters
    description: Change the TPI parameters
    target:
        entity:
            integration: versatile_thermostat
    fields:
        tpi_coef_int:
            name: Coef Int
            description: Coefficient Integral
            required: false
            advanced: false
            example: "0.6"
            selector:
                number:
                    min: 0
                    max: 10
                    step: 0.01
                    mode: box
        tpi_coef_ext:
            name: Coef Ext
            description: Coefficient External
            required: false
            advanced: false
            example: "0.01"
            selector:
                number:
                    min: 0
                    max: 1
                    step: 0.001
                    mode: box
        minimal_activation_delay:
            name: Minimal Activation delay
            description: Delay in seconds under which the equipment will not be activated
            required: false
            advanced: true
            example: "10"
            selector:
                number:
                    min: 0
                    max: 1000
                    step: 1
                    mode: box
                    unit_of_measurement: "seconds"
        minimal_deactivation_delay:
            name: Minimal Deactivation delay
            description: Delay in seconds under which the equipment will be kept active
            required: false
            advanced: true
            example: "10"
            selector:
                number:
                    min: 0
                    max: 1000
                    step: 1
                    mode: box
                    unit_of_measurement: "seconds"
        tpi_threshold_low:
            name: Low TPI threshold
            description: Threshold in ° under which the TPI algorithm will be on. 0 means no threshold
            required: false
            advanced: false
            example: "0.1"
            selector:
                number:
                    min: -10
                    max: 10
                    step: 0.1
                    mode: box
                    unit_of_measurement: "°"
        tpi_threshold_high:
            name: High TPI threshold
            description: Threshold in ° above which the TPI algorithm will be off. 0 means no threshold
            required: false
            advanced: false
            example: "0.1"
            selector:
                number:
                    min: -10
                    max: 10
                    step: 0.1
                    mode: box
                    unit_of_measurement: "°"

set_auto_tpi_mode:
    name: Set Auto TPI mode
    description: Enable or disable the Auto TPI learning mode.
    target:
        entity:
            integration: versatile_thermostat
            domain:
                - climate
    fields:
        auto_tpi_mode:
            name: Auto TPI mode
            description: Enable (true) or disable (false) the Auto TPI learning
            required: true
            advanced: false
            default: true
            selector:
                boolean:
        reinitialise:
            name: Reset learning data
            description: Reset all learning data when enabling Auto TPI mode (default is true)
            required: false
            advanced: false
            default: true
            selector:
                boolean:
        allow_kint_boost_on_stagnation:
            name: Allow Kint boost
            description: Allow boosting Kint when temperature stagnates despite demand (default false)
            required: true
            advanced: false
            default: false
            selector:
                boolean:
        allow_kext_compensation_on_overshoot:
            name: Allow Kext compensation
            description: Allow adjusting Kext when temperature overshoots (default false)
            required: true
            advanced: false
            default: false
            selector:
                boolean:


auto_tpi_calibrate_capacity:
    name: Auto Tpi Calibrate Capacity
    description: Calibrate the heating/cooling capacity (in min/°) using linear regression on the entity's history data.
    target:
        entity:
            integration: versatile_thermostat
            domain:
                - climate
    fields:
        start_date:
            name: History from date
            description: Date from which to retrieve history (default is 30 days ago)
            required: false
            advanced: false
            example: "2023-11-01"
            selector:
                date:
        end_date:
            name: History to date
            description: Date until which to retrieve history (default is now)
            required: false
            advanced: false
            example: "2023-12-01"
            selector:
                date:
        min_power_threshold:
            name: Minimum Power Threshold
            description: Minimum power percentage to consider a cycle as saturated (default 95%). Lower values (e.g., 90%) will include more cycles but may be less accurate.
            required: true
            default: 95
            advanced: true
            example: 95
            selector:
                number:
                    min: 80
                    max: 100
                    step: 1
                    unit_of_measurement: "%"
                    mode: slider
        save_to_config:
            name: Save to Config
            description: Whether to apply the calculated capacity to the entity's configuration
            required: true
            advanced: false
            example: true
            selector:
                boolean:

set_timed_preset:
    name: Set Timed Preset
    description: Force a preset for a given duration. After the duration expires, the original preset will be restored.
    target:
        entity:
            integration: versatile_thermostat
            domain:
                - climate
    fields:
        preset:
            name: Preset
            description: The preset to apply temporarily
            required: true
            advanced: false
            example: "boost"
            selector:
                text:
        duration_minutes:
            name: Duration (minutes)
            description: Duration in minutes for which the preset will be active
            required: true
            advanced: false
            example: 30
            default: 30
            selector:
                number:
                    min: 1
                    max: 1440
                    step: 1
                    unit_of_measurement: "min"
                    mode: box

cancel_timed_preset:
    name: Cancel Timed Preset
    description: Cancel any active timed preset and restore the original preset.
    target:
        entity:
            integration: versatile_thermostat
            domain:
                - climate

recalibrate_valves:
    name: Recalibrate valves
    description: Recalibrate opening/closing degrees for all valve underlyings of a VTherm (only over_climate_valve).
    target:
        entity:
            integration: versatile_thermostat
            domain:
                - climate
    fields:
        delay_seconds:
            name: Delay seconds
            description: Delay in seconds between open and close step for each valve
            required: true
            example: 5
            default: 60
            selector:
                number:
                    min: 30
                    max: 300

download_logs:
    name: Download logs
    description: Collect and download filtered logs for a VTherm entity.
    target:
        entity:
            integration: versatile_thermostat
            domain:
                - climate
    fields:
        log_level:
            name: Log level
            description: Minimum log level to include
            required: false
            default: "DEBUG"
            selector:
                select:
                    options:
                        - "DEBUG"
                        - "INFO"
                        - "WARNING"
                        - "ERROR"
        period_start:
            name: Period start
            description: Start of the extraction period (default is 60 minutes ago)
            required: false
            selector:
                datetime:
        period_end:
            name: Period end
            description: End of the extraction period (default is now)
            required: false
            selector:
                datetime:
