Wireless Network Trigger Unreliable on M1 Macs?

Hi There,

Coming from an 16" Intel MBP I am now rocking a 14" Apple Silicon MBP.

Here my existing KM macros for changing the network location based on a wireless network trigger seem to fail in most cases. I have attached both scripts for my work and home locations – since my macros may be faulty. Any help is 100% welcome.

Many thanks in advance,
Yves

@peternlewis?

You can turn on Wireless Network debugging with the command:

defaults write com.stairways.keyboardmaestro.engine Debug Wireless

and then restart the Keyboard Maestro Engine (File ➤ Quit Engine, File ➤ Launch Engine).

That will log in to the Engine.log file each time Keyboard Maestro is notified of a wireless network change, but it wont tell you what networks are actually there.

You can use the WirelessNetwork token to list the current networks.

So between those two you should be able to see if the system is letting Keyboard Maestro know about the change, and what networks it thinks are connected.

1 Like

Hi Peter,

Thanks for taking care of my minor quibble. After I stopped shutting down my MBP, whenever I left the office or home and booted it up at the corresponding other location – meaning I leave it now permanently on – both macros work flawless. They discover the wireless network change and set the network location accordingly.

If I am at the other location with a different WiFi and boot up the M1 MBP there, the KM engine doesn’t seem to reliable detect the WiFi change.

I am pasting the KM engine log part of a freshly booted M1 MBP below:

2022-01-16 10:52:24 Debugging level set to ' Wireless '
2022-01-16 10:52:24 Engine Starting 10.0.2
2022-01-16 10:52:24 Old engine details remains a running process Running Engine Details/565
2022-01-16 10:52:24 Old engine details remains a running process Running Engine Details/570
2022-01-16 10:52:24 Daemon launched by login window. Initiating login actions.
2022-01-16 10:52:24 Execute macro “Init” from trigger At Login
2022-01-16 10:54:07 handleInterfaceChanged Notification Received
2022-01-16 10:54:07 handle handleInterfaceChanged Notification Received
2022-01-16 10:54:57 handleInterfaceChanged Notification Received
2022-01-16 10:54:57 handle handleInterfaceChanged Notification Received

At the end of the log above I changed the network location manually.

And here is a KM engine log part where the KM engine discovered the WiFi change by itself (on an M1 MBP that was on and just woke up):

2022-01-18 11:47:44 handleInterfaceChanged Notification Received
2022-01-18 11:47:44 handle handleInterfaceChanged Notification Received
2022-01-18 11:47:48 handleInterfaceChanged Notification Received
2022-01-18 11:47:48 handle handleInterfaceChanged Notification Received
2022-01-18 11:47:48 HandleChangeNotification
2022-01-18 11:47:48 Execute macro “Set Network Location to Work” from trigger Wireless Network “Quarantine” is Connected
2022-01-18 11:47:48 handleInterfaceChanged Notification Received
Last message repeated 4 times
2022-01-18 11:47:48 handle handleInterfaceChanged Notification Received
Last message repeated 4 times
2022-01-18 11:47:49 handleInterfaceChanged Notification Received
2022-01-18 11:47:49 handle handleInterfaceChanged Notification Received
2022-01-18 11:48:47 handleInterfaceChanged Notification Received
2022-01-18 11:48:47 handle handleInterfaceChanged Notification Received
2022-01-18 11:49:03 handleInterfaceChanged Notification Received
2022-01-18 11:49:04 handle handleInterfaceChanged Notification Received

If both logs help you to narrow the problem down, I am happy proceed with any additionally information needed. If it is how it is I now at least have some kind of workaround.

Cheers, Yves

PS Keyboard Maestro is one of if not the greatest piece of software. Thanks for making it!

A network “change” does not happen when Keyboard Maestro Engine launches. It does not matter what the network was when Keyboard Maestro Engine quit, whatever it is when it launches is accepted as the current network, and only a change from that to something else could cause the trigger to fire.

I see, that totally makes sense. I will change my two macros above so that they store the current *%WirelessNetwork%*in a global variable. And upon the Engine Launch Trigger I will check if that variable is different from the current WiFi and if yes, I will set the current network location accordingly. I will report back, if this solves my problem.

1 Like

Many thanks to @peternlewis for pointing me in the right direction. With his help I was able to solve my problem with a three way approach:

  1. Trigger the macro when the Keyboard Maestro engine lauches.
  2. Trigger the macro when when the Mac awakes from sleep.
  3. And compare the current Wireless Network Name with the name of the last Wireless Network Name which is stored in a global variable.

My slight feeling is, that 3. might be not necessary – but who knows. Without further ado here is an image from my macro, which runs now for several weeks rock solid:

1 Like

You could also perhaps use my generic token monitoring utility which, as posted, monitors the token %WirelessNetwork% and notifies us when its value is changed. It uses a similar approach to yours, but it handles multiple tokens at the same time so it uses a dictionary rather than a variable.

Hi @Sleepy,

Many thanks for the tip – I will check your Token Change Monitor Macro.

Big THX,
Yves