login(); if ($login_results) { /** * we get the current site mgmt settings */ $current_site_settings = $unifi_connection->list_settings(); $mgmt_settings = []; foreach ($current_site_settings as $section) { if ($section->key == 'mgmt') { $mgmt_settings = $section; } } /** * toggle the auto upgrade setting and set the auto upgrade hour to 3 */ $mgmt_settings->auto_upgrade = !$mgmt_settings->auto_upgrade; $mgmt_settings->auto_upgrade_hour = 3; $mgmt_id = $mgmt_settings->_id; $set_result = $unifi_connection->set_site_mgmt($mgmt_id, $mgmt_settings); echo 'done' . PHP_EOL; exit(); } echo 'login failed' . PHP_EOL;