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

export const emoncmsDomain = 'emoncms';
export const emoncmsDefaultName = 'Emoncms';

export type TEmoncmsRawData = TSimpleLocalRawData;
export interface IEmoncmsSnapshot extends ISimpleLocalSnapshot {}
export interface IEmoncmsConfig extends ISimpleLocalConfig {
  url?: string;
  includeOnlyFeedIds?: Array<string | number>;
}
export interface IHomeAssistantEmoncmsConfig extends IEmoncmsConfig {}

export const emoncmsProfile: ISimpleLocalIntegrationProfile = {
  domain: 'emoncms',
  displayName: 'Emoncms',
  manufacturer: 'OpenEnergyMonitor',
  model: 'Emoncms',
  defaultName: emoncmsDefaultName,
  defaultHttpPath: '/feed/list.json',
  defaultProtocol: 'http',
  status: 'read-only-runtime',
  platforms: [
    'sensor',
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'http',
    'custom',
  ],
  discoveryKeywords: [
    'emoncms',
    'openenergymonitor',
    'feed',
    'energy',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/emoncms',
    upstreamDomain: 'emoncms',
    integrationType: 'service',
    iotClass: 'local_polling',
    qualityScale: undefined,
    qualityScaleRulesPath: 'homeassistant/components/emoncms/quality_scale.yaml',
    requirements: [
      'pyemoncms==0.1.3',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@borpin',
      '@alexandrecuer',
    ],
    configFlow: true,
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
      ],
      platforms: [
        'sensor',
      ],
      controls: false,
    },
    localApi: {
      implemented: [
        'manual local endpoint setup for Emoncms URL or host, snapshots, raw data, snapshotProvider, and injected native clients',
        'generic HTTP local feed-list transport when config.path includes required local API parameters',
      ],
      explicitUnsupported: [
        'claiming live command success without injected client.execute or commandExecutor',
        'feed writes, account administration, and cloud-only Emoncms API operations',
        'remote API polling that cannot be reached as a local endpoint',
      ],
    },
  },
};
