If you're using an M1 or M2 iPad with an external monitor you'll have noticed that the only audio available is that monitor. If there are no speakers or if the built in monitor speakers are lousy you have a couple choices for audio. Of course, AirPods are an option. Bluetooth to an audio speaker. If the monitor has an audio out you could plug in speakers. But HomePods are another option.
It might seem at first that this won't work. When using Music or the TV app, if you select HomePods from the AirPlay widget you'll get an error: "AirPlay is unavailable while an external display is connected."
The solution is a simple shortcut. Run this and you can play audio to your HomePods when connected to an external monitor. If you pause playback for for more than a few minutes you'll have to re-run it because audio will default back to the connected monitor.
Other benefits of using this Shortcut: It seems to connect a bit faster than using the built in AirPlay widget found in apps. When I use that widget in the Music or Podcast app it actually transfers "ownership" of the audio stream to the HomePods. So, really, it's not AirPlaying the stream from the iPad/iPhone to the HomePods but rather the HomePods become the new source device:
When using the Shortcut the iPad or iPhone remains the source device and pushes the audio to the HomePods:
Another benefit when using the Shortcut is bedtime playing of a podcast. By using the shortcut method I can set the sleep timer in the Podcast app from the device. This isn't an option when using the AirPlay widget.