Detecting when the user is actually "in sim" vs in the menus using python-simconnect?

I’m using Python-SimConnect and am trying to detect whether we’re actually “in the game” or not, but I can’t seem to find any variable I can query on the Simuation Variables docs page that lets me check whether we loaded into the world or not. Is there a variable for this? Or if it’s an event, I can’t seem to find anything in the Event IDs pages either that sounds like it’d be useful. What am I missing?

There’s a few vars that “sort of” tell me whether we’re “probably” loaded in the sim by looking at things like GROUND_ALTITUDE being 0.0 but that’s also a real value when flying over water or even land that’s exactly at sea level so that’s not all that reliable, and I could look at AVIONICS_MASTER_SWITCH but that only tells me whether the plane’s active, not whether we’re in the sim or not. And things like AMBIENT_PRESSURE are set to a real value even when we’re not loaded into the sim, so that’s a no-go either.

I could use the combination of {AMBIENT_TEMPERATURE, AMBIENT_VISIBILITY, AMBIENT_WIND_DIRECTION} which seems to be {20.0,20000.0,225.0} while not in the game, with null/None values while loading, but that seems… fragile? If MSFS changes those defaults in any update, in-game detection based on ambient values will break. And it also ends up flagging as being in the game well before the loading screen is done, so that’s not ideal.

Turns out that the SIM_START and SIM_END events are bound as a boolean called sm.running, which can be used to determine whether the user is “in the world” or not.

And then if you want to be even more specific, you can additionally look at the CAMERA_STATE value (although that needs a bit of work), and check whether that’s an int, and if so, if it’s <= 6 (anything higher than that and we’re basically not in one of the many “the user is not in control” modes) as well as CRASH_FLAG > 0 || CRASH_SEQUENCE > 0 so that we don’t consider the user “flying” during the time they crashed and clicked through to restart.