import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { P1MonitorClient } from './p1_monitor.classes.client.js';
import { P1MonitorConfigFlow } from './p1_monitor.classes.configflow.js';
import { createP1MonitorDiscoveryDescriptor } from './p1_monitor.discovery.js';
import type { IP1MonitorConfig } from './p1_monitor.types.js';
import { p1MonitorDomain, p1MonitorProfile } from './p1_monitor.types.js';

export class P1MonitorIntegration extends SimpleLocalIntegration<IP1MonitorConfig> {
  public readonly domain = p1MonitorDomain;
  public readonly discoveryDescriptor = createP1MonitorDiscoveryDescriptor();
  public readonly configFlow = new P1MonitorConfigFlow();

  constructor() {
    super(p1MonitorProfile);
  }

  public override async setup(configArg: IP1MonitorConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(p1MonitorProfile, new P1MonitorClient(configArg));
  }
}

export class HomeAssistantP1MonitorIntegration extends P1MonitorIntegration {}
