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

export const ialarmDomain = 'ialarm';
export const ialarmDefaultName = 'iAlarm';
export const ialarmDefaultPort = 18034;

export type TIalarmRawData = TSimpleLocalRawData;
export interface IIalarmSnapshot extends ISimpleLocalSnapshot {}
export interface IIalarmConfig extends ISimpleLocalConfig {
  mac?: string;
}
export interface IHomeAssistantIalarmConfig extends IIalarmConfig {}

export const ialarmProfile: ISimpleLocalIntegrationProfile = {
  domain: 'ialarm',
  displayName: 'Antifurto365 iAlarm',
  manufacturer: 'Antifurto365 - Meian',
  model: 'iAlarm',
  defaultName: ialarmDefaultName,
  defaultPort: ialarmDefaultPort,
  defaultProtocol: 'tcp',
  status: 'read-only-runtime',
  platforms: [
    'sensor',
  ],
  serviceDomains: [
    'alarm_control_panel',
  ],
  controlServices: [
    'alarm_disarm',
    'alarm_arm_home',
    'alarm_arm_away',
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'ialarm',
    'antifurto365',
    'meian',
    'alarm panel',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/ialarm',
    upstreamDomain: 'ialarm',
    integrationType: 'device',
    iotClass: 'local_polling',
    qualityScale: undefined,
    requirements: [
      'pyialarm==2.2.0',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@RyuzakiKK',
    ],
    configFlow: true,
    documentation: 'https://www.home-assistant.io/integrations/ialarm',
    loggers: [
      'pyialarm',
    ],
    defaults: {
      port: ialarmDefaultPort,
      stateMap: {
        ARMED_AWAY: 'armed_away',
        ARMED_STAY: 'armed_home',
        DISARMED: 'disarmed',
        TRIGGERED: 'triggered',
      },
    },
    platforms: [
      'alarm_control_panel',
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'alarm_disarm',
        'alarm_arm_home',
        'alarm_arm_away',
      ],
      platforms: [
        'alarm_control_panel',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual local setup for iAlarm host/port/MAC metadata, snapshots, raw data, snapshotProvider, and injected native clients',
        'runtime alarm state snapshot mapping into supported local entities',
        'safe alarm command delegation to injected client.execute or commandExecutor only',
      ],
      explicitUnsupported: [
        'native pyialarm TCP status polling in this TypeScript package without an injected client or snapshotProvider',
        'claiming alarm_arm_away, alarm_arm_home, or alarm_disarm success without injected client.execute or commandExecutor',
        'Home Assistant ConfigEntryNotReady and DataUpdateCoordinator side effects',
      ],
    },
  },
};
