diff --git a/api/sensor.php b/api/sensor.php index 93757ff..05f75c6 100644 --- a/api/sensor.php +++ b/api/sensor.php @@ -16,7 +16,7 @@ class sensor extends cora\crud { ]; public static $cache = [ - 'sync' => 300 // 5 Minutes + 'sync' => 180 // 3 Minutes ]; /** diff --git a/api/thermostat.php b/api/thermostat.php index c4e4b4d..b0e2965 100644 --- a/api/thermostat.php +++ b/api/thermostat.php @@ -18,7 +18,7 @@ class thermostat extends cora\crud { ]; public static $cache = [ - 'sync' => 300 // 5 Minutes + 'sync' => 180 // 3 Minutes ]; /** diff --git a/js/beestat/ecobee.js b/js/beestat/ecobee.js index 2404625..69578d5 100644 --- a/js/beestat/ecobee.js +++ b/js/beestat/ecobee.js @@ -16,10 +16,10 @@ beestat.ecobee.notify_if_down = function() { beestat.ecobee.down_notification_ = new beestat.component.down_notification(); } - // if (down === true) { - // beestat.ecobee.down_notification_.render($('body')); - // } else { - // beestat.ecobee.down_notification_.dispose(); - // } + if (down === true) { + beestat.ecobee.down_notification_.render($('body')); + } else { + beestat.ecobee.down_notification_.dispose(); + } } }; diff --git a/js/beestat/poll.js b/js/beestat/poll.js index 3fe537d..6d8a388 100644 --- a/js/beestat/poll.js +++ b/js/beestat/poll.js @@ -36,6 +36,20 @@ beestat.disable_poll = function() { beestat.poll = function() { var api = new beestat.api(); + api.add_call( + 'thermostat', + 'sync', + {}, + 'thermostat_sync' + ); + + api.add_call( + 'sensor', + 'sync', + {}, + 'sensor_sync' + ); + api.add_call( 'user', 'read_id', @@ -94,7 +108,6 @@ beestat.poll = function() { beestat.cache.set('ecobee_thermostat', response.ecobee_thermostat); beestat.cache.set('ecobee_sensor', response.ecobee_sensor); beestat.enable_poll(); - beestat.dispatcher.dispatchEvent('poll'); beestat.ecobee.notify_if_down(); }); diff --git a/js/component/card/sensors.js b/js/component/card/sensors.js index 8675b25..adbf07d 100644 --- a/js/component/card/sensors.js +++ b/js/component/card/sensors.js @@ -3,9 +3,18 @@ */ beestat.component.card.sensors = function() { var self = this; - beestat.dispatcher.addEventListener('poll', function() { + + var change_function = beestat.debounce(function() { self.rerender(); - }); + }, 10); + + beestat.dispatcher.addEventListener( + [ + 'cache.thermostat', + 'cache.ecobee_thermostat' + ], + change_function + ); beestat.component.card.apply(this, arguments); }; diff --git a/js/component/card/system.js b/js/component/card/system.js index 215805c..054b719 100644 --- a/js/component/card/system.js +++ b/js/component/card/system.js @@ -5,9 +5,17 @@ beestat.component.card.system = function() { var self = this; - beestat.dispatcher.addEventListener('poll', function() { + var change_function = beestat.debounce(function() { self.rerender(); - }); + }, 10); + + beestat.dispatcher.addEventListener( + [ + 'cache.thermostat', + 'cache.ecobee_thermostat' + ], + change_function + ); beestat.component.card.apply(this, arguments); };