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
PMDG

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.
	console.log(weather_presets);
});
wx_listener.trigger('ASK_WEATHER_LIST');

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
//42

4 Likes

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

Hi Keven !
I really donā€™t know anything about code, but, although I have live weather on, the Sun desperately shines everywhere ! (Iā€™m playing on PC) Could your code line help me ? But what should I do with it ?
Thanx for your help !