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

export const heatmiserDomain = 'heatmiser';
export const heatmiserDefaultName = 'Heatmiser';

export interface IHeatmiserThermostatConfig {
  id: number;
  name: string;
}

export type THeatmiserRawData = TSimpleLocalRawData;
export interface IHeatmiserSnapshot extends ISimpleLocalSnapshot {}
export interface IHeatmiserConfig extends ISimpleLocalConfig {
  tstats?: IHeatmiserThermostatConfig[];
  thermostats?: IHeatmiserThermostatConfig[];
}
export interface IHomeAssistantHeatmiserConfig extends IHeatmiserConfig {}

const heatmiserControlServices = [
  'set_temperature',
  'set_hvac_mode',
  'turn_on',
  'turn_off',
];

export const heatmiserProfile: ISimpleLocalIntegrationProfile = {
  domain: heatmiserDomain,
  displayName: 'Heatmiser',
  manufacturer: 'Heatmiser',
  model: 'PRT thermostat via UH1',
  defaultName: heatmiserDefaultName,
  defaultProtocol: 'tcp',
  status: 'read-only-runtime',
  platforms: [
    'climate',
  ],
  serviceDomains: [
    'climate',
  ],
  controlServices: heatmiserControlServices,
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'heatmiser',
    'uh1',
    'prt',
    'thermostat',
    'heatmiserv3',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/heatmiser',
    upstreamDomain: 'heatmiser',
    iotClass: 'local_polling',
    qualityScale: 'legacy',
    requirements: [
      'heatmiserV3==2.0.4',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@andylockran',
    ],
    configFlow: false,
    documentation: 'https://www.home-assistant.io/integrations/heatmiser',
    loggers: [
      'heatmiserV3',
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        ...heatmiserControlServices,
      ],
      platforms: [
        'climate',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual local UH1 host/port and thermostat list setup',
        'snapshot, raw thermostat data, snapshotProvider, and injected native client operation',
        'climate entity mapping from Heatmiser V3 thermostat snapshots',
      ],
      explicitUnsupported: [
        'opening a Heatmiser V3 socket and reading DCB records directly from this TypeScript package',
        'claiming live temperature or HVAC command success without injected client.execute or commandExecutor',
      ],
    },
  },
};
