|
71 | 71 |
|
72 | 72 | from utils import calc_percent_limit, str2time, dp0, dp2, dp4, format_time_ago, get_override_time_from_string, history_attribute, prune_today, mask_secret_args |
73 | 73 | from const import TIME_FORMAT, TIME_FORMAT_DAILY, TIME_FORMAT_HA |
74 | | -from predbat import THIS_VERSION |
| 74 | +from predbat import THIS_VERSION_DISPLAY |
75 | 75 | from component_base import ComponentBase |
76 | 76 | from config import APPS_SCHEMA |
77 | 77 | from web_annual import AnnualPage |
@@ -808,6 +808,11 @@ def get_status_html(self, version): |
808 | 808 |
|
809 | 809 | status_entity = self.prefix + ".status" |
810 | 810 | last_updated = self.get_state_wrapper(status_entity, attribute="last_updated", default=None) |
| 811 | + if last_updated: |
| 812 | + try: |
| 813 | + last_updated = str2time(last_updated).replace(tzinfo=None, microsecond=0) |
| 814 | + except (ValueError, TypeError) as e: |
| 815 | + self.log("Warn: Failed to parse last_updated time {}: {}".format(last_updated, e)) |
811 | 816 | status = self.get_state_wrapper(status_entity, default="Unknown") |
812 | 817 | detail = self.get_state_wrapper(status_entity, attribute="detail", default="") |
813 | 818 | debug = self.get_state_wrapper(status_entity, attribute="debug", default="") |
@@ -1607,7 +1612,7 @@ def get_header(self, title, refresh=0, codemirror=False): |
1607 | 1612 | if self.base.update_pending: |
1608 | 1613 | calculating = True |
1609 | 1614 | self.update_success_timestamp() |
1610 | | - return get_header_html(title, calculating, self.default_page, self.arg_errors, THIS_VERSION, self.get_battery_status_icon(), refresh, codemirror=codemirror) |
| 1615 | + return get_header_html(title, calculating, self.default_page, self.arg_errors, THIS_VERSION_DISPLAY, self.get_battery_status_icon(), refresh, codemirror=codemirror) |
1611 | 1616 |
|
1612 | 1617 | def get_chart_series(self, name, results, chart_type, color): |
1613 | 1618 | """ |
@@ -2831,7 +2836,7 @@ async def html_dash_content(self, request): |
2831 | 2836 | """ |
2832 | 2837 | Return just the dashboard body content for AJAX refresh (preserves scroll position) |
2833 | 2838 | """ |
2834 | | - text = self.get_status_html(THIS_VERSION) |
| 2839 | + text = self.get_status_html(THIS_VERSION_DISPLAY) |
2835 | 2840 | return web.Response(content_type="text/html", text=text) |
2836 | 2841 |
|
2837 | 2842 | async def html_dash(self, request): |
@@ -2880,7 +2885,7 @@ async def html_dash(self, request): |
2880 | 2885 | """ |
2881 | 2886 | text += "<body>\n" |
2882 | 2887 | text += '<div id="dash-content-container">\n' |
2883 | | - text += self.get_status_html(THIS_VERSION) |
| 2888 | + text += self.get_status_html(THIS_VERSION_DISPLAY) |
2884 | 2889 | text += "</div>\n" |
2885 | 2890 | text += "</body></html>\n" |
2886 | 2891 | return web.Response(content_type="text/html", text=text) |
|
0 commit comments