From b2239e4bbb7bbcb81f3f4d516114a36a1b30cae3 Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Wed, 8 Jan 2020 18:56:29 -0500 Subject: [PATCH] Closed #214 - Show last updated date on temperature profiles --- js/component/card/temperature_profiles.js | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/js/component/card/temperature_profiles.js b/js/component/card/temperature_profiles.js index 52b7249..1c8a76f 100644 --- a/js/component/card/temperature_profiles.js +++ b/js/component/card/temperature_profiles.js @@ -193,6 +193,32 @@ beestat.component.card.temperature_profiles.prototype.get_title_ = function() { return 'Temperature Profiles'; }; +/** + * Get the subtitle of the card. + * + * @return {string} The subtitle. + */ +beestat.component.card.temperature_profiles.prototype.get_subtitle_ = function() { + var thermostat = beestat.cache.thermostat[beestat.setting('thermostat_id')]; + var thermostat_group = beestat.cache.thermostat_group[ + thermostat.thermostat_group_id + ]; + + /* + * All profiles are calculated at the same time, and resist is the most + * guaranteed one to have. + */ + if (thermostat_group.temperature_profile.resist !== undefined) { + var generated_at_m = moment( + thermostat_group.temperature_profile.resist.metadata.generated_at + ); + + return 'Generated ' + generated_at_m.format('MMM Do @ h a') + ' (updated weekly)'; + } + + return null; +}; + /** * Decorate the menu. *