The basic idea is to turn on the external equipment whenever there is recent activity within the mopidy log file and turn off the power when there has been no log activity and no active sound output for a long-ish while.
FYI, the stereo_power.sh script (which is not included) operates a cheap Tonbux 4 outlet WiFi Smart Power Strip. If you are interested, that script gets the job done using the TUYA cli: https://github.com/TuyaAPI/cli