What I would do personally is use a tag on the port to exclude them, personal preference I find tags a bit cleaner, more portable and they help me remember what automations are running or not running on a port/device/network.
if total_usage_kb == 0:
x = dashboard.switch.getDeviceSwitchPort(serial,port_id)
if "no_auto_shut" in x['tags']:
print('Port {} on {} tagged with no automatic shutdown, skipping'.format(serial,port_id))
else:
dashboard.switch.updateDeviceSwitchPort(serial, port_id,enabled=False)