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

export const iammeterDomain = 'iammeter';
export const iammeterDefaultName = 'IamMeter';
export const iammeterDefaultPort = 80;
export const iammeterDefaultHttpPath = '/monitorjson';

export type TIammeterRawData = TSimpleLocalRawData;
export interface IIammeterSnapshot extends ISimpleLocalSnapshot {}
export interface IIammeterConfig extends ISimpleLocalConfig {
  model?: 'WEM3080' | 'WEM3080T' | 'WEM3162' | string;
  serialNumber?: string;
}
export interface IHomeAssistantIammeterConfig extends IIammeterConfig {}

export const iammeterProfile: ISimpleLocalIntegrationProfile = {
  domain: 'iammeter',
  displayName: 'IamMeter',
  manufacturer: 'IamMeter',
  model: 'WEM3080/WEM3080T',
  defaultName: iammeterDefaultName,
  defaultPort: iammeterDefaultPort,
  defaultHttpPath: iammeterDefaultHttpPath,
  defaultProtocol: 'http',
  status: 'read-only-runtime',
  platforms: [
    'sensor',
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'http',
    'custom',
  ],
  discoveryKeywords: [
    'iammeter',
    'iam meter',
    'wem3080',
    'wem3080t',
    'wem3162',
    'monitorjson',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/iammeter',
    upstreamDomain: 'iammeter',
    iotClass: 'local_polling',
    qualityScale: 'legacy',
    requirements: [
      'iammeter==0.2.1',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@lewei50',
    ],
    configFlow: false,
    documentation: 'https://www.home-assistant.io/integrations/iammeter',
    loggers: [
      'iammeter',
    ],
    defaults: {
      host: '192.168.2.15',
      port: iammeterDefaultPort,
      name: iammeterDefaultName,
      path: iammeterDefaultHttpPath,
      scanIntervalSeconds: 30,
      platformTimeoutSeconds: 8,
      deviceTypes: [
        'WEM3080',
        'WEM3080T',
      ],
    },
    platforms: [
      'sensor',
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
      ],
      platforms: [
        'sensor',
      ],
      controls: false,
    },
    localApi: {
      implemented: [
        'manual local HTTP setup for host/port/path metadata, snapshots, raw data, snapshotProvider, and injected native clients',
        'read-only /monitorjson HTTP snapshot requests when host/path and any required credentials are supplied',
        'runtime mapping of IamMeter sensor snapshots for WEM3080, WEM3080T, and WEM3162 data',
      ],
      explicitUnsupported: [
        'Home Assistant YAML platform migration and entity registry unique-id migration side effects',
        'claiming live command success without injected client.execute or commandExecutor',
        'writing meter configuration or cloud upload settings',
      ],
    },
  },
};
