name: Combo heat pump
products:
  - id: kjf6gjn1kaawfyjk
    manufacturer: Chiltrix
    model: CX50

entities:
  # PRIMARY HVAC (CLIMATE)
  - entity: climate
    name: Air
    dps:
      # Power control
      - id: 126
        type: boolean
        name: hvac_mode
        mapping:
          - dps_val: false
            value: "off"
            available: water_off
          - dps_val: true
            constraint: mode
            conditions:
              - dps_val: "cool"
                value: cool
                available: water_off
              - dps_val: "heat"
                value: heat
                available: water_off
              - dps_val: "dhw"
                value: "off"
                available: water_on
              - dps_val: "cool_dhw"
                value: cool
                available: water_on
              - dps_val: "heat_dhw"
                value: heat
                available: water_on

      # Mode enum
      - id: 130
        type: string
        name: mode
        hidden: true

      # Helper: water heating inactive
      - id: 130
        type: string
        name: water_off
        hidden: true
        mapping:
          - dps_val: "cool"
            value: true
          - dps_val: "heat"
            value: true
          - value: false

      # Helper: water heating active
      - id: 130
        type: string
        name: water_on
        hidden: true
        mapping:
          - dps_val: "dhw"
            value: true
          - dps_val: "cool_dhw"
            value: true
          - dps_val: "heat_dhw"
            value: true
          - value: false

      # Target temperature (return water setpoint for HVAC)
      - id: 101
        type: integer
        name: temperature
        unit: C
        range:
          min: 0
          max: 80

      # Current temperature (return water as proxy)
      - id: 111
        type: integer
        name: current_temperature
        mapping:
          - scale: 10

  # DHW WATER HEATER
  - entity: water_heater
    name: DHW
    dps:
      # Power & operation mode combined
      - id: 126
        type: boolean
        name: operation_mode
        mapping:
          - dps_val: false
            value: "off"
            available: air_off
          - dps_val: true
            constraint: mode
            conditions:
              - dps_val: "dhw"
                value: heat_pump
                available: air_off
              - dps_val: "cool"
                value: "off"
                available: air_cool
              - dps_val: "cool_dhw"
                value: heat_pump
                available: air_cool
              - dps_val: "heat"
                value: "off"
                available: air_heat
              - dps_val: "heat_dhw"
                value: heat_pump
                available: air_heat

      # Mode enum (hidden)
      - id: 130
        type: string
        name: mode
        hidden: true

      # Helper: air off (dhw only)
      - id: 130
        type: string
        name: air_off
        hidden: true
        mapping:
          - dps_val: "dhw"
            value: true
          - value: false

      # Helper: air cooling active
      - id: 130
        type: string
        name: air_cool
        hidden: true
        mapping:
          - dps_val: "cool"
            value: true
          - dps_val: "cool_dhw"
            value: true
          - value: false

      # Helper: air heating active
      - id: 130
        type: string
        name: air_heat
        hidden: true
        mapping:
          - dps_val: "heat"
            value: true
          - dps_val: "heat_dhw"
            value: true
          - value: false

      # DHW setpoint
      - id: 102
        type: integer
        name: temperature
        unit: C
        range:
          min: 10
          max: 70

      # Current DHW temperature
      - id: 113
        type: integer
        name: current_temperature

  # EXTRA CONFIG NUMBERS
  - entity: number
    name: Minimum water flow
    category: config
    class: volume_flow_rate
    dps:
      - id: 103
        type: integer
        name: value
        unit: L/min
        range:
          min: 0
          max: 60

  # TEMPERATURE & FLOW SENSORS
  - entity: sensor
    name: Output temperature
    class: temperature
    category: diagnostic
    icon: "mdi:thermometer-chevron-down"
    dps:
      - id: 112
        type: integer
        name: sensor
        unit: °C
        class: measurement
        mapping:
          - scale: 10

  - entity: sensor
    name: Air conditioning water flow
    category: diagnostic
    class: volume_flow_rate
    dps:
      - id: 114
        type: integer
        name: sensor
        unit: L/min
        class: measurement

  - entity: sensor
    name: Compressor temperature
    class: temperature
    category: diagnostic
    icon: "mdi:fire"
    dps:
      - id: 115
        type: integer
        name: sensor
        unit: °C
        class: measurement

  - entity: sensor
    name: Coil temperature
    class: temperature
    category: diagnostic
    icon: "mdi:pipe"
    dps:
      - id: 116
        type: integer
        name: sensor
        unit: °C
        class: measurement

  - entity: sensor
    translation_key: ambient_temperature
    class: temperature
    dps:
      - id: 117
        type: integer
        name: sensor
        unit: °C
        class: measurement

  - entity: sensor
    name: Compressor return temperature
    class: temperature
    category: diagnostic
    icon: "mdi:fan"
    dps:
      - id: 118
        type: integer
        name: sensor
        unit: °C
        class: measurement

  - entity: sensor
    name: Exchange plate temperature
    class: temperature
    category: diagnostic
    icon: "mdi:pipe-wrench"
    dps:
      - id: 119
        type: integer
        name: sensor
        unit: °C
        class: measurement

  # ELECTRICAL / SPEED
  - entity: sensor
    name: Compressor frequency
    class: frequency
    category: diagnostic
    icon: "mdi:engine"
    dps:
      - id: 106
        type: integer
        name: sensor
        unit: Hz
        class: measurement

  - entity: sensor
    name: Fan speed
    category: diagnostic
    icon: "mdi:fan-auto"
    dps:
      - id: 107
        type: integer
        name: sensor
        unit: rpm
        class: measurement

  - entity: sensor
    class: current
    category: diagnostic
    dps:
      - id: 108
        type: integer
        name: sensor
        unit: A
        class: measurement
        mapping:
          - scale: 10

  # RAW STATUS WORD
  - entity: sensor
    name: Status bits
    category: diagnostic
    icon: "mdi:information-outline"
    hidden: true
    dps:
      - id: 120
        type: integer
        name: sensor

  # FAULT STATUS (BINARY_SENSOR)
  - entity: binary_sensor
    class: problem
    category: diagnostic
    dps:
      # Main fault detection from group 1
      - id: 104
        type: string
        name: sensor
        mapping:
          - dps_val: "eorr0"
            value_redirect: fault_group_2
          - value: true

      # Fault code 1 as attribute
      - id: 104
        type: string
        name: fault_code

      # Fallback to group 2
      - id: 105
        type: string
        name: fault_group_2
        hidden: true
        mapping:
          - dps_val: "eorr0"
            value: false
          - value: true

      # Fault code 2 as attribute
      - id: 105
        type: string
        name: fault_code_2
