import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { OpenhomeClient } from './openhome.classes.client.js';
import { OpenhomeConfigFlow } from './openhome.classes.configflow.js';
import { createOpenhomeDiscoveryDescriptor } from './openhome.discovery.js';
import type { IOpenhomeConfig } from './openhome.types.js';
import { openhomeDomain, openhomeProfile } from './openhome.types.js';

export class OpenhomeIntegration extends SimpleLocalIntegration<IOpenhomeConfig> {
  public readonly domain = openhomeDomain;
  public readonly discoveryDescriptor = createOpenhomeDiscoveryDescriptor();
  public readonly configFlow = new OpenhomeConfigFlow();

  constructor() {
    super(openhomeProfile);
  }

  public override async setup(configArg: IOpenhomeConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(openhomeProfile, new OpenhomeClient(configArg));
  }
}

export class HomeAssistantOpenhomeIntegration extends OpenhomeIntegration {}
