LVAR variable to turn liveweather ON / OFF

Hello, it would be very helpful to have a LVAR variable to be able to turn
live weather on or off. I would love to assign a physical switch (home cockpit
user) to turn live weather on or off (without using the screen

Thanks Okan Sacli

Yeah at the very least I would like to know if its on or off.

Rob Murdoch

We’re really not setting the bar very high here… I’d like an API where I can retrieve the current loaded weather data plus a ‘live weather’ flag. The parameters for the weather are pretty basic (wind layers, cloud layers, temp/pressure) so reading that in a single query should be relatively simple.

Knowing whether live weather is on or off would be very useful for avionics developers, as then we can know whether to apply cold weather altimetry corrections based on temperature as some real systems do, or not. Applying corrections with offline weather would be counter-productive, as it does not seem to actually alter the lapse rate with temperature.

const wx_listener = RegisterViewListener("JS_LISTENER_WEATHER", () => {});

wx_listener.on('UpdatePreset', (weather) => {
	const is_live = weather.index == 0;
	console.log(weather, is_live);
	// You're welcome!

wx_listener.on('SetWeatherList', (weather_presets) => {
	// If you want the list of wx presets.

To note…

  1. You have to unregister (wx_listener.unregister()) and re-register the ViewListener if you want to get fresh data periodically. The sim doesn’t trigger UpdatePreset when the preset changes despite what the event name infers.
  2. The weather data provided in the live “preset” is total BS and cannot be relied on. Getting nearest METAR station data is possible but the code to get it is ridiculously overcomplicated. I can get in the weeds if someone really needs it.
  3. Search for html_ui/js/services/weather.js to get the full list of capabilities. It’s what the weather panel uses to control weather settings. Yes you can also inject custom weather that way :wink:
  4. This works on avionics and in-game panels. If you need this to run in the sim’s toolbar, please refer to this project: GitHub - parallel42/msfs-toolbar-interop

To set weather to live:

wx_listener.trigger('CUSTOM_WEATHER_PRESET_CHANGED', 0); // Use the ID of the desired preset. 0 = Live

Keven Menard


Keven this is awesome - massively appreciated. I looked at weather.js as soon as I discovered it but on my own I totally failed to get it to give me the ‘current preset info’. Your code worked straight out of the box.

For multiplayer gliding in MSFS the ability to signature the loaded weather is really quite important, so thanks again.

1 Like