Inspired by this blog post but found the scipt didn't work quite right because it used single quotes ('
) instead of double inside the JSON body. The tweaked scripts look like this:
#!/bin/sh
username=admin
password=changeme
baseurl=https://localhost:8443
site=default
cookie=/tmp/unifi_cookie
curl_cmd="curl --tlsv1 --silent --cookie ${cookie} --cookie-jar ${cookie} --insecure "
${curl_cmd} --data '{"username":"'"$username"'", "password":"'"$password"'"}' $baseurl/api/login
${curl_cmd} --data '{ "led_enabled": true}' $baseurl/api/s/$site/set/setting/mgmt
#!/bin/sh
username=admin
password=changeme
baseurl=https://localhost:8443
site=default
cookie=/tmp/unifi_cookie
curl_cmd="curl --tlsv1 --silent --cookie ${cookie} --cookie-jar ${cookie} --insecure "
${curl_cmd} --data '{"username":"'"$username"'", "password":"'"$password"'"}' $baseurl/api/login
${curl_cmd} --data '{ "led_enabled": false}' $baseurl/api/s/$site/set/setting/mgmt
The rest of the post is still accurate and I encourage you to check it out for more details on exactly how to schedule using cron.