I gave up on trying to control motion the way your're suppose to, so decided to write my own rough and ready python script.
It essentially searches through the motion.conf for predefined strings "from strings", then replaces them with "to strings". I call the python scrip using a cronjob to automate the process.
Below is the script, if anyone is having the same problems as I did for ages!
#!/usr/bin/env python
###############################################################################
# This script opens Motion's configuration file, searches through it for
# "from" then copies the contents and replacements "to"
# (eg from = threshold 300 to threshold 6000) to the tmp.conf file.
# It then renames the un-modified existing motion.conf file to
# "motion_old.conf" for backup purposes; before renaming the "temp.conf" to
# "motion.conf", the new modified file.
# It then sets the new motion.conf file to user "motion" and group "motion",
# before restarting motion.
###############################################################################
###############################################################################
# call the script from cronjob for 5:30AM
#
# 30 5 * * * sudo /usr/src/scripts/mod_file/modify_motionconf_night_to_day_garden.py
#
###############################################################################
import os, sys
infile = open('/etc/motion.conf') # the motion.conf file that will be renamed for backup purposes
outfile = open('/etc/tmp.conf', 'w') # temp file to write to
# from to
replacements = {'threshold 300':'threshold 6000', 'text_left garden cam night':'text_left garden cam day', '#----night----#':'#----day----#'}
# threshold 189 text_left 389 #----xxx----# 5 line numbers in motion.conf
############################################################################### search and create new temp file part
for line in infile:
for src, target in replacements.items():
line = line.replace(src, target)
outfile.write(line)
infile.close()
outfile.close()
############################################################################### search and create new temp file part end
#os.remove('/etc/motion.conf') # uncomment if you don't want a backup
os.rename("/etc/motion.conf","/etc/motion_old.conf")
#delay or not?
os.rename("/etc/tmp.conf","/etc/motion.conf")
os.system("chown :motion /etc/motion.conf")
os.system("chown motion /etc/motion.conf")
os.system("sudo /etc/init.d/motion restart")
It's not elegant, but it works,
Kind Regards,
Reggie.