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

export const fluxLedDomain = 'flux_led';
export const fluxLedDefaultName = 'Magic Home';
export const fluxLedDefaultPort = 5577;

export type TFluxLedRawData = TSimpleLocalRawData;
export interface IFluxLedSnapshot extends ISimpleLocalSnapshot {}
export interface IFluxLedConfig extends ISimpleLocalConfig {
  model?: string;
  modelNum?: number;
  model_num?: number;
  modelInfo?: string;
  model_info?: string;
  modelDescription?: string;
  model_description?: string;
  minorVersion?: number;
  minor_version?: number;
  remoteAccessEnabled?: boolean;
  remote_access_enabled?: boolean;
  remoteAccessHost?: string;
  remote_access_host?: string;
  remoteAccessPort?: number;
  remote_access_port?: number;
  whiteChannelType?: string;
  white_channel_type?: string;
}
export interface IHomeAssistantFluxLedConfig extends IFluxLedConfig {}

export const fluxLedProfile: ISimpleLocalIntegrationProfile = {
  domain: 'flux_led',
  displayName: 'Magic Home',
  manufacturer: 'Zengge',
  model: 'Magic Home LED controller',
  defaultName: fluxLedDefaultName,
  defaultPort: fluxLedDefaultPort,
  defaultProtocol: 'local',
  status: 'read-only-runtime',
  platforms: [
    'button',
    'light',
    'number',
    'select',
    'sensor',
    'switch',
  ],
  serviceDomains: [
    'button',
    'light',
    'number',
    'select',
    'switch',
  ],
  controlServices: [
    'press',
    'select_option',
    'set_custom_effect',
    'set_music_mode',
    'set_value',
    'set_zones',
    'turn_off',
    'turn_on',
  ],
  discoverySources: [
    'manual',
    'dhcp',
    'custom',
  ],
  discoveryKeywords: [
    'flux_led',
    'magic home',
    'zengge',
    'flux led',
    'led controller',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/flux_led',
    upstreamDomain: 'flux_led',
    iotClass: 'local_push',
    qualityScale: undefined,
    requirements: [
      'flux-led==1.2.0',
    ],
    dependencies: [
      'network',
    ],
    afterDependencies: [],
    codeowners: [
      '@icemanch',
    ],
    configFlow: true,
    documentation: 'https://www.home-assistant.io/integrations/flux_led',
    loggers: [
      'flux_led',
    ],
    dhcp: [
      { registered_devices: true },
      { hostname: '[ba][lk]*', macaddress: '18B905*' },
      { hostname: '[ba][lk]*', macaddress: '249494*' },
      { hostname: '[ba][lk]*', macaddress: '7CB94C*' },
      { hostname: '[hba][flk]*', macaddress: 'ACCF23*' },
      { hostname: '[ba][lk]*', macaddress: 'B4E842*' },
      { hostname: '[hba][flk]*', macaddress: 'F0FE6B*' },
      { hostname: 'lwip*', macaddress: '8CCE4E*' },
      { hostname: 'hf-lpb100-zj*' },
      { hostname: 'zengge_[0-9a-f][0-9a-f]_*' },
      { hostname: 'zengge' },
      { hostname: 'sta*', macaddress: 'C82E47*' },
    ],
    defaults: {
      port: fluxLedDefaultPort,
      scanIntervalSeconds: 5,
      networkScanIntervalSeconds: 120,
      effectSpeed: 50,
      transitions: ['gradual', 'jump', 'strobe'],
    },
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'press',
        'select_option',
        'set_custom_effect',
        'set_music_mode',
        'set_value',
        'set_zones',
        'turn_off',
        'turn_on',
      ],
      platforms: [
        'button',
        'light',
        'number',
        'select',
        'sensor',
        'switch',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual local endpoint metadata, snapshots, raw data, snapshotProvider, and injected native clients',
        'read-only Magic Home light, switch, sensor, number, select, and button entity mapping',
        'safe control delegation to injected client.execute or commandExecutor only',
      ],
      explicitUnsupported: [
        'native flux-led TCP/UDP discovery and control protocol in this TypeScript package',
        'claiming light, switch, effect, music mode, select, number, or button command success without an injected executor',
        'Home Assistant device registry MAC migration and background discovery scheduling',
      ],
    },
  },
};
