Class WeatherStation

Interface to any vantage weather station (Vue, Pro, Pro 2). Provides useful methods to access realtime weather data from your weather station's console. The device must be connected serially. To interact with your weather station create an instance of this class using WeatherStation.connect.

The WeatherStation is an EventEmitter. The events fired by the interface are described WeatherStationEvents here.

This interface is limited to station independent features. Use WeatherStationAdvanced for station dependent features.

Hierarchy

Properties

The used interface settings. These control the addressed serialport, the baud rate, the used units, etc. They are immutable.

See

WeatherStationSettings

defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single event. This limit can be changed for individual WeatherStation instances using the setMaxListeners method.

To change the default for all EventEmitter instances, this property can be used. If this value is not a positive number, a RangeError is thrown.

defaultSettings: WeatherStationSettings = ...

The WeatherStation's default settings.

Accessors

Methods

  • Validates the connection to the console by running the TEST command. No error is thrown on failure, instead false is resolved.

    Parameters

    • Optional timeout: number

    Returns Promise<boolean>

    whether the connection is valid

  • Creates a basic realtime data container. If there already is a basic realtime container this function returns the existing one and ignores the passed settings.

    This basic realtime data container repeatedly calls .getBasicRealtimeData() (and .getHighsAndLows()) in the background to update it's properties. On every (valid) update the (valid-)update is emitted.

    You can listen to them using standard event listeners:

    realtime.on("update", (err?) => console.log(`It's ${realtime.tempOut}°F outside!`)) 
    

    or wait for them asynchroniously:

    await realtime.waitForUpdate();
    console.log(`It's ${realtime.tempOut}°F outside!`);

    Parameters

    Returns BasicRealtimeDataContainer

    the new or existing realtime data container

    Example

    const realtime = WeatherStation.connectBasicRealtimeDataContainer({
    updateInterval: 1,
    });
    await realtime.waitForUpdate();

    console.log(`It's ${realtime.tempOut}°F outside!`);
    realtime.pause();
  • Closes the connection to the weather station (if it's open). Throws no error if the connection is already closed.

    Returns Promise<void>

    Throws

    a SerialPortError if an error occurrs while closing the connection

  • Synchronously calls each of the listeners registered for the event eventName, in the order they were registered, passing the supplied arguments to each. Returns true if the event had listeners, false otherwise.

    Type Parameters

    Parameters

    Returns boolean

    whether the event had listeners

  • Returns an array listing the events for which the WeatherStation has registered listeners.

    Type Parameters

    Returns U[]

    an array listing the events for which the WeatherStation has registered listeners

  • Gets the default (restructured) LOOP package. The return value is dependent on the weather station's model. This might be either a LOOP1 or a LOOP2 package (or null if an error occurrs).

    Parameters

    • Optional timeout: number

    Returns Promise<[null, VantError] | [LOOP1 | LOOP2, undefined]>

    the default LOOP package

    Link

    Following errors are possible:

  • Gets the console's firmware date code in the "Month dd yyyy" format (e.g. "Sep 12 2017").

    Parameters

    • Optional timeout: number

    Returns Promise<[string, undefined] | [null, VantError]>

    the console's firmware date code

    Link

    Following errors are possible:

  • Gets the backwards compatible weather station type as string.

    • Wizard III
    • Wizard II
    • Monitor
    • Perception
    • GroWeather
    • Energy Enviromontor
    • Health Enviromonitor
    • Vantage Pro / Pro 2
    • Vantage Vue
    • null (an error occurred)

    Parameters

    • Optional timeout: number

    Returns Promise<[null, VantError] | ["Wizard III" | "Wizard II" | "Monitor" | "Perception" | "GroWeather" | "Energy Enviromontor" | "Health Enviromonitor" | "Vantage Pro / Pro 2" | "Vantage Vue", undefined]>

    the backwards compatible weather station type

    Link

    Following errors are possible:

  • Gets the backwards compatible weather station type. Use getWeatherstationType to get the type as string.

    • 0 => Wizard III
    • 1 => Wizard II
    • 2 => Monitor
    • 3 => Perception
    • 4 => GroWeather
    • 5 => Energy Enviromontor
    • 6 => Health Enviromonitor
    • 16 => Vantage Pro / Pro 2
    • 17 => Vantage Vue
    • null => An error occurred

    Parameters

    • Optional timeout: number

    Returns Promise<[null, VantError] | [0 | 1 | 16 | 2 | 3 | 4 | 6 | 5 | 17, undefined]>

    the backwards compatible weather station type

    Link

    Following errors are possible:

  • Returns whether the interface tries to hold the connection to the weather station. After calling connect() this will return true. After calling disconnect() it will return false.

    Returns boolean

    whether the interface tries to hold the connection

  • Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

    Type Parameters

    Parameters

    Returns WeatherStation

    this (for chaining calls)

  • Reconnects to the weather station (opens the serial connection and wakes the station up).

    Parameters

    • Optional timeout: number

    Returns Promise<void>

    Link

    Following errors are possible:

  • Turns the console's background light off / on. Returns whether the command was executed successful.

    Parameters

    • state: boolean

      whether the background light should be on

    • Optional timeout: number

    Returns Promise<[boolean, undefined | VantError]>

    whether the command was executed successful

    Link

    Following errors are possible:

  • By default, a maximum of 10 listeners can be registered for any single event. This limit can be changed for individual WeatherStation instances using this method.

    To change the default for all EventEmitter instances, change defaultMaxListeners.

    Parameters

    • maxListeners: number

      new limit for the amount of listeners for any single event on this WeatherStation instance

    Returns WeatherStation

    this (for chaining calls)

  • Creates a connection to your vantage console (Vue, Pro, Pro 2) using the passed settings (see MinimumWeatherStationSettings). The device should be connected serially. Throws an error if connecting fails.

    Weather station dependent functionality (e.g. firmware version code for Vantage Pro 2 / Vue) is not supported on this interface. Use WeatherStationAdvanced for more features.

    Parameters

    Returns Promise<WeatherStation>

    Example

    const device = await WeatherStation.connect({ path: "COM3", rainCollectorSize: "0.2mm" });

    const [highsAndLows, err] = await device.getHighsAndLows();
    inspect(highsAndLows);

    await device.disconnect();

    Link

    Following errors are possible:

Generated using TypeDoc