
-----
When our FlexRadio is not being used it really should do 'something'. We typically put it in a WSPR spotting mode via WSJT-X, but sometimes we forget. This short simple Python script takes care of that.
----
FlexRadio has an open API and we could have just used it to accomplish the project. However, there is wonderful (and free) program that is always open on the PC running with the FlexRadio SmartSDR software that make things even easier. We use FRStack for it's API calls and to automatically set things up for WSJT-X when the rig is idle. NOTE: We use FRStack for other features as well. IMO it is a must have program to make your Flex more flexible.
-----
The Python script listed below looks at user defined intervals (in the example it is every 60 minutes) to see if any settings on the rig have changed. If a setting has changed (frequency, band, mode, volume, filters, etc. etc. etc...) the program assumes the rig is in use and just waits for the next check interval.

-----
If the time interval expires and no settings have been changed the program assumes the rig is idle and switches it to DIGU mode and starts reporting WSPR spots.

-----
# auto_wspr.py OCT2023
# JUN2026 edits removes Slicemaster dependency
#
# Python script to make the Flex Radio switch to WSPR mode when idle.
#
# Written by: WhiskeyTangoHotel.Com
#
# Leverages the auto LAUNCH feature of "Slice Master".
# We don't use Slicemaster for Spots.
# Now prog excepts WSJT-X runs all the time. Spots by FRSTACK
# https://github.com/K1DBO/slice-master-6000
#
# Leverages WSJT-X for TX/Rx spotting
# https://wsjt.sourceforge.io/wsjtx.html
#
# Leverages FRStack
# https://www.mkcmsoftware.com/download/FRStackWebApiReadme.html#apis
import requests
import urllib.request
import time
from datetime import datetime
import pytz
# Dictionary mapping city names to their respective timezones
city_timezones = {
"austin": "America/Chicago"
# Add more cities and their timezones if needed
}
city = "austin" # Change this to any city you want to get the local time for
# Get the timezone for the given city
timezone = pytz.timezone(city_timezones.get(city.lower()))
# Set idle_max to the number of minutes between checks to see if any rig settings have changed.
# If idle rig then switch to DIGU mode. DIGU mode will trigger Slice Master to start WSJT-X.
idle_max = 60 # in minutes, How ofen to check to see if the rig is idle.
# 9 WSPR frequencies listed to cycle through
wspr_bands = [
("80m", 3.5686),
("40m", 7.0386),
("30m", 10.1387),
("20m", 14.0956),
("17m", 18.1046),
("15m", 21.0946),
("12m", 24.9246),
("10m", 28.1246),
("6m", 50.2930)
]
band_index = 0
last_status = 'First_run'
mode = ' '
#print ( 'Entering endless loop.....' )
while True:
print ('Checking for rig activity every' , idle_max , 'minutes.')
print ('---------------------------------------------------')
# If rig is in DIGU mode then do nothing. We are already running WXJT
response = requests.get('http://localhost:13522/api/ActiveSlice/MODE?')
response = response.text
mode = response
#print ('MODE is:' , response)
if response == '"DIGU"':
print('Rig already in DIGU mode.')
print('Cycling to next WSPR band.')
# Tune to the next WSPR band
band_name, freq = wspr_bands[band_index]
print(f"Switching to {band_name} WSPR ({freq} MHz)")
urllib.request.urlopen(
f'http://localhost:13522/api/ActiveSlice/FREQ?={freq}'
)
# Advance to the next band for the next idle cycle
band_index = (band_index + 1) % len(wspr_bands)
else: # not in DIGU mode. Have rig settings changed or is it idle?
response = requests.get('http://localhost:13522/api/ActiveSlice/INFO?')
current_status = response.text
if last_status != current_status:
print('Rig in use. Do not change to DIGU. Do not launch WSJT')
last_status = current_status
else:
print('Rig has been idle for', idle_max, 'minutes.')
# DIGU modes can be LOUD. Adjust the volume to low
urllib.request.urlopen(
'http://localhost:13522/api/ActiveSlice/AUDIOGAIN?=+1'
)
# Switch rig to DIGU mode
urllib.request.urlopen(
'http://localhost:13522/api/ActiveSlice/MODE?=DIGU'
)
# Tune to the first WSPR band after becoming idle
band_name, freq = wspr_bands[band_index]
print(f"Switching to {band_name} WSPR ({freq} MHz)")
urllib.request.urlopen(
f'http://localhost:13522/api/ActiveSlice/FREQ?={freq}'
)
band_index = (band_index + 1) % len(wspr_bands)
# Remember this status so we don't repeatedly think the rig
# has just become idle.
last_status = current_status
for nextcheck in range(idle_max, 0, -1):
response = requests.get('http://localhost:13522/api/ActiveSlice/MODE?')
response = response.text
mode = response
response = requests.get('http://localhost:13522/api/ActiveSlice/FREQ?')
response = response.text
freq = response
local_time = datetime.now(timezone)
#print("-------------------------------")
#print(f"The local time in {city.capitalize()}, Texas is:", local_time.strftime("%Y-%m-%d %H:%M:%S %Z"))
print ('MODE:', mode, "@" , freq, '|', local_time.strftime("%H:%M:%S %Z"), "with", int(nextcheck) , "minutes until next idle rig check...")
time.sleep(60) # 60 because one minute increments expected.
print (' ')
# end endless while loop
-----
