1
0
mirror of https://github.com/beestat/app.git synced 2025-05-24 02:14:03 -04:00

Resolved issues with down notification.

This commit is contained in:
Jon Ziebell 2020-01-31 20:00:01 -05:00
parent 967bb5d446
commit 131fee9442
6 changed files with 42 additions and 12 deletions

View File

@ -16,7 +16,7 @@ class sensor extends cora\crud {
];
public static $cache = [
'sync' => 300 // 5 Minutes
'sync' => 180 // 3 Minutes
];
/**

View File

@ -18,7 +18,7 @@ class thermostat extends cora\crud {
];
public static $cache = [
'sync' => 300 // 5 Minutes
'sync' => 180 // 3 Minutes
];
/**

View File

@ -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();
}
}
};

View File

@ -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();
});

View File

@ -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);
};

View File

@ -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);
};