import { SimpleLocalClient, type IServiceCallRequest, type IServiceCallResult } from '../../core/index.js';
import type { IMonopriceConfig } from './monoprice.types.js';
import { monopriceProfile } from './monoprice.types.js';

export class MonopriceClient extends SimpleLocalClient<IMonopriceConfig> {
  constructor(private readonly configArg: IMonopriceConfig) {
    super(monopriceProfile, configArg);
  }

  public async execute(requestArg: IServiceCallRequest): Promise<IServiceCallResult> {
    if (this.configArg.client?.execute || this.configArg.commandExecutor) {
      return super.execute(requestArg);
    }
    return {
      success: false,
      error: `Monoprice ${requestArg.service} is not implemented natively: Home Assistant uses pymonoprice over pyserial/serial_asyncio for an RS-232 serial port, and this package has no serial transport dependency. Provide an injected client.execute() or commandExecutor for live polling/control.`,
    };
  }
}
