Class Recorder

The recorder is the counter-part to the startVantageAPI() function. It repeatedly sends weather data to a running vant-api instance via HTTP requests.

To get the weather data is utilizes a VantPro2Interface or a VantVueInterface. Only works on Vantage Pro 2 and Vue (having firmware dated after April 24, 2002 / v1.90 or above).

The recorder is structured in multiple tasks which are responsibly for different kinds of weather data. Currently there are following tasks:

  • Current Conditions: Uploads rich realtime data very often (configurable, default: every 1s) [route: api/v1/current]

To create a recorder write:

const recorder = await Recorder.create(...);

To configure the current conditions task write:

recorder.configureCurrentConditionsTask(...);

To start the recorder write:

recorder.start();

Hierarchy

  • Recorder

Constructors

Properties

currentConditionsTaskSettings?: CurrentConditionsTaskSettings
interface: default | default
realtimeRecorderTimeout?: Timeout
running: boolean
settings: {
    api: string;
    baudRate: BaudRate;
    consoleLog: boolean;
    fileLog: boolean;
    key: string;
    logErrorInformation: boolean;
    logLevel: LogLevel;
    model: AdvancedModel;
    path: string;
    preferEnvironmentVariables: boolean;
    rainCollectorSize?: RainCollectorSize;
    units: { readonly rain: RainUnit; readonly wind: WindUnit; readonly temperature: TemperatureUnit; readonly solarRadiation: "W/m²"; readonly pressure: PressureUnit; };
}

Type declaration

  • Readonly api: string

    The URL to the api. E.g. http://localhost:8000/api. Corresponding environment variable: API

  • Readonly baudRate: BaudRate

    The baud rate to use. Default is 19200. This has to match your weather station's settings! Corresponding environment variable: BAUD_RATE

  • Readonly consoleLog: boolean

    Whether the console log is enabled. Default is true. Corresponding environment variable: CONSOLE_LOG

  • Readonly fileLog: boolean

    Whether file logging is enabled. Default is true. Corresponding environment variable: FILE_LOG

  • Readonly key: string

    The api key used to communicate with the api. Corresponding environment variable: API_KEY

  • Readonly logErrorInformation: boolean

    Whether to log detailed error information. Default is true. Corresponding environment variable: `LOG_ERROR_INFORMATION´

  • Readonly logLevel: LogLevel

    The minimimum log level that will be output. Default is "info". Corresponding environment variable: LOG_LEVEL

  • Readonly model: AdvancedModel

    The weather station model. Default is PRO2. Corresponding environment variable: MODEL

  • Readonly path: string

    The serial path to the weather station. E.g. COM3. Corresponding environment variable: SERIAL_PATH

  • Readonly preferEnvironmentVariables: boolean

    Whether to prefer environment variables configured in the .env file. Default is false.

  • Optional Readonly rainCollectorSize?: RainCollectorSize

    The weather station's rain collector size.

  • Readonly units: { readonly rain: RainUnit; readonly wind: WindUnit; readonly temperature: TemperatureUnit; readonly solarRadiation: "W/m²"; readonly pressure: PressureUnit; }

    The default units. Important: Has to match the configured vant-api units! Corresponding environment variables: RAIN_UNIT, TEMPERATURE_UNIT, ...

Methods

  • Configures the current conditions task. This is related to the /api/v1/current route. Pass your desired settings to configure and enable the task, pass false to disable it.

    It is also possible to configure your recorder using a .env file. To enable this feature pass useEnvironmentVariables: true.

    To start all your configured tasks run start().

    Parameters

    Returns void

    Throws

    InvalidRecorderConfigurationError if the settings are invalid

  • Return whether the current conditions task is configured.

    Returns boolean

    whether the current conditions task is configured

  • Return the set up current conditions task's interval.

    Returns undefined | number

    the set up current conditions task's interval

  • Restarts the recorder. Useful if you changed the recorder's settings while it was already running.

    Returns void

  • Starts the recorder. Tasks that have been configured using configure*Task(...) will be started.

    Does nothing if the recorder already has been started.

    Returns void

  • Stops the recorder. Clears all currently running recording tasks.

    Does nothing if the recorder already has been stopped.

    Returns void

  • Creates a new recorder with the passed settings. Throws an InvalidRecorderConfigurationError if the settings are invalid.

    It is also possible to configure your recorder using a .env file. To enable this feature pass useEnvironmentVariables: true.

    Example:

    // create recorder
    const recorder = await Recorder.create({
    path: "COM5",
    api: "http://localhost:8000/api",
    rainCollectorSize: "0.2mm",
    model: "Pro2",
    ....
    });

    // configure realtime recordings
    recorder.configureRealtimeRecording({ interval: 10 });

    // start recorder
    recorder.start();

    Parameters

    Returns Promise<Recorder>

    a recorder instance

    Throws

    InvalidRecorderConfigurationError if the settings are invalid

Generated using TypeDoc