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

export const greeneyeMonitorDomain = 'greeneye_monitor';
export const greeneyeMonitorDefaultName = 'GreenEye Monitor';

export type TGreeneyeMonitorRawData = TSimpleLocalRawData;
export interface IGreeneyeMonitorSnapshot extends ISimpleLocalSnapshot {}
export interface IGreeneyeMonitorConfig extends ISimpleLocalConfig {
  monitors?: Array<Record<string, unknown>>;
  port?: number;
}
export interface IHomeAssistantGreeneyeMonitorConfig extends IGreeneyeMonitorConfig {}

export const greeneyeMonitorProfile: ISimpleLocalIntegrationProfile = {
  domain: 'greeneye_monitor',
  displayName: 'GreenEye Monitor (GEM)',
  manufacturer: 'Brultech',
  model: 'GreenEye Monitor',
  defaultName: greeneyeMonitorDefaultName,
  defaultProtocol: 'local',
  status: 'read-only-runtime',
  platforms: [
    'sensor',
  ],
  serviceDomains: [
    'sensor',
  ],
  controlServices: [],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'greeneye',
    'greeneye monitor',
    'greeneye_monitor',
    'gem',
    'brultech',
    'energy monitor',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/greeneye_monitor',
    upstreamDomain: 'greeneye_monitor',
    iotClass: 'local_push',
    qualityScale: 'legacy',
    requirements: [
      'greeneye_monitor==3.0.3',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@jkeljo',
    ],
    configFlow: false,
    documentation: 'https://www.home-assistant.io/integrations/greeneye_monitor',
    loggers: [
      'greeneye',
    ],
    homeAssistantPlatforms: [
      'sensor',
    ],
    defaults: {
      temperatureUnit: 'C',
      channelRange: [1, 48],
      pulseCounterRange: [1, 4],
      temperatureSensorRange: [1, 8],
      voltageSensorRange: [1, 48],
    },
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
      ],
      platforms: [
        'sensor',
      ],
      controls: false,
    },
    localApi: {
      implemented: [
        'manual local setup for configured GEM monitor/channel metadata, snapshots, raw data, snapshotProvider, and injected native clients',
        'runtime device and sensor entity mapping for current, pulse counter, temperature, and voltage snapshots',
      ],
      explicitUnsupported: [
        'opening a native GreenEye push server inside this TypeScript package',
        'claiming live command success without injected client.execute or commandExecutor',
        'Home Assistant YAML monitor schema validation and listener lifecycle management',
      ],
    },
  },
};
