import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { PlugwiseClient } from './plugwise.classes.client.js';
import { PlugwiseConfigFlow } from './plugwise.classes.configflow.js';
import { createPlugwiseDiscoveryDescriptor } from './plugwise.discovery.js';
import type { IPlugwiseConfig } from './plugwise.types.js';
import { plugwiseDomain, plugwiseProfile } from './plugwise.types.js';

export class PlugwiseIntegration extends SimpleLocalIntegration<IPlugwiseConfig> {
  public readonly domain = plugwiseDomain;
  public readonly discoveryDescriptor = createPlugwiseDiscoveryDescriptor();
  public readonly configFlow = new PlugwiseConfigFlow();

  constructor() {
    super(plugwiseProfile);
  }

  public override async setup(configArg: IPlugwiseConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(plugwiseProfile, new PlugwiseClient(configArg));
  }
}

export class HomeAssistantPlugwiseIntegration extends PlugwiseIntegration {}
