| ... |
... |
@@ -182,7 +182,7 @@ function authenticate() {
|
|
182 |
182 |
}, function () {
|
|
183 |
183 |
console.log('failed');
|
|
184 |
184 |
});
|
|
185 |
|
- get_status();
|
|
|
185 |
+ timed_switch_home(15*60);
|
|
186 |
186 |
} else {
|
|
187 |
187 |
console.log('------Unexpected error : authentication is OK but no SID retrieved');
|
|
188 |
188 |
message = "Auth error, no SID";
|
| ... |
... |
@@ -280,15 +280,17 @@ function timed_switch_home(duration) {
|
|
280 |
280 |
console.log('---- authenticate');
|
|
281 |
281 |
if (sid != "") {
|
|
282 |
282 |
var epoch = Math.round(new Date().getTime() / 1000.0);
|
|
283 |
|
- var start_ts = epoch //+ 10
|
|
|
283 |
+ var start_ts = epoch + 10
|
|
284 |
284 |
var end_ts = duration + start_ts
|
|
285 |
|
- console.log('---- switching home mode for ' + duration + 'seconds');
|
|
|
285 |
+ var d= new Date(end_ts*1000)
|
|
|
286 |
+ var end_time = d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
|
|
|
287 |
+ console.log('---- switching home mode for ' + duration + 'seconds, until '+end_time);
|
|
286 |
288 |
url_path = "/webapi/entry.cgi?api=SYNO.SurveillanceStation.HomeMode&version=1&method=SaveOneTimeSwitch&onetime_enable_on=true&onetime_disable_on=true&onetime_enable_time=" + start_ts + "&onetime_disable_time=" + end_ts + "&_sid=" + sid;
|
|
287 |
289 |
method = "GET"
|
|
288 |
290 |
onload_switch_function = function (xhr) {
|
|
289 |
291 |
response = JSON.parse(xhr.responseText);
|
|
290 |
292 |
if (response.success == true) {
|
|
291 |
|
- message = "Home mode is ON for "+duration+" seconds";
|
|
|
293 |
+ message = "Home mode is ON until "+end_time;
|
|
292 |
294 |
}else{
|
|
293 |
295 |
message = "something happened, try again ! (S200)";
|
|
294 |
296 |
}
|
| ... |
... |
@@ -383,8 +385,8 @@ Pebble.addEventListener('appmessage', function (e) {
|
|
383 |
385 |
get_status();
|
|
384 |
386 |
break;
|
|
385 |
387 |
case 'home_on':
|
|
386 |
|
- //switch_home(true);
|
|
387 |
|
- timed_switch_home(15*60)
|
|
|
388 |
+ switch_home(true);
|
|
|
389 |
+ //timed_switch_home(15*60)
|
|
388 |
390 |
break;
|
|
389 |
391 |
case 'home_off':
|
|
390 |
392 |
switch_home(false);
|