Documentation
    Preparing search index...

    Represents a RestClient object.

    The options for the RestClient.

    Index

    Constructors

    Properties

    certificationUrl: string

    The URL for the certification endpoint. It is used for signing and acquiring certification for IoT devices. The URL is constructed by appending the '/iot-open/sign/certification' path to the restApiHost.

    deviceListUrl: string

    The URL for fetching the list of devices.

    deviceQuotaUrl: string

    The URL for querying device quota information.

    requestHandler: RequestHandler

    Represents a utility class that is used to handle requests.

    restApiHost: string

    Represents the host URL of the REST API. Use https://api-e.ecoflow.com for european accounts or https://api-a.ecoflow.com in the US.

    setCmdUrl: string

    Sets the command URL for the REST API host and device quota.

    The base URL of the REST API host.

    Methods

    • Requests all device properties.

      Parameters

      • sn: string

        Device serial number

      Returns Promise<{ code: "0"; data?: Record<string, any>; message: "Success" }>

      • Promise that resolves to the device properties response
    • Retrieves a list of device class instances. To narrow down a device-type you may use the instanceOf operator.

      const devices = await restClient.getDevices();

      for (const device of devices) {
      if (device instanceof SmartPlug) {
      await device.switchOn();
      }
      }

      Returns Promise<UnknownDevice[]>

      A promise that resolves to an array of devices.

    • Receive a list of all devices connected to the account.

      Returns Promise<
          {
              code: "0";
              data: objectOutputType<
                  {
                      deviceName: ZodOptional<ZodString>;
                      online: ZodUnion<[ZodLiteral<0>, ZodLiteral<1>]>;
                      productName: ZodString;
                      sn: ZodString;
                  },
                  ZodTypeAny,
                  "passthrough",
              >[];
              message: "Success";
          },
      >

      A promise that resolves to the device list response.

    • Requests credentials required to establish an MQTT connection.

      Returns Promise<
          {
              certificateAccount: string;
              certificatePassword: string;
              port: number;
              protocol: "mqtts";
              url: string;
          },
      >

      An object containing the MQTT credentials. - certificateAccount: The certificate account. - certificatePassword: The certificate password. - url: The MQTT broker URL. - protocol: The MQTT protocol (e.g., MQTT or MQTT over WebSocket). - port: The MQTT broker port.

      If there is an error retrieving the credentials or if the response contains an error message.

    • Returns an array of all serial numbers bound to the connected account.

      Returns Promise<string[]>

      An array of serial numbers.

    • Parses the given response data using the provided schema.

      Type Parameters

      • T extends ZodTypeAny

      Parameters

      • data: unknown

        The response data to be parsed.

      • schema: T

        The schema to be used for parsing.

      Returns inferSchema<T>

      • The parsed response data.
      • If an error is detected in the response data.
    • Update device settings. Depending on the device type different settings can be updated.

      Parameters

      • payload: Record<string, any>

      Returns Promise<
          | {
              code: "0";
              eagleEyeTraceId: string;
              message: "Success";
              tid: string;
          }
          | { code: string; eagleEyeTraceId: string; message: string; tid: string },
      >