import type { ISimpleLocalConfig, ISimpleLocalIntegrationProfile, ISimpleLocalSnapshot, TSimpleLocalRawData } from '../../core/index.js';

export const hrEnergyQubeDomain = 'hr_energy_qube';
export const hrEnergyQubeDefaultName = 'Qube heat pump';
export const hrEnergyQubeDefaultPort = 502;

export type THrEnergyQubeRawData = TSimpleLocalRawData;
export interface IHrEnergyQubeSnapshot extends ISimpleLocalSnapshot {}
export interface IHrEnergyQubeConfig extends ISimpleLocalConfig {
  softwareVersion?: string;
}
export interface IHomeAssistantHrEnergyQubeConfig extends IHrEnergyQubeConfig {}

export const hrEnergyQubeProfile: ISimpleLocalIntegrationProfile = {
  domain: 'hr_energy_qube',
  displayName: 'Qube heat pump',
  manufacturer: 'Qube',
  model: 'Heat Pump',
  defaultName: hrEnergyQubeDefaultName,
  defaultPort: hrEnergyQubeDefaultPort,
  defaultProtocol: 'tcp',
  status: 'read-only-runtime',
  platforms: [
    'binary_sensor',
    'sensor',
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'qube',
    'qube heat pump',
    'heat pump',
    'modbus tcp',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/hr_energy_qube',
    upstreamDomain: 'hr_energy_qube',
    integrationType: 'hub',
    iotClass: 'local_polling',
    qualityScale: 'bronze',
    requirements: [
      'python-qube-heatpump==1.8.0',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@MattieGit',
    ],
    configFlow: true,
    documentation: 'https://www.home-assistant.io/integrations/hr_energy_qube',
    loggers: [
      'python_qube_heatpump',
    ],
    defaults: {
      port: hrEnergyQubeDefaultPort,
      scanIntervalSeconds: 15,
      statusMap: {
        1: 'standby',
        2: 'alarm',
        6: 'keyboard_off',
        8: 'compressor_startup',
        9: 'compressor_shutdown',
        14: 'standby',
        15: 'cooling',
        16: 'heating',
        17: 'start_fail',
        18: 'standby',
        22: 'heating_dhw',
      },
    },
    platforms: [
      'binary_sensor',
      'sensor',
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
      ],
      platforms: [
        'binary_sensor',
        'sensor',
      ],
      controls: false,
    },
    localApi: {
      implemented: [
        'manual local setup for Qube host/port metadata, snapshots, raw data, snapshotProvider, and injected native clients',
        'runtime mapping of Qube heat pump sensor and binary sensor snapshots',
      ],
      explicitUnsupported: [
        'native Modbus TCP register reads in this TypeScript package without an injected client or snapshotProvider',
        'claiming live command success without injected client.execute or commandExecutor',
        'Home Assistant device registry and DataUpdateCoordinator side effects',
      ],
    },
  },
};
