Browse code

fix schedule vs manual modes interactions

Louis Jonget authored on29/03/2024 10:58:42
Showing2 changed files
1 1
Binary files a/build/synocam_home_switch.pbw and b/build/synocam_home_switch.pbw differ
... ...
@@ -334,7 +334,20 @@ function switch_home(bool) {
334 334
     console.log('---- authenticate');
335 335
     if (sid != "") {
336 336
         console.log('---- switching home mode to ' + bool);
337
-        url_path = "/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=" + bool + "&_sid=" + sid;
337
+        var epoch = Math.round(new Date().getTime() / 1000.0);
338
+        var start_ts = epoch + 10
339
+        switch (bool) {
340
+            case true:
341
+                url_path = "/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=SaveOneTimeSwitch&onetime_enable_on=true&onetime_disable_on=false&onetime_enable_time=" + start_ts + "&_sid=" + sid;
342
+                break;
343
+            case false:
344
+                url_path = "/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=SaveOneTimeSwitch&onetime_enable_on=false&onetime_disable_on=true&onetime_disable_time=" + start_ts + "&_sid=" + sid;
345
+                break;
346
+            default:
347
+                message = "something happened, try again ! (IMPOSSIBLE)";
348
+        }
349
+        
350
+        //url_path = "/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=Switch&on=" + bool + "&_sid=" + sid;
338 351
         method = "GET"
339 352
         onload_switch_function = function(xhr) {
340 353
             response = JSON.parse(xhr.responseText);