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

export const emonitorDomain = 'emonitor';
export const emonitorDefaultName = 'SiteSage Emonitor';

export type TEmonitorRawData = TSimpleLocalRawData;
export interface IEmonitorSnapshot extends ISimpleLocalSnapshot {}
export interface IEmonitorConfig extends ISimpleLocalConfig {
  macAddress?: string;
  mac_address?: string;
}
export interface IHomeAssistantEmonitorConfig extends IEmonitorConfig {}

export const emonitorProfile: ISimpleLocalIntegrationProfile = {
  domain: 'emonitor',
  displayName: 'SiteSage Emonitor',
  manufacturer: 'Powerhouse Dynamics, Inc.',
  model: 'SiteSage Emonitor',
  defaultName: emonitorDefaultName,
  defaultProtocol: 'http',
  status: 'read-only-runtime',
  platforms: [
    'sensor',
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'dhcp',
    'http',
    'custom',
  ],
  discoveryKeywords: [
    'emonitor',
    'sitesage',
    'powerhouse dynamics',
    '0090c2',
    'power monitor',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/emonitor',
    upstreamDomain: 'emonitor',
    integrationType: 'device',
    iotClass: 'local_polling',
    qualityScale: undefined,
    requirements: [
      'aioemonitor==1.0.5',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@bdraco',
    ],
    configFlow: true,
    dhcp: [
      {
        hostname: 'emonitor*',
        macaddress: '0090C2*',
      },
      {
        registered_devices: true,
      },
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
      ],
      platforms: [
        'sensor',
      ],
      controls: false,
    },
    localApi: {
      implemented: [
        'manual local host setup, snapshots, raw data, snapshotProvider, and injected native clients',
        'SiteSage Emonitor status/channel snapshot mapping compatible with aioemonitor status data',
      ],
      explicitUnsupported: [
        'claiming live control success without injected client.execute or commandExecutor',
        'guessing undocumented aioemonitor HTTP endpoints for direct polling',
        'cloud account flows and remote API polling',
      ],
    },
  },
};
