Readonly
settingsThe used interface settings. These control the addressed serialport, the baud rate, the used units, etc. They are immutable.
WeatherStationSettings
Static
defaultBy 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.
Static
Readonly
defaultThe WeatherStation's default settings.
Whether the interface is currently connected to the weather station.
Adds an event listener. Possible events are described here.
The event to listen for
The listener to add
this (for chaining calls)
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!`);
your desired settings
the new or existing realtime data container
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.
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.
Rest
...args: Parameters<WeatherStationEvents[U]>whether the event had listeners
Returns an array listing the events for which the WeatherStation has registered listeners.
an array listing the events for which the WeatherStation has registered listeners
Gets a handful of useful realtime weather data (see BasicRealtimeData). This includes temperature (in and out), pressure, humidity, wind speed, rain, ...
Optional
timeout: numbera handful of useful realtime weather data (a simple realtime record)
Following errors are possible:
Gets the basic realtime data container that has been created before using .createBasicRealtimeDataContainer()
.
the existing basic realtime data container
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).
Optional
timeout: numberthe default LOOP package
Following errors are possible:
Gets the console's firmware date code in the "Month dd yyyy"
format (e.g. "Sep 12 2017"
).
Optional
timeout: numberthe console's firmware date code
Following errors are possible:
Gets the highs and lows from the console.
Optional
timeout: numberthe highs and lows HighsAndLows
Following errors are possible:
Returns the current max listener value for the WeatherStation which is either set by setMaxListeners or defaults to defaultMaxListeners.
the current max listener value for the current WeatherStation instance
Gets the backwards compatible weather station type as string.
null
(an error occurred)Optional
timeout: numberthe backwards compatible weather station type
Following errors are possible:
Gets the backwards compatible weather station type. Use getWeatherstationType to get the type as string.
0
=> Wizard III1
=> Wizard II2
=> Monitor3
=> Perception4
=> GroWeather5
=> Energy Enviromontor6
=> Health Enviromonitor16
=> Vantage Pro / Pro 217
=> Vantage Vuenull
=> An error occurredOptional
timeout: numberthe backwards compatible weather station type
Following errors are possible:
Returns the number of listeners listening to the event named eventName
.
the number of listeners listening to the event
Returns a copy of the array of listeners for the event named eventName
.
a copy of the array of listeners for the passed event
Alias for removeListener.
this (for chaining calls)
Alias for addListener.
this (for chaining calls)
Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.
this (for chaining calls)
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.
this (for chaining calls)
Adds a one-time listener function for the event named eventName
to the beginning of the listeners array.
The next time eventName
is triggered, this listener is removed, and then invoked.
this (for chaining calls)
Reconnects to the weather station (opens the serial connection and wakes the station up).
Optional
timeout: numberFollowing errors are possible:
Removes all listeners, or those of the specified eventName
.
Optional
eventName: keyof WeatherStationEventsthis (for chaining calls)
Removes the specified listener from the listener array for the event named eventName
.
the event the listener listens to
the listener to remove
this (for chaining calls)
Turns the console's background light off / on. Returns whether the command was executed successful.
whether the background light should be on
Optional
timeout: numberwhether the command was executed successful
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.
new limit for the amount of listeners for any single event on this WeatherStation instance
this (for chaining calls)
Static
connectCreates 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.
the interface settings
const device = await WeatherStation.connect({ path: "COM3", rainCollectorSize: "0.2mm" });
const [highsAndLows, err] = await device.getHighsAndLows();
inspect(highsAndLows);
await device.disconnect();
Following errors are possible:
Generated using TypeDoc
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.