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

export const motionmountDomain = "motionmount";
export const motionmountDefaultName = "Vogel's MotionMount";
export const motionmountDefaultPort = 23;
export const motionmountDefaultTimeoutMs = 5000;

export type TMotionmountRawData = TSimpleLocalRawData;
export interface IMotionmountSnapshot extends ISimpleLocalSnapshot {}
export interface IMotionmountConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
  pin?: number | string;
}
export interface IHomeAssistantMotionmountConfig extends IMotionmountConfig {}

export const motionmountProfile: ISimpleLocalIntegrationProfile = {
  domain: motionmountDomain,
  displayName: "Vogel's MotionMount",
  manufacturer: "Vogel's MotionMount",
  model: "Vogel's MotionMount local integration",
  defaultName: motionmountDefaultName,
  defaultPort: motionmountDefaultPort,
  defaultProtocol: 'tcp',
  status: "control-runtime",
  platforms: [
    "binary_sensor",
    "number",
    "select",
    "sensor",
  ],
  serviceDomains: [
    "number",
    "select",
  ],
  controlServices: [
    "select_option",
    "set_value",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "motionmount",
    "Vogel's MotionMount",
    "Motionmount",
    "Vogel's",
    "MotionMount",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/motionmount",
    "upstreamDomain": "motionmount",
    "integrationType": "device",
    "iotClass": "local_push",
    "qualityScale": "bronze",
    "requirements": [
      "python-MotionMount==2.3.0",
    ],
    "codeowners": [
      "@laiho-vogels",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/motionmount",
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "select_option",
        "set_value",
      ],
      "platforms": [
        "binary_sensor",
        "number",
        "select",
        "sensor",
      ],
      "controls": "native TCP line-protocol controls when host/port is configured; delegated to injected client.execute or commandExecutor otherwise",
    },
    "localApi": {
      "implemented": [
        "native TCP line-protocol snapshots for host/port MotionMount devices, including position, motion, error status, authentication status, and presets",
        "native TCP line-protocol controls for set_value extension/turn and select_option preset commands when a reachable device endpoint is configured",
        "manual local setup for Vogel's MotionMount endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Vogel's MotionMount device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "claiming MotionMount pairing, PIN recovery, or authenticated write success when the device rejects the configured PIN",
        "MotionMount push notification subscription fan-out beyond per-request TCP polling",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without a reachable TCP endpoint, injected client.execute, or commandExecutor",
      ],
    },
  },
};
