default_config:

logger:
    default: info
    logs:
        custom_components.versatile_thermostat: debug
        custom_components.versatile_thermostat.underlyings: debug
        custom_components.versatile_thermostat.climate: debug

# If you need to debug uncommment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
debugpy:
    start: true
    wait: false
    port: 5678

versatile_thermostat:
    auto_regulation_expert:
        kp: 0.4
        ki: 0.08
        k_ext: 0.0
        offset_max: 5
        stabilization_threshold: 0.1
        accumulated_error_threshold: 50
    short_ema_params:
        max_alpha: 0.6
        halflife_sec: 301
        precision: 3

input_number:
    fake_temperature_sensor1:
        name: Temperature
        min: 0
        max: 35
        step: .1
        icon: mdi:thermometer
        unit_of_measurement: °C
        mode: box
    fake_external_temperature_sensor1:
        name: Ext Temperature
        min: -10
        max: 35
        step: .1
        icon: mdi:home-thermometer
        unit_of_measurement: °C
        mode: box
    fake_current_power:
        name: Current power
        min: 0
        max: 1000
        step: 10
        icon: mdi:flash
        unit_of_measurement: kW
    fake_current_power_max:
        name: Current power max threshold
        min: 0
        max: 1000
        step: 10
        icon: mdi:flash
        unit_of_measurement: kW
    fake_valve1:
        name: The valve 1
        min: 0
        max: 100
        icon: mdi:pipe-valve
        unit_of_measurement: percentage

input_boolean:
    # input_boolean to simulate the windows entity. Only for development environment.
    fake_window_sensor1:
        name: Window 1
        icon: mdi:window-closed-variant
    # input_boolean to simulate the heater entity switch. Only for development environment.
    fake_heater_switch3:
        name: Heater 3
        icon: mdi:radiator
    fake_heater_switch2:
        name: Heater 2
        icon: mdi:radiator
    fake_heater_switch1:
        name: Heater 1
        icon: mdi:radiator
    fake_heater_ac1:
        name: Air contionner 1
        icon: mdi:air-conditioner
    fake_heater_4switch1:
        name: Heater (multiswitch1)
        icon: mdi:radiator
    fake_heater_4switch2:
        name: Heater (multiswitch2)
        icon: mdi:radiator
    fake_heater_4switch3:
        name: Heater (multiswitch3)
        icon: mdi:radiator
    fake_heater_4switch4:
        name: Heater (multiswitch4)
        icon: mdi:radiator
    fake_heater_4climate1:
        name: Heater (multiclimate1)
        icon: mdi:radiator
    fake_heater_4climate2:
        name: Heater (multiclimate2)
        icon: mdi:radiator
    fake_heater_4climate3:
        name: Heater (multiclimate3)
        icon: mdi:radiator
    fake_heater_4climate4:
        name: Heater (multiclimate4)
        icon: mdi:radiator
    # input_boolean to simulate the motion sensor entity. Only for development environment.
    fake_motion_sensor1:
        name: Motion Sensor 1
        icon: mdi:run
    # input_boolean to simulate the presence sensor entity. Only for development environment.
    fake_presence_sensor1:
        name: Presence Sensor 1
        icon: mdi:home

climate:
    - platform: generic_thermostat
      name: Underlying thermostat1
      heater: input_boolean.fake_heater_switch3
      target_sensor: input_number.fake_temperature_sensor1
    - platform: generic_thermostat
      name: Underlying thermostat2
      heater: input_boolean.fake_heater_switch3
      target_sensor: input_number.fake_temperature_sensor1
    - platform: generic_thermostat
      name: Underlying thermostat3
      heater: input_boolean.fake_heater_switch3
      target_sensor: input_number.fake_temperature_sensor1
    - platform: generic_thermostat
      name: Underlying thermostat4
      heater: input_boolean.fake_heater_switch3
      target_sensor: input_number.fake_temperature_sensor1
    - platform: generic_thermostat
      name: Underlying thermostat 4-1
      heater: input_boolean.fake_heater_4climate1
      target_sensor: input_number.fake_temperature_sensor1
      ac_mode: false
    - platform: generic_thermostat
      name: Underlying thermostat 4-2
      heater: input_boolean.fake_heater_4climate2
      target_sensor: input_number.fake_temperature_sensor1
      ac_mode: false
    - platform: generic_thermostat
      name: Underlying thermostat 4-3
      heater: input_boolean.fake_heater_4climate3
      target_sensor: input_number.fake_temperature_sensor1
      ac_mode: false
    - platform: generic_thermostat
      name: Underlying thermostat 4-4
      heater: input_boolean.fake_heater_4climate4
      target_sensor: input_number.fake_temperature_sensor1
      ac_mode: false
    - platform: generic_thermostat
      name: Underlying thermostat9
      heater: input_boolean.fake_heater_switch3
      target_sensor: input_number.fake_temperature_sensor1

recorder:
    include:
        domains:
            - input_boolean
            - input_number
            - switch
            - climate
            - sensor

template:
    - binary_sensor:
          - name: maison_occupee
            unique_id: maison_occupee
            state: "{{is_state('person.jmc', 'home') }}"
            device_class: occupancy
    - sensor:
          - name: "Total énergie switch1"
            unique_id: total_energie_switch1
            unit_of_measurement: "kWh"
            device_class: energy
            state_class: total_increasing
            state: >
                {% set energy = state_attr('climate.thermostat_switch_1', 'total_energy') | float(default=-1) %}
                {% if energy < 0 %}{{none}}{% else %}
                  {{ energy | round(2, default=0) }}
                {% endif %}
          - name: "Total énergie climate 2"
            unique_id: total_energie_climate2
            unit_of_measurement: "kWh"
            device_class: energy
            state_class: total_increasing
            state: >
                {% set energy = state_attr('climate.thermostat_climate_2', 'total_energy') | float(default=-1) %}
                {% if energy < 0 %}{{none}}{% else %}
                  {{ energy | round(2, default=0) }}
                {% endif %}
          - name: "Total énergie chambre"
            unique_id: total_energie_chambre
            unit_of_measurement: "kWh"
            device_class: energy
            state_class: total_increasing
            state: >
                {% set energy = state_attr('climate.thermostat_chambre', 'total_energy') | float(default=-1) %}
                {% if energy < 0 %}{{none}}{% else %}
                  {{ energy | round(2, default=0) }}
                {% endif %}

switch:
    - platform: template
      switches:
          pilote_sdb_rdc:
              friendly_name: "Pilote chauffage SDB RDC"
              value_template: "{{ is_state_attr('switch_seche_serviettes_sdb_rdc', 'sensor_state', 'on') }}"
              turn_on:
                  service: select.select_option
                  data:
                      option: comfort
                  target:
                      entity_id: select.seche_serviettes_sdb_rdc_cable_outlet_mode

              turn_off:
                  service: select.select_option
                  data:
                      option: comfort-2
                  target:
                      entity_id: select.seche_serviettes_sdb_rdc_cable_outlet_mode

frontend:
    extra_module_url:
        - /config/www/community/versatile-thermostat-ui-card/versatile-thermostat-ui-card.js
    themes:
        versatile_thermostat_theme:
            state-binary_sensor-safety-on-color: "#FF0B0B"
            state-binary_sensor-power-on-color: "#FF0B0B"
            state-binary_sensor-window-on-color: "rgb(156, 39, 176)"
            state-binary_sensor-motion-on-color: "rgb(156, 39, 176)"
            state-binary_sensor-presence-on-color: "lightgreen"
            state-binary_sensor-running-on-color: "orange"
