Home Information - Your home, your data, organized.
Python
New system health info page (#214)
Tony C6f10bb76c040
diff --git a/src/hi/apps/alert/monitors.py b/src/hi/apps/alert/monitors.pyindex 5a84b9af..ea98a69c 100644--- a/src/hi/apps/alert/monitors.py+++ b/src/hi/apps/alert/monitors.py@@ -23,11 +23,11 @@ class AlertMonitor( PeriodicMonitor, AlertMixin ):@classmethoddef get_provider_info(cls) -> ProviderInfo:- """ Subclasses should override with something more meaningful. """return ProviderInfo(provider_id = 'hi.apps.alert',provider_name = 'Alert Monitor',- description = '',+ description = 'Alert processing and notification management',+ expected_heartbeat_interval_secs = cls.ALERT_POLLING_INTERVAL_SECS,)async def do_work(self):diff --git a/src/hi/apps/common/templatetags/icons.py b/src/hi/apps/common/templatetags/icons.pyindex fa6b8bbc..92f87316 100644--- a/src/hi/apps/common/templatetags/icons.py+++ b/src/hi/apps/common/templatetags/icons.py@@ -44,6 +44,7 @@ AVAILABLE_ICONS = {'lightbulb','lock','map-pin',+ 'minus-circle','move','path','play',@@ -56,6 +57,7 @@ AVAILABLE_ICONS = {'settings','shield','sync',+ 'tasks','times-circle','upload','video',diff --git a/src/hi/apps/monitor/monitor_manager.py b/src/hi/apps/monitor/monitor_manager.pyindex ccfd13a2..624ef419 100644--- a/src/hi/apps/monitor/monitor_manager.py+++ b/src/hi/apps/monitor/monitor_manager.py@@ -3,6 +3,8 @@ import loggingimport threadingfrom typing import List, Type+from hi.apps.system.health_status_provider import HealthStatusProvider+from django.apps import appsfrom django.conf import settings@@ -44,7 +46,8 @@ class AppMonitorManager( Singleton ):continuelogger.debug( f'Starting app monitor: {monitor.id}' )- asyncio.create_task( monitor.start() )+ asyncio.create_task( monitor.start(),+ name=f'App-{monitor.id}' )continuereturn@@ -57,6 +60,13 @@ class AppMonitorManager( Singleton ):continuereturn+ def get_health_status_providers(self) -> List[HealthStatusProvider]:+ """Get health status providers for all registered monitors.+ Each provider exposes get_provider_info() and health_status.+ """+ with self._data_lock:+ return list( self._monitor_map.values() )+def _discover_periodic_monitors(self) -> List[ Type[ PeriodicMonitor ]]:periodic_monitor_class_list = list()for app_config in apps.get_app_configs():diff --git a/src/hi/apps/monitor/tests/test_periodic_monitor.py b/src/hi/apps/monitor/tests/test_periodic_monitor.pyindex 80b9f1f0..2ed912fe 100644--- a/src/hi/apps/monitor/tests/test_periodic_monitor.py+++ b/src/hi/apps/monitor/tests/test_periodic_monitor.py@@ -24,7 +24,6 @@ class ConcreteTestMonitor(PeriodicMonitor):@classmethoddef get_provider_info(cls) -> ProviderInfo:- """ Subclasses should override with something more meaningful. """return ProviderInfo(provider_id = 'test_monitor',provider_name = 'Test Monitor',@@ -60,7 +59,6 @@ class TestPeriodicMonitor(AsyncTaskTestCase):@classmethoddef get_provider_info(cls) -> ProviderInfo:- """ Subclasses should override with something more meaningful. """return ProviderInfo(provider_id = 'test_monitor',provider_name = 'Test Monitor',diff --git a/src/hi/apps/notify/monitors.py b/src/hi/apps/notify/monitors.pyindex 49c4ab31..ab60e929 100644--- a/src/hi/apps/notify/monitors.py+++ b/src/hi/apps/notify/monitors.py@@ -21,11 +21,11 @@ class NotificationMonitor( PeriodicMonitor, NotificationMixin ):@classmethoddef get_provider_info(cls) -> ProviderInfo:- """ Subclasses should override with something more meaningful. """return ProviderInfo(provider_id = 'hi.apps.notify',provider_name = 'Notifications Monitor',- description = '',+ description = 'Notification processing and delivery management',+ expected_heartbeat_interval_secs = cls.NOTIFICATION_POLLING_INTERVAL_SECS,)async def do_work(self):diff --git a/src/hi/apps/security/monitors.py b/src/hi/apps/security/monitors.pyindex d3163283..d381d08c 100644--- a/src/hi/apps/security/monitors.py+++ b/src/hi/apps/security/monitors.py@@ -27,11 +27,11 @@ class SecurityMonitor( PeriodicMonitor, SettingsMixin, SecurityMixin ):@classmethoddef get_provider_info(cls) -> ProviderInfo:- """ Subclasses should override with something more meaningful. """return ProviderInfo(provider_id = 'hi.apps.security',provider_name = 'Security Monitor',- description = '',+ description = 'Security state monitoring and automated day/night transitions',+ expected_heartbeat_interval_secs = cls.SECURITY_POLLING_INTERVAL_SECS,)async def do_work(self):diff --git a/src/hi/apps/system/aggregate_health_provider.py b/src/hi/apps/system/aggregate_health_provider.pyindex bc4e3a47..009a9679 100644--- a/src/hi/apps/system/aggregate_health_provider.py+++ b/src/hi/apps/system/aggregate_health_provider.py@@ -5,7 +5,8 @@ import threadingfrom typing import Optional, Sequenceimport hi.apps.common.datetimeproxy as datetimeproxy-from .api_health_aggregator import ApiHealthAggregator++from .aggregate_health_status import AggregateHealthStatusfrom .api_health_status_provider import ApiHealthStatusProviderfrom .enums import HealthStatusType, HealthAggregationRulefrom .provider_info import ProviderInfo@@ -32,7 +33,7 @@ class AggregateHealthProvider(ABC):self._api_health_status_providers = [] # Track API health status providersprovider_info = self.get_provider_info()- self._aggregated_health_status = ApiHealthAggregator(+ self._aggregated_health_status = AggregateHealthStatus(provider_id = provider_info.provider_id,provider_name = provider_info.provider_name,status = HealthStatusType.UNKNOWN,@@ -51,7 +52,7 @@ class AggregateHealthProvider(ABC):pass@property- def health_status(self) -> ApiHealthAggregator:+ def health_status(self) -> AggregateHealthStatus:"""Get aggregated health status (thread-safe, always fresh)."""self._ensure_api_aggregator_setup()with self._health_lock:@@ -84,7 +85,7 @@ class AggregateHealthProvider(ABC):continueself._refresh_aggregated_health()return-+def remove_api_health_status_provider(self,api_health_status_provider : ApiHealthStatusProvider@@ -98,7 +99,11 @@ class AggregateHealthProvider(ABC):returndef _refresh_aggregated_health(self) -> None:- """Refresh aggregated health from all tracked API health status providers."""+ """Refresh API status map from all tracked API health status providers.++ Note: The aggregated health status is computed dynamically via the status property,+ so this method only needs to update the API status map.+ """# Clear current sourcesself._aggregated_health_status.api_status_map.clear()@@ -107,10 +112,9 @@ class AggregateHealthProvider(ABC):service_info = provider.get_api_provider_info()api_health = provider.api_health_statusself._aggregated_health_status.api_status_map[service_info] = api_health- continue-- # Update overall status based on aggregation- self._aggregated_health_status.status = self._aggregated_health_status.overall_status++ # Status is now computed dynamically via the status property in AggregateHealthStatus+ # No need to manually update it herereturndef update_health_status( self,diff --git a/src/hi/apps/system/aggregate_health_status.py b/src/hi/apps/system/aggregate_health_status.pynew file mode 100644index 00000000..ebdcf17c--- /dev/null+++ b/src/hi/apps/system/aggregate_health_status.py@@ -0,0 +1,95 @@+from dataclasses import dataclass, field+from typing import Dict++from .health_status import HealthStatus+from .api_health_status import ApiHealthStatus+from .provider_info import ProviderInfo+from .enums import HealthStatusType, ApiHealthStatusType, HealthAggregationRule+++@dataclass+class AggregateHealthStatus( HealthStatus ):+ """+ Extends HealthStatus to add API source tracking and aggregation.+ The status property returns the aggregated health status combined with base status.+ """+ # Current aggregated API health data+ api_status_map : Dict[ProviderInfo, ApiHealthStatus] = field(default_factory=dict)+ aggregation_rule : HealthAggregationRule = HealthAggregationRule.ALL_SOURCES_HEALTHY++ # Store the base status separately (for provider's own health issues)+ _base_status : HealthStatusType = field(default=HealthStatusType.HEALTHY, init=False)++ @property+ def status(self) -> HealthStatusType:+ """+ Override status to return the combined health status.+ Returns the worst of base status and aggregated API status.+ """+ api_health = self.aggregate_health()++ # Return worst of base status and aggregated API status using priority+ # Lower priority number = worse health+ return min([self._base_status, api_health], key=lambda s: s.priority)++ @status.setter+ def status(self, value: HealthStatusType) -> None:+ """Allow setting the base status (for provider's own health issues)."""+ self._base_status = value++ def aggregate_health(self) -> HealthStatusType:+ """+ Returns the computed health based on aggregation rule.+ DISABLED sources are excluded from health calculations.+ """+ if not self.api_status_map:+ return self._base_status # No API sources, use base health++ # Filter out DISABLED sources - they don't contribute to health calculations+ active_api_statuses = [ api.status for api in self.api_status_map.values()+ if api.status != ApiHealthStatusType.DISABLED ]++ # If all sources are disabled, use base health status+ if not active_api_statuses:+ return self._base_status++ # Count status types we need for decision making+ healthy_count = sum( 1 for s in active_api_statuses+ if s == ApiHealthStatusType.HEALTHY )+ failing_count = sum( 1 for s in active_api_statuses+ if s == ApiHealthStatusType.FAILING )+ unavailable_count = sum( 1 for s in active_api_statuses+ if s == ApiHealthStatusType.UNAVAILABLE )++ total_active = len(active_api_statuses)++ # Apply aggregation rule+ if self.aggregation_rule == HealthAggregationRule.ALL_SOURCES_HEALTHY:+ # All active sources must be healthy+ if healthy_count == total_active:+ return HealthStatusType.HEALTHY+ elif failing_count > 0 or unavailable_count > 0:+ return HealthStatusType.ERROR+ else: # Has degraded or unknown sources+ return HealthStatusType.WARNING++ elif self.aggregation_rule == HealthAggregationRule.MAJORITY_SOURCES_HEALTHY:+ # Majority of active sources must be healthy+ if healthy_count > total_active / 2:+ return HealthStatusType.HEALTHY+ elif failing_count > 0 or unavailable_count > 0:+ return HealthStatusType.ERROR+ else:+ return HealthStatusType.WARNING++ elif self.aggregation_rule == HealthAggregationRule.ANY_SOURCE_HEALTHY:+ # At least one active source must be healthy+ if healthy_count > 0:+ return HealthStatusType.HEALTHY+ elif failing_count > 0 or unavailable_count > 0:+ return HealthStatusType.ERROR+ else: # Only degraded/unknown sources+ return HealthStatusType.WARNING++ # Fallback to base status for unknown aggregation rules+ return self._base_statusdiff --git a/src/hi/apps/system/api_health_aggregator.py b/src/hi/apps/system/api_health_aggregator.pydeleted file mode 100644index daaca0cd..00000000--- a/src/hi/apps/system/api_health_aggregator.py+++ /dev/null@@ -1,68 +0,0 @@-from dataclasses import dataclass, field-from typing import Dict--from .health_status import HealthStatus-from .api_health import ApiHealthStatus-from .provider_info import ProviderInfo-from .enums import HealthStatusType, ApiHealthStatusType, HealthAggregationRule---@dataclass-class ApiHealthAggregator( HealthStatus ):- """- Extends HealthStatus to add API source tracking and aggregation.- """- # Current aggregated API health data- api_status_map : Dict[ProviderInfo, ApiHealthStatus] = field(default_factory=dict)- aggregation_rule : HealthAggregationRule = HealthAggregationRule.ALL_SOURCES_HEALTHY-- def aggregate_health(self) -> HealthStatusType:- """- Returns the computed health based on aggregation rule.- """- if not self.api_status_map:- return self.status # No API sources, use base health-- api_statuses = [ api.status for api in self.api_status_map.values() ]-- if self.aggregation_rule == HealthAggregationRule.ALL_SOURCES_HEALTHY:- # All must be healthy- if all( s == ApiHealthStatusType.HEALTHY for s in api_statuses ):- return HealthStatusType.HEALTHY- elif any( s in [ ApiHealthStatusType.FAILING,- ApiHealthStatusType.UNAVAILABLE ]- for s in api_statuses) :- return HealthStatusType.ERROR- else:- return HealthStatusType.WARNING-- elif self.aggregation_rule == HealthAggregationRule.MAJORITY_SOURCES_HEALTHY:- # Majority must be healthy- healthy_count = sum( 1 for s in api_statuses- if s == ApiHealthStatusType.HEALTHY )- if healthy_count > len(api_statuses) / 2:- return HealthStatusType.HEALTHY- else:- return HealthStatusType.WARNING-- elif self.aggregation_rule == HealthAggregationRule.ANY_SOURCE_HEALTHY:- # At least one must be healthy- if any( s == ApiHealthStatusType.HEALTHY for s in api_statuses ):- return HealthStatusType.HEALTHY- else:- return HealthStatusType.ERROR-- return self.status # Fallback to base status-- @property- def overall_status(self) -> HealthStatusType:- """- Get overall status considering both base health and API health.- """- api_health = self.aggregate_health()-- # Return worst of base status and aggregated API status using priority- statuses = [self.status, api_health]-- # Return status with highest priority (lowest priority number)- return min(statuses, key=lambda s: s.priority)diff --git a/src/hi/apps/system/api_health.py b/src/hi/apps/system/api_health_status.pysimilarity index 67%rename from src/hi/apps/system/api_health.pyrename to src/hi/apps/system/api_health_status.pyindex 334fd87a..d2c2b9e0 100644--- a/src/hi/apps/system/api_health.py+++ b/src/hi/apps/system/api_health_status.py@@ -24,12 +24,14 @@ class ApiHealthStatus:provider_id : str # Technical identifierstatus : ApiHealthStatusType- last_success : Optional[datetime] = None- total_calls : int = 0- total_failures : int = 0- consecutive_failures : int = 0- average_response_time : Optional[float] = None- last_response_time : Optional[float] = None+ last_success : Optional[datetime] = None+ total_calls : int = 0+ total_failures : int = 0+ consecutive_failures : int = 0+ average_response_time : Optional[float] = None+ last_response_time : Optional[float] = None+ cache_hits : int = 0+ cache_misses : int = 0def record_api_call( self, api_call_context : ApiCallContext ):self.total_calls += 1@@ -57,7 +59,29 @@ class ApiHealthStatus:self.average_response_time = (( self.average_response_time * 0.8 )+ ( api_call_context.duration * 0.2 ))return++ def record_cache_hit(self) -> int:+ self.cache_hits += 1+ self.status = ApiHealthStatusType.HEALTHY+ return+ def record_cache_miss(self) -> int:+ self.cache_misses += 1+ self.status = ApiHealthStatusType.HEALTHY+ return++ @property+ def cache_hit_rate(self) -> float:+ cache_attempts = self.cache_hits + self.cache_misses+ if cache_attempts < 1:+ return 0.0+ return ( self.cache_hits / cache_attempts )++ @property+ def cache_hit_rate_percent(self) -> float:+ return self.cache_hit_rate * 100.0++ # This happens alongside record_api_call(), record_cache_hit() and record_cache_miss()@propertydef is_healthy(self) -> bool:"""Check if this API source is healthy."""@@ -77,46 +101,50 @@ class ApiHealthStatus:return 100.0return ((self.total_calls - self.total_failures) / self.total_calls) * 100+ @property+ def status_display(self) -> str:+ return self.status.label+@propertydef status_css_class(self) -> str:- """Get CSS class for status styling."""return {ApiHealthStatusType.HEALTHY: "success",ApiHealthStatusType.DEGRADED: "warning",ApiHealthStatusType.UNKNOWN: "warning",ApiHealthStatusType.FAILING: "error",- ApiHealthStatusType.UNAVAILABLE: "error"+ ApiHealthStatusType.UNAVAILABLE: "error",+ ApiHealthStatusType.DISABLED: "info"}[self.status]@propertydef status_badge_class(self) -> str:- """Get Bootstrap badge class for status."""return {- ApiHealthStatusType.HEALTHY: "badge-success",+ ApiHealthStatusType.UNKNOWN: "monitor-status-unknown",+ ApiHealthStatusType.HEALTHY: "monitor-status-healthy",ApiHealthStatusType.DEGRADED: "monitor-status-warning",- ApiHealthStatusType.UNKNOWN: "monitor-status-warning",ApiHealthStatusType.FAILING: "monitor-status-error",- ApiHealthStatusType.UNAVAILABLE: "monitor-status-error"+ ApiHealthStatusType.UNAVAILABLE: "monitor-status-error",+ ApiHealthStatusType.DISABLED: "monitor-status-info"}[self.status]@propertydef status_icon(self) -> str:- """Get Font Awesome icon for status."""return {ApiHealthStatusType.HEALTHY: "check-circle",ApiHealthStatusType.DEGRADED: "warning",- ApiHealthStatusType.UNKNOWN: "warning",- ApiHealthStatusType.FAILING: "warning",- ApiHealthStatusType.UNAVAILABLE: "warning"+ ApiHealthStatusType.UNKNOWN: "question-circle",+ ApiHealthStatusType.FAILING: "times-circle",+ ApiHealthStatusType.UNAVAILABLE: "exclamation-circle",+ ApiHealthStatusType.DISABLED: "minus-circle"}[self.status]@propertydef border_color_class(self) -> str:- """Get border color class for API source section."""return {ApiHealthStatusType.HEALTHY: "api-source-healthy",ApiHealthStatusType.DEGRADED: "api-source-warning",ApiHealthStatusType.UNKNOWN: "api-source-warning",ApiHealthStatusType.FAILING: "api-source-error",- ApiHealthStatusType.UNAVAILABLE: "api-source-error"+ ApiHealthStatusType.UNAVAILABLE: "api-source-error",+ ApiHealthStatusType.DISABLED: "api-source-info"}[self.status]diff --git a/src/hi/apps/system/api_health_status_provider.py b/src/hi/apps/system/api_health_status_provider.pyindex 72c3a8f4..02c10f1f 100644--- a/src/hi/apps/system/api_health_status_provider.py+++ b/src/hi/apps/system/api_health_status_provider.py@@ -5,7 +5,7 @@ import loggingimport threadingimport time-from .api_health import ApiCallContext, ApiHealthStatus+from .api_health_status import ApiCallContext, ApiHealthStatusfrom .provider_info import ProviderInfofrom .enums import ApiCallStatusType, ApiHealthStatusType@@ -84,4 +84,32 @@ class ApiHealthStatusProvider(ABC):)return+ def record_cache_hit( self ):+ self._ensure_api_health_status_provider_setup()+ with self._api_health_lock:+ self._api_health_status.record_cache_hit()+ return++ def record_cache_miss( self ):+ self._ensure_api_health_status_provider_setup()+ with self._api_health_lock:+ self._api_health_status.record_cache_miss()+ return++ def update_api_health_status( self, status_type : ApiHealthStatusType ) -> None:+ self._ensure_api_health_status_provider_setup()+ with self._api_health_lock:+ self._api_health_status.status = status_type+ return++ def set_healthy( self ) -> None:+ self.update_api_health_status( status_type = ApiHealthStatusType.HEALTHY )+ return++ def set_disabled( self ) -> None:+ self.update_api_health_status( status_type = ApiHealthStatusType.DISABLED )+ return+++diff --git a/src/hi/apps/system/asyncio_health_provider.py b/src/hi/apps/system/asyncio_health_provider.pynew file mode 100644index 00000000..9e130775--- /dev/null+++ b/src/hi/apps/system/asyncio_health_provider.py@@ -0,0 +1,83 @@+"""+Wrapper utility to convert BackgroundTaskMonitor status to HealthStatusProvider.++This provides a bridge between hi.apps.common.asyncio_utils.BackgroundTaskMonitor+and hi.apps.system.health_status.HealthStatus without creating circular dependencies.+"""++import logging++from hi.apps.common.asyncio_utils import BackgroundTaskMonitor+from .enums import HealthStatusType+from .health_status_provider import HealthStatusProvider+from .provider_info import ProviderInfo+++logger = logging.getLogger(__name__)+++class AsyncioHealthStatusProvider( HealthStatusProvider ):++ def __init__(self):+ super().__init__()+ self._initialize_health_status()+ return++ @classmethod+ def get_provider_info(cls) -> ProviderInfo:+ return ProviderInfo(+ provider_id='hi.apps.system.background_tasks',+ provider_name='Background Task Monitor',+ description='System background tasks and async operations'+ )++ def _initialize_health_status(self):+ """Convert BackgroundTaskMonitor status to HealthStatus.+ """+ try:+ async_diagnostics = BackgroundTaskMonitor.get_background_task_status()++ status_type = HealthStatusType.HEALTHY+ error_message = None++ if not async_diagnostics:+ status_type = HealthStatusType.UNKNOWN+ error_message = "Unable to retrieve background task status"+ else:+ main_thread = async_diagnostics.get('main_thread', {})+ if not main_thread.get('is_alive'):+ status_type = HealthStatusType.ERROR+ error_message = "Main thread is not alive"++ if status_type == HealthStatusType.HEALTHY:+ background_tasks = async_diagnostics.get('background_tasks', {})+ dead_tasks = []+ stopped_loops = []++ for task_name, task_info in background_tasks.items():+ thread = task_info.get('thread', {})+ if not thread.get('is_alive'):+ dead_tasks.append(task_name)++ event_loop = task_info.get('event_loop', {})+ if event_loop.get('exists') and not event_loop.get('is_running'):+ stopped_loops.append(task_name)++ if dead_tasks:+ status_type = HealthStatusType.ERROR+ error_message = f"Dead threads: {', '.join(dead_tasks)}"+ elif stopped_loops:+ status_type = HealthStatusType.WARNING+ error_message = f"Stopped event loops: {', '.join(stopped_loops)}"++ self.update_health_status(+ status = status_type,+ error_message = error_message,+ )+ except Exception as e:+ logger.exception("Failed to get background task health status")+ self.update_health_status(+ status = HealthStatusType.ERROR,+ error_message = f"Failed to retrieve status: {str(e)}",+ )+ returndiff --git a/src/hi/apps/system/enums.py b/src/hi/apps/system/enums.pyindex 8d9b0255..dfff1706 100644--- a/src/hi/apps/system/enums.py+++ b/src/hi/apps/system/enums.py@@ -151,6 +151,7 @@ class ApiHealthStatusType(LabeledEnum):DEGRADED = ('Degraded' , 'API responding but performance or occasional issues')FAILING = ('Failing' , 'API experiencing frequent failures or timeouts')UNAVAILABLE = ('Unavailable' , 'API completely unresponsive or returning errors')+ DISABLED = ('Disabled' , 'API source has been manually disabled')@classmethoddef from_metrics(cls,@@ -216,6 +217,8 @@ class ApiHealthStatusType(LabeledEnum):return HealthStatusType.HEALTHYelif self == ApiHealthStatusType.DEGRADED:return HealthStatusType.WARNING+ elif self == ApiHealthStatusType.DISABLED:+ return HealthStatusType.DISABLEDelse: # FAILING or UNAVAILABLEreturn HealthStatusType.ERRORdiff --git a/src/hi/apps/system/health_status.py b/src/hi/apps/system/health_status.pyindex 46a4fff4..4bb917a7 100644--- a/src/hi/apps/system/health_status.py+++ b/src/hi/apps/system/health_status.py@@ -18,6 +18,7 @@ class HealthStatus:heartbeat : Optional[datetime] = Noneerror_message : Optional[str] = Noneerror_count : int = 0+ expected_heartbeat_interval_secs : Optional[int] = None # Expected polling interval for dynamic heartbeat thresholds@propertydef is_healthy(self) -> bool:@@ -42,57 +43,74 @@ class HealthStatus:import hi.apps.common.datetimeproxy as datetimeproxyreturn int((datetimeproxy.now() - self.heartbeat).total_seconds())+ def _get_heartbeat_thresholds(self) -> tuple[int, int]:+ if self.expected_heartbeat_interval_secs:+ # Dynamic thresholds: 1.5x interval for active, 3x for stale+ active_threshold = int(self.expected_heartbeat_interval_secs * 1.5)+ stale_threshold = int(self.expected_heartbeat_interval_secs * 3.0)+ else:+ # Fixed thresholds for backward compatibility+ active_threshold = 30+ stale_threshold = 300 # 5 minutes++ return active_threshold, stale_threshold+@propertydef heartbeat_status_text(self) -> str:- """Get heartbeat status description."""if not self.heartbeat:return "Unknown"age = self.heartbeat_age_secondsif age is None:return "Unknown"- elif age < 30:++ active_threshold, stale_threshold = self._get_heartbeat_thresholds()++ if age < active_threshold:return "Active"- elif age < 300: # 5 minutes+ elif age < stale_threshold:return "Stale"else:return "Dead"@propertydef heartbeat_css_class(self) -> str:- """Get CSS class for heartbeat indicator."""if not self.heartbeat:return "heartbeat-dead"age = self.heartbeat_age_secondsif age is None:return "heartbeat-dead"- elif age < 30:++ active_threshold, stale_threshold = self._get_heartbeat_thresholds()++ if age < active_threshold:return "heartbeat-healthy"- elif age < 300: # 5 minutes+ elif age < stale_threshold:return "heartbeat-stale"else:return "heartbeat-dead"@propertydef heartbeat_text_class(self) -> str:- """Get text color class for heartbeat status."""if not self.heartbeat:return "text-error-custom"age = self.heartbeat_age_secondsif age is None:return "text-error-custom"- elif age < 30:++ active_threshold, stale_threshold = self._get_heartbeat_thresholds()++ if age < active_threshold:return "text-success-custom"- elif age < 300: # 5 minutes+ elif age < stale_threshold:return "text-warning-custom"else:return "text-error-custom"@propertydef status_badge_class(self) -> str:- """Get Bootstrap badge class for overall status."""if self.status.is_healthy:return "monitor-status-healthy"elif self.status.is_warning:@@ -108,7 +126,6 @@ class HealthStatus:@propertydef status_alert_class(self) -> str:- """Get alert class for status summary."""if self.is_healthy:return "alert-success"elif self.status.is_info:@@ -120,7 +137,6 @@ class HealthStatus:@propertydef status_icon(self) -> str:- """Get Font Awesome icon for status."""if self.status.is_healthy:return "check-circle"elif self.status.is_warning:@@ -134,9 +150,23 @@ class HealthStatus:else: # UNKNOWNreturn "question-circle"+ @property+ def border_color_class(self) -> str:+ if self.status.is_healthy:+ return "border-healthy"+ elif self.status.is_warning:+ return "border-warning"+ elif self.status.is_info:+ return "border-info"+ elif self.status.is_critical:+ return "border-error"+ elif self.status.is_error:+ return "bordder-error"+ else: # UNKNOWN+ return "border-unknown"+@propertydef status_summary_message(self) -> str:- """Get appropriate status summary message."""if self.is_healthy:return "Is operating normally and heartbeat is active."elif self.is_critical:diff --git a/src/hi/apps/system/health_status_provider.py b/src/hi/apps/system/health_status_provider.pyindex 4d293ac7..6e8ca579 100644--- a/src/hi/apps/system/health_status_provider.py+++ b/src/hi/apps/system/health_status_provider.py@@ -30,6 +30,7 @@ class HealthStatusProvider(ABC):provider_name = provider_info.provider_name,status = HealthStatusType.UNKNOWN,last_check = datetimeproxy.now(),+ expected_heartbeat_interval_secs = provider_info.expected_heartbeat_interval_secs,)self._health_lock = threading.Lock()returndiff --git a/src/hi/apps/system/provider_info.py b/src/hi/apps/system/provider_info.pyindex 1d73aed2..9009cfee 100644--- a/src/hi/apps/system/provider_info.py+++ b/src/hi/apps/system/provider_info.py@@ -14,6 +14,7 @@ class ProviderInfo:provider_id : str # Technical identifier (e.g., 'hass_api', 'zm_api')provider_name : str # Human-friendly display name (e.g., 'Home Assistant API')description : Optional[str] = None # Optional longer description+ expected_heartbeat_interval_secs : Optional[int] = None # Expected heartbeat interval for dynamic thresholdsdef __str__(self) -> str:return f"{self.provider_name} ({self.provider_id})"diff --git a/src/hi/apps/system/templates/system/modals/aggregate_health_status.html b/src/hi/apps/system/templates/system/modals/aggregate_health_status.htmldeleted file mode 100644index 6675b5a2..00000000--- a/src/hi/apps/system/templates/system/modals/aggregate_health_status.html+++ /dev/null@@ -1,146 +0,0 @@-{% extends "modals/action_done.html" %}-{% load icons %}-{% load tz %}--{% block modal_dialog_class %}hi-modal-dialog-800{% endblock %}--{% block title_text %}-{% icon "shield" size="sm" css_class="mr-2" %}-{{ health_status.provider_name }} Health-{% endblock %}--{% block body %}-{% timezone USER_TIMEZONE %}--<div class="container-fluid px-0">- <!-- Overall Provider Status -->- <div class="row mb-4">- <div class="col-12">- <div class="d-flex align-items-center mb-3">- <span class="badge monitor-status-badge {{ health_status.status_badge_class }} mr-3">- {% icon health_status.status_icon size="sm" css_class="mr-2" %}- {{ health_status.status_display }}- </span>- </div>-- <!-- Provider Heartbeat -->- {% if health_status.heartbeat %}- <div class="row">- <div class="col-sm-3"><strong>Provider Status:</strong></div>- <div class="col-sm-9">- <span class="heartbeat-indicator {{ health_status.heartbeat_css_class }}"></span>- <span class="{{ health_status.heartbeat_text_class }}">{{ health_status.heartbeat_status_text }}</span>- <small class="text-muted-custom">- (last seen {{ health_status.heartbeat|localtime|date:"H:i:s" }})- </small>- </div>- </div>- {% endif %}-- <div class="row mt-2">- <div class="col-sm-3"><strong>Last Check:</strong></div>- <div class="col-sm-9">{{ health_status.last_check|localtime|date:"M j, Y H:i:s" }}</div>- </div>-- {% if health_status.error_message %}- <div class="row mt-2">- <div class="col-sm-3"><strong>Error Details:</strong></div>- <div class="col-sm-9">- <div class="{{ health_status.status_alert_class }} p-2">- {{ health_status.error_message }}- </div>- </div>- </div>- {% endif %}-- {% if health_status.error_count > 1 %}- <div class="row mt-2">- <div class="col-sm-3"><strong>Error Count:</strong></div>- <div class="col-sm-9">{{ health_status.error_count }}</div>- </div>- {% endif %}- </div>- </div>-- {% if health_status.api_status_map %}- <!-- API Sources Section -->- <div class="row">- <div class="col-12">- <h6 class="mb-3">- {% icon "plug" size="sm" css_class="mr-2" %}- API Sources- </h6>-- {% for api_status in health_status.api_status_map.values %}- <div class="api-source-section {{ api_status.border_color_class }} mb-4">- <div class="d-flex justify-content-between align-items-center mb-2">- <h6 class="mb-0">{{ api_status.provider_name }}</h6>- <span class="badge {{ api_status.status_badge_class }}">- {% icon api_status.status_icon size="sm" css_class="mr-1" %}{{ api_status.status.label }}- </span>- </div>-- {% if api_status.last_success %}- <div class="row">- <div class="col-sm-3"><strong>Last Success:</strong></div>- <div class="col-sm-9">{{ api_status.last_success|localtime|date:"H:i:s" }}</div>- </div>- {% endif %}-- <div class="api-metrics-grid mt-2">- <div class="metric-item {{ api_status.status_css_class }}">- <div class="small text-muted-custom">Total Calls</div>- <div class="metric-value">{{ api_status.total_calls|floatformat:0 }}</div>- </div>- <div class="metric-item {{ api_status.status_css_class }}">- <div class="small text-muted-custom">Success Rate</div>- <div class="metric-value">{{ api_status.success_rate_percentage|floatformat:1 }}%</div>- </div>- {% if api_status.last_response_time %}- <div class="metric-item {{ api_status.status_css_class }}">- <div class="small text-muted-custom">Last Response</div>- <div class="metric-value">{{ api_status.last_response_time|floatformat:2 }}s</div>- </div>- {% elif api_status.average_response_time %}- <div class="metric-item {{ api_status.status_css_class }}">- <div class="small text-muted-custom">Avg Response</div>- <div class="metric-value">{{ api_status.average_response_time|floatformat:2 }}s</div>- </div>- {% else %}- <div class="metric-item {{ api_status.status_css_class }}">- <div class="small text-muted-custom">Response Time</div>- <div class="metric-value">timeout</div>- </div>- {% endif %}- {% if api_status.total_failures > 0 or api_status.consecutive_failures > 0 %}- <div class="metric-item {{ api_status.status_css_class }}">- <div class="small text-muted-custom">- {% if api_status.consecutive_failures > 0 %}Consecutive Failures{% else %}Total Failures{% endif %}- </div>- <div class="metric-value">- {% if api_status.consecutive_failures > 0 %}{{ api_status.consecutive_failures }}{% else %}{{ api_status.total_failures }}{% endif %}- </div>- </div>- {% endif %}- </div>- </div>- {% endfor %}- </div>- </div>- {% endif %}-- <!-- Status Summary Alert -->- <div class="row">- <div class="col-12">- <div class="alert {{ health_status.status_alert_class }}">- <p class="mb-0">- {% icon health_status.status_icon size="sm" css_class="mr-2" %}- {{ health_status.status_summary_message }}- </p>- </div>- </div>- </div>-</div>--{% endtimezone %}-{% endblock %}diff --git a/src/hi/apps/system/templates/system/modals/api_health_status.html b/src/hi/apps/system/templates/system/modals/api_health_status.htmlnew file mode 100644index 00000000..fc5fd98d--- /dev/null+++ b/src/hi/apps/system/templates/system/modals/api_health_status.html@@ -0,0 +1,13 @@+{% extends "modals/action_done.html" %}+{% load icons %}++{% block modal_dialog_class %}hi-modal-dialog-800{% endblock %}++{% block title_text %}+{% icon "shield" size="sm" css_class="mr-2" %}+{{ api_health_status.provider_name }} Health+{% endblock %}++{% block body %}+{% include "system/panes/api_health_status_row.html" with api_health_status=api_health_status %}+{% endblock %}diff --git a/src/hi/apps/system/templates/system/modals/background_task_status.html b/src/hi/apps/system/templates/system/modals/background_task_status.htmlnew file mode 100644index 00000000..5f715047--- /dev/null+++ b/src/hi/apps/system/templates/system/modals/background_task_status.html@@ -0,0 +1,13 @@+{% extends "modals/action_done.html" %}+{% load icons %}++{% block modal_dialog_class %}hi-modal-dialog-800{% endblock %}++{% block title_text %}+{% icon "tasks" size="sm" css_class="mr-2" %}+Background Task Details+{% endblock %}++{% block body %}+{% include "system/panes/background_task_details.html" with async_diagnostics=async_diagnostics %}+{% endblock %}\ No newline at end of filediff --git a/src/hi/apps/system/templates/system/modals/health_status.html b/src/hi/apps/system/templates/system/modals/health_status.htmlindex 70a72ec1..c3244893 100644--- a/src/hi/apps/system/templates/system/modals/health_status.html+++ b/src/hi/apps/system/templates/system/modals/health_status.html@@ -1,6 +1,5 @@{% extends "modals/action_done.html" %}{% load icons %}-{% load tz %}{% block modal_dialog_class %}hi-modal-dialog-800{% endblock %}@@ -10,70 +9,5 @@{% endblock %}{% block body %}-{% timezone USER_TIMEZONE %}--<div class="container-fluid px-0">- <!-- Overall Provider Status -->- <div class="row mb-4">- <div class="col-12">- <div class="d-flex align-items-center mb-3">- <span class="badge monitor-status-badge {{ health_status.status_badge_class }} mr-3">- {% icon health_status.status_icon size="sm" css_class="mr-2" %}- {{ health_status.status_display }}- </span>- </div>-- <!-- Provider Heartbeat -->- {% if health_status.heartbeat %}- <div class="row">- <div class="col-sm-3"><strong>Provider Status:</strong></div>- <div class="col-sm-9">- <span class="heartbeat-indicator {{ health_status.heartbeat_css_class }}"></span>- <span class="{{ health_status.heartbeat_text_class }}">{{ health_status.heartbeat_status_text }}</span>- <small class="text-muted-custom">- (last seen {{ health_status.heartbeat|localtime|date:"H:i:s" }})- </small>- </div>- </div>- {% endif %}-- <div class="row mt-2">- <div class="col-sm-3"><strong>Last Check:</strong></div>- <div class="col-sm-9">{{ health_status.last_check|localtime|date:"M j, Y H:i:s" }}</div>- </div>-- {% if health_status.error_message %}- <div class="row mt-2">- <div class="col-sm-3"><strong>Error Details:</strong></div>- <div class="col-sm-9">- <div class="{{ health_status.status_alert_class }} p-2">- {{ health_status.error_message }}- </div>- </div>- </div>- {% endif %}-- {% if health_status.error_count > 1 %}- <div class="row mt-2">- <div class="col-sm-3"><strong>Error Count:</strong></div>- <div class="col-sm-9">{{ health_status.error_count }}</div>- </div>- {% endif %}- </div>- </div>-- <!-- Status Summary Alert -->- <div class="row">- <div class="col-12">- <div class="alert {{ health_status.status_alert_class }}">- <p class="mb-0">- {% icon health_status.status_icon size="sm" css_class="mr-2" %}- {{ health_status.status_summary_message }}- </p>- </div>- </div>- </div>-</div>--{% endtimezone %}+{% include "system/panes/health_status_details.html" %}{% endblock %}diff --git a/src/hi/apps/system/templates/system/panes/api_health_status_details.html b/src/hi/apps/system/templates/system/panes/api_health_status_details.htmlnew file mode 100644index 00000000..6acf8921--- /dev/null+++ b/src/hi/apps/system/templates/system/panes/api_health_status_details.html@@ -0,0 +1,75 @@+{% load icons %}+{% load tz %}+{% timezone USER_TIMEZONE %}++<div class="api-source-section {{ api_health_status.border_color_class }} mb-4">+ <div class="d-flex justify-content-between align-items-center mb-2">+ <h6 class="mb-0">{{ api_health_status.provider_name }}</h6>+ <span class="badge {{ api_health_status.status_badge_class }}">+ {% icon api_health_status.status_icon size="sm" css_class="mr-1" %}{{ api_health_status.status.label }}+ </span>+ </div>++ {% if api_health_status.last_success %}+ <div class="row">+ <div class="col-sm-3"><strong>Last Success:</strong></div>+ <div class="col-sm-9">{{ api_health_status.last_success|localtime|date:"H:i:s" }}</div>+ </div>+ {% endif %}++ <div class="api-metrics-grid mt-2">+ <div class="metric-item {{ api_health_status.status_css_class }}">+ <div class="small text-muted-custom">Total Calls</div>+ <div class="metric-value">{{ api_health_status.total_calls|floatformat:0 }}</div>+ </div>+ <div class="metric-item {{ api_health_status.status_css_class }}">+ <div class="small text-muted-custom">Success Rate</div>+ <div class="metric-value">+ {% if api_health_status.total_calls %}+ {{ api_health_status.success_rate_percentage|floatformat:1 }}%+ {% else %}+ ---+ {% endif %}+ </div>+ </div>+ {% if api_health_status.last_response_time %}+ <div class="metric-item {{ api_health_status.status_css_class }}">+ <div class="small text-muted-custom">Last Response</div>+ <div class="metric-value">{{ api_health_status.last_response_time|floatformat:2 }}s</div>+ </div>+ {% elif api_health_status.average_response_time %}+ <div class="metric-item {{ api_health_status.status_css_class }}">+ <div class="small text-muted-custom">Avg Response</div>+ <div class="metric-value">{{ api_health_status.average_response_time|floatformat:2 }}s</div>+ </div>+ {% else %}+ <div class="metric-item {{ api_health_status.status_css_class }}">+ <div class="small text-muted-custom">Response Time</div>+ <div class="metric-value">---</div>+ </div>+ {% endif %}+ {% if api_health_status.total_failures > 0 or api_health_status.consecutive_failures > 0 %}+ <div class="metric-item {{ api_health_status.status_css_class }}">+ <div class="small text-muted-custom">+ {% if api_health_status.consecutive_failures > 0 %}Consecutive Failures{% else %}Total Failures{% endif %}+ </div>+ <div class="metric-value">+ {% if api_health_status.consecutive_failures > 0 %}{{ api_health_status.consecutive_failures }}{% else %}{{ api_health_status.total_failures }}{% endif %}+ </div>+ </div>+ {% endif %}+ </div>++ <!-- Cache Statistics -->+ {% if api_health_status.cache_hits > 0 or api_health_status.cache_misses > 0 %}+ <div class="cache-stats mt-2">+ <small class="text-muted">+ Cache: {{ api_health_status.cache_hits }} hits, {{ api_health_status.cache_misses }} misses+ {% if api_health_status.cache_hit_rate_percent %}+ ({{ api_health_status.cache_hit_rate_percent|floatformat:1 }}% hit rate)+ {% endif %}+ </small>+ </div>+ {% endif %}+</div>+{% endtimezone %}diff --git a/src/hi/apps/system/templates/system/panes/api_health_status_item.html b/src/hi/apps/system/templates/system/panes/api_health_status_item.htmlnew file mode 100644index 00000000..a9483567--- /dev/null+++ b/src/hi/apps/system/templates/system/panes/api_health_status_item.html@@ -0,0 +1,21 @@+{% load icons %}+{% load tz %}++{% timezone USER_TIMEZONE %}+<div class="api-source-section {{ api_health_status.border_color_class }} mb-4">+ <a href="{% url 'system_api_health_status' provider_id=api_health_status.provider_id %}"+ class="clickable-card"+ data-async="modal">+ <div class="d-flex justify-content-between" >+ <div>+ <strong>{{ api_health_status.provider_name }}</strong>+ </div>+ <div>+ <span class="badge {{ api_health_status.status_badge_class }}">+ {% icon api_health_status.status_icon size="sm" css_class="mr-1" %}{{ api_health_status.status_display }}+ </span>+ </div>+ </div>+ </a>+</div>+{% endtimezone %}diff --git a/src/hi/apps/system/templates/system/panes/background_task_details.html b/src/hi/apps/system/templates/system/panes/background_task_details.htmlnew file mode 100644index 00000000..d5bfcdf0--- /dev/null+++ b/src/hi/apps/system/templates/system/panes/background_task_details.html@@ -0,0 +1,89 @@+{% load icons %}+{% load tz %}++{% timezone USER_TIMEZONE %}+{% if async_diagnostics %}+<div class="background-task-details">+ <div class="row mb-3">+ <div class="col-sm-3"><strong>Main Thread:</strong></div>+ <div class="col-sm-9">{{ async_diagnostics.main_thread.name }}</div>+ </div>++ <div class="row mb-3">+ <div class="col-sm-3"><strong>Active Threads:</strong></div>+ <div class="col-sm-9">{{ async_diagnostics.current_thread.active_count }}</div>+ </div>++ {% if async_diagnostics.background_tasks %}+ <div class="row">+ <div class="col-12">+ <h6 class="mb-3">Background Tasks</h6>+ {% for task_name, task_info in async_diagnostics.background_tasks.items %}+ <div class="mt-3 p-3 border-left border-info">+ <div class="mb-2"><strong>{{ task_name }}</strong></div>++ <div class="row mb-2">+ <div class="col-sm-3"><strong>Thread:</strong></div>+ <div class="col-sm-9">+ {% if task_info.thread.is_alive %}+ <span class="text-success">+ {% icon "check-circle" size="sm" css_class="mr-1" %}{{ task_info.thread_name }}+ </span>+ {% else %}+ <span class="text-danger">+ {% icon "warning" size="sm" css_class="mr-1" %}Dead+ </span>+ {% endif %}+ </div>+ </div>++ <div class="row mb-2">+ <div class="col-sm-3"><strong>Event Loop:</strong></div>+ <div class="col-sm-9">+ {% if task_info.event_loop.exists and task_info.event_loop.is_running %}+ <span class="text-success">+ {% icon "check-circle" size="sm" css_class="mr-1" %}Running ({{ task_info.event_loop.active_tasks }} active tasks)+ </span>+ {% elif task_info.event_loop.exists %}+ <span class="text-warning">+ {% icon "warning" size="sm" css_class="mr-1" %}Stopped+ </span>+ {% else %}+ <span class="text-danger">+ {% icon "warning" size="sm" css_class="mr-1" %}Dead+ </span>+ {% endif %}+ </div>+ </div>++ {% if task_info.event_loop.task_details %}+ <div class="row">+ <div class="col-sm-3"><strong>Tasks:</strong></div>+ <div class="col-sm-9">+ {% for task_detail in task_info.event_loop.task_details %}+ <div class="small mb-1">+ - {{ task_detail.name|default:"unknown" }}+ {% if task_detail.done %}+ <span class="text-muted">(done)</span>+ {% elif task_detail.cancelled %}+ <span class="text-warning">(cancelled)</span>+ {% else %}+ <span class="text-success">(running)</span>+ {% endif %}+ </div>+ {% endfor %}+ </div>+ </div>+ {% endif %}+ </div>+ {% endfor %}+ </div>+ </div>+ {% endif %}+</div>+{% else %}+<div class="alert alert-warning">+ <p class="mb-0">Background task status information is not available.</p>+</div>+{% endif %}+{% endtimezone %}diff --git a/src/hi/apps/system/templates/system/panes/health_status_card.html b/src/hi/apps/system/templates/system/panes/health_status_card.htmlnew file mode 100644index 00000000..393d614c--- /dev/null+++ b/src/hi/apps/system/templates/system/panes/health_status_card.html@@ -0,0 +1,50 @@+{% load icons %}+{% load tz %}++{% timezone USER_TIMEZONE %}+{% with health_status_provider.health_status as health_status %}+<a {% if health_status.provider_id == 'hi.apps.system.background_tasks' %}+ href="{% url 'background_task_details' as modal_url %}"+ {% else %}+ href="{% url 'system_health_status' provider_id=health_status.provider_id %}"+ {% endif %}+ class="clickable-card"+ data-async="modal">+ <div class="card {{ health_status.border_color_class }}">+ <div class="card-body">+ <div class="d-flex justify-content-between align-items-center mb-2">+ <h6 class="mb-0">{{ health_status.provider_name }}</h6>+ <span class="badge monitor-status-badge {{ health_status.status_badge_class }}">+ {% icon health_status.status_icon size="sm" css_class="mr-1" %}{{ health_status.status_display }}+ </span>+ </div>++ <div class="row">+ <div class="col-sm-6">+ <small class="text-muted">Last Check:</small><br>+ <span>{{ health_status.last_check|localtime|date:"H:i:s" }}</span>+ </div>+ <div class="col-sm-6">+ <small class="text-muted">Status:</small><br>+ <span class="heartbeat-indicator {{ health_status.heartbeat_css_class }}"></span>+ <span class="{{ health_status.heartbeat_text_class }}">{{ health_status.heartbeat_status_text }}</span><br>+ <small class="text-muted-custom">+ (last seen {{ health_status.heartbeat|localtime|date:"H:i:s" }})+ {% if health_status.expected_heartbeat_interval_secs %}+ <br>Expected: {{ health_status.expected_heartbeat_interval_secs }}s+ {% endif %}+ </small>+ </div>+ </div>++ <div class="row">+ <div class="col-12">+ <small class="text-muted">{{ health_status_provider.get_provider_info.description }}</small>+ </div>+ </div>++ </div>+ </div>+</a>+{% endwith %}+{% endtimezone %}diff --git a/src/hi/apps/system/templates/system/panes/health_status_details.html b/src/hi/apps/system/templates/system/panes/health_status_details.htmlnew file mode 100644index 00000000..50e37bef--- /dev/null+++ b/src/hi/apps/system/templates/system/panes/health_status_details.html@@ -0,0 +1,87 @@+{% load icons %}+{% load tz %}+{% timezone USER_TIMEZONE %}++<div class="container-fluid px-0">+ <!-- Overall Provider Status -->+ <div class="row mb-4">+ <div class="col-12">+ <div class="d-flex align-items-center mb-3">+ <span class="badge monitor-status-badge {{ health_status.status_badge_class }} mr-3">+ {% icon health_status.status_icon size="sm" css_class="mr-2" %}+ {{ health_status.status_display }}+ </span>+ </div>++ <!-- Provider Heartbeat -->+ {% if health_status.heartbeat %}+ <div class="row">+ <div class="col-sm-3"><strong>Provider Status:</strong></div>+ <div class="col-sm-9">+ <span class="heartbeat-indicator {{ health_status.heartbeat_css_class }}"></span>+ <span class="{{ health_status.heartbeat_text_class }}">{{ health_status.heartbeat_status_text }}</span>+ <small class="text-muted-custom">+ (last seen {{ health_status.heartbeat|localtime|date:"H:i:s" }})+ </small>+ {% if health_status.expected_heartbeat_interval_secs %}+ <br>Expected: {{ health_status.expected_heartbeat_interval_secs }}s+ {% endif %}+ </div>+ </div>+ {% endif %}++ <div class="row mt-2">+ <div class="col-sm-3"><strong>Last Check:</strong></div>+ <div class="col-sm-9">{{ health_status.last_check|localtime|date:"M j, Y H:i:s" }}</div>+ </div>++ {% if health_status.error_message %}+ <div class="row mt-2">+ <div class="col-sm-3"><strong>Error Details:</strong></div>+ <div class="col-sm-9">+ <div class="{{ health_status.status_alert_class }} p-2">+ {{ health_status.error_message }}+ </div>+ </div>+ </div>+ {% endif %}++ {% if health_status.error_count > 1 %}+ <div class="row mt-2">+ <div class="col-sm-3"><strong>Error Count:</strong></div>+ <div class="col-sm-9">{{ health_status.error_count }}</div>+ </div>+ {% endif %}+ </div>+ </div>++ <!-- Status Summary Alert -->+ <div class="row">+ <div class="col-12">+ <div class="alert {{ health_status.status_alert_class }}">+ <p class="mb-0">+ {% icon health_status.status_icon size="sm" css_class="mr-2" %}+ {{ health_status.status_summary_message }}+ </p>+ </div>+ </div>+ </div>++ {% if health_status.api_status_map %}+ <!-- API Sources Section -->+ <div class="row">+ <div class="col-12">+ <h6 class="mb-3">+ {% icon "plug" size="sm" css_class="mr-2" %}+ API Sources+ </h6>++ {% for api_health_status in health_status.api_status_map.values %}+ {% include "system/panes/api_health_status_details.html" with api_health_status=api_health_status %}+ {% endfor %}+ </div>+ </div>+ {% endif %}++</div>+{% endtimezone %}diff --git a/src/hi/apps/system/templates/system/panes/health_status_pane.html b/src/hi/apps/system/templates/system/panes/health_status_pane.htmlnew file mode 100644index 00000000..9582ff23--- /dev/null+++ b/src/hi/apps/system/templates/system/panes/health_status_pane.html@@ -0,0 +1,39 @@+{% load icons %}+{% load tz %}++{% timezone USER_TIMEZONE %}+{% with health_status_provider.health_status as health_status %}+<div class="card {{ health_status.border_color_class }}">+ <div class="card-body">+ <a href="{% url 'system_health_status' provider_id=health_status.provider_id %}"+ class="clickable-card"+ data-async="modal">++ <div class="d-flex justify-content-between align-items-center mb-3">+ <div>+ <h6 class="mb-0">{{ health_status.provider_name }}</h6>++ {% if health_status.api_status_map %}+ <small class="text-muted">{{ health_status.api_status_map|length }} API source{{ health_status.api_status_map|length|pluralize }} configured</small>+ {% endif %}+ </div>+ <div>+ <span class="badge monitor-status-badge {{ health_status.status_badge_class }}">+ {% icon health_status.status_icon size="md" css_class="mr-1" %}{{ health_status.status_display }}+ </span>+ </div>+ </div>+ </a>++ {% if health_status.api_status_map %}+ <div class="api-sources-list">+ {% for api_health_status in health_status.api_status_map.values %}+ <hr />+ {% include "system/panes/api_health_status_item.html" with api_health_status=api_health_status %}+ {% endfor %}+ </div>+ {% endif %}+ </div>+</div>+{% endwith %}+{% endtimezone %}diff --git a/src/hi/apps/system/templates/system/panes/system_info.html b/src/hi/apps/system/templates/system/panes/system_info.htmlindex c8f985ba..83afbe6f 100644--- a/src/hi/apps/system/templates/system/panes/system_info.html+++ b/src/hi/apps/system/templates/system/panes/system_info.html@@ -5,77 +5,70 @@{% block config_content %}{% timezone USER_TIMEZONE %}<div class="container-fluid">- <div class="d-flex justify-content-between my-1">- <div class="h3">System Info</div>- <div>- <a role="button" class="btn btn-primary"- href="#"- data-async="modal" >- {% icon "plus" size="sm" css_class="hi-icon-left" %}PLACEHOLDER- </a>+ <!-- System Health Page Header -->+ <div class="d-flex justify-content-between align-items-center my-3">+ <h3>System Health</h3>+ <a hrf="{% url 'system_info' %}"+ class="btn btn-outline-primary btn-sm" data-async="true">+ {% icon "sync" size="sm" css_class="mr-1" %}Refresh Status+ </a>+ </div>++ <!-- Application Monitors Grid -->+ <div class="row">+ <div class="col-12">+ <h5 class="mb-3">Application Monitors</h5>+ </div>+ </div>++ <div class="row">+ {% for monitor_provider in app_monitor_providers %}+ <div class="col-lg-6 col-md-12 mb-3">+ {% include "system/panes/health_status_card.html" with health_status_provider=monitor_provider %}+ </div>+ {% endfor %}+ </div>++ <!-- Integrations Monitors Grid -->+ <div class="row">+ <div class="col-12">+ <h5 class="mb-3">Integration Monitors</h5></div></div>- <div>- PLACEHOLDER+ <div class="row">+ {% for integration_provider in integration_providers %}+ <div class="col-lg-6 col-md-12 mb-3">+ {% include "system/panes/health_status_card.html" with health_status_provider=integration_provider %}+ </div>+ {% endfor %}+ </div>++ <!-- Weather Sources Section -->+ <div class="row mt-4">+ <div class="col-12">+ <h5 class="mb-3">Weather API Sources</h5>+ </div></div>- {% if async_diagnostics %}- <div class="row mt-2">- <div class="col-sm-3"><strong>Background Tasks:</strong></div>- <div class="col-sm-9">- <div class="small">- <div>Main Thread: {{ async_diagnostics.main_thread.name }}</div>- <div>Active Threads: {{ async_diagnostics.current_thread.active_count }}</div>+ <div class="row">+ <div class="col-12">+ {% include "system/panes/health_status_pane.html" with health_status_provider=weather_provider %}+ </div>+ </div>- {% for task_name, task_info in async_diagnostics.background_tasks.items %}- <div class="mt-1 p-1 border-left border-info">- <div><strong>{{ task_name }}</strong></div>- <div>Thread:- {% if task_info.thread.is_alive %}- <span class="text-success">- {% icon "check-circle" size="sm" css_class="mr-1" %}{{ task_info.thread_name }}- </span>- {% else %}- <span class="text-danger">- {% icon "warning" size="sm" css_class="mr-1" %}Dead- </span>- {% endif %}- </div>- <div>Event Loop:- {% if task_info.event_loop.exists and task_info.event_loop.is_running %}- <span class="text-success">- {% icon "check-circle" size="sm" css_class="mr-1" %}Running ({{ task_info.event_loop.active_tasks }} active tasks)- </span>- {% elif task_info.event_loop.exists %}- <span class="text-warning">- {% icon "warning" size="sm" css_class="mr-1" %}Stopped- </span>- {% else %}- <span class="text-danger">- {% icon "warning" size="sm" css_class="mr-1" %}Dead- </span>- {% endif %}- </div>+ <!-- Background Tasks Section -->+ <div class="row mt-4">+ <div class="col-12">+ <h5 class="mb-3">System Tasks</h5>+ </div>+ </div>- {% if task_info.event_loop.task_details %}- <div class="mt-1">- <small>Tasks:</small>- {% for task_detail in task_info.event_loop.task_details %}- <div class="ml-2 small">- - {{ task_detail.coro_name|default:"unknown" }}- {% if task_detail.done %}(done){% elif task_detail.cancelled %}(cancelled){% else %}(running){% endif %}- </div>- {% endfor %}- </div>- {% endif %}- </div>- {% endfor %}- </div>+ <div class="row">+ <div class="col-12">+ {% include "system/panes/health_status_pane.html" with health_status_provider=background_task_provider %}</div></div>- {% endif %}-</div>{% endtimezone %}{% endblock %}diff --git a/src/hi/apps/system/tests/synthetic_data.py b/src/hi/apps/system/tests/synthetic_data.pyindex b79e90dd..c5ff13e1 100644--- a/src/hi/apps/system/tests/synthetic_data.py+++ b/src/hi/apps/system/tests/synthetic_data.py@@ -2,15 +2,15 @@Synthetic data generation for system health status testing.This module provides a class to generate realistic test data for health status-scenarios, supporting both regular HealthStatus and ApiHealthAggregator objects.+scenarios, supporting both regular HealthStatus and AggregateHealthStatus objects."""from datetime import datetime, timedeltafrom typing import Dictimport hi.apps.common.datetimeproxy as datetimeproxy-from hi.apps.system.api_health import ApiHealthStatus-from hi.apps.system.api_health_aggregator import ApiHealthAggregator+from hi.apps.system.aggregate_health_status import AggregateHealthStatus+from hi.apps.system.api_health_status import ApiHealthStatusfrom hi.apps.system.provider_info import ProviderInfofrom hi.apps.system.enums import (HealthStatusType,@@ -24,7 +24,7 @@ class SystemSyntheticData:"""Generator for synthetic system health status data for testing purposes.- Provides methods to create realistic HealthStatus and ApiHealthAggregator+ Provides methods to create realistic HealthStatus and AggregateHealthStatusobjects with appropriate test data for all status types."""@@ -35,10 +35,10 @@ class SystemSyntheticData:Args:status_type: One of 'unknown', 'healthy', 'warning', 'error', 'disabled'- with_api_data: Whether to create ApiHealthAggregator (True) or HealthStatus (False)+ with_api_data: Whether to create AggregateHealthStatus (True) or HealthStatus (False)Returns:- HealthStatus or ApiHealthAggregator instance with appropriate test data+ HealthStatus or AggregateHealthStatus instance with appropriate test data"""now = datetimeproxy.now()@@ -90,13 +90,13 @@ class SystemSyntheticData:})if with_api_data:- # Create ApiHealthAggregator with sample API sources+ # Create AggregateHealthStatus with sample API sourcesapi_status_map = cls._create_sample_api_status_map(status_type, now)aggregation_rule = cls._get_aggregation_rule_for_status(status_type)- return ApiHealthAggregator(- api_status_map=api_status_map,- aggregation_rule=aggregation_rule,+ return AggregateHealthStatus(+ api_status_map = api_status_map,+ aggregation_rule = aggregation_rule,**base_data)else:diff --git a/src/hi/apps/system/tests/test_aggregate_health_status.py b/src/hi/apps/system/tests/test_aggregate_health_status.pynew file mode 100644index 00000000..95a7acc4--- /dev/null+++ b/src/hi/apps/system/tests/test_aggregate_health_status.py@@ -0,0 +1,256 @@+"""+Unit tests for AggregateHealthStatus aggregation logic.+"""+import unittest+from unittest.mock import MagicMock++from hi.apps.system.aggregate_health_status import AggregateHealthStatus+from hi.apps.system.api_health_status import ApiHealthStatus+from hi.apps.system.provider_info import ProviderInfo+from hi.apps.system.enums import (+ HealthStatusType,+ ApiHealthStatusType,+ HealthAggregationRule+)+++class TestAggregateHealthStatus(unittest.TestCase):+ """Test cases for AggregateHealthStatus aggregation logic."""++ def setUp(self):+ """Set up test fixtures."""+ self.base_status = AggregateHealthStatus(+ provider_id="test_provider",+ provider_name="Test Provider",+ status=HealthStatusType.HEALTHY,+ last_check=MagicMock(),+ aggregation_rule=HealthAggregationRule.ALL_SOURCES_HEALTHY+ )++ def _create_api_status(self, name: str, status: ApiHealthStatusType) -> tuple[ProviderInfo, ApiHealthStatus]:+ """Helper to create API status for testing."""+ provider_info = ProviderInfo(+ provider_id=f"api_{name}",+ provider_name=f"API {name}",+ description=f"Test API {name}"+ )+ api_status = ApiHealthStatus(+ provider_id=f"api_{name}",+ provider_name=f"API {name}",+ status=status,+ total_calls=10,+ total_failures=0+ )+ return provider_info, api_status++ def test_no_api_sources_returns_base_status(self):+ """Test that with no API sources, base status is returned."""+ result = self.base_status.aggregate_health()+ self.assertEqual(result, HealthStatusType.HEALTHY)++ def test_all_sources_healthy_rule(self):+ """Test ALL_SOURCES_HEALTHY aggregation rule."""+ self.base_status.aggregation_rule = HealthAggregationRule.ALL_SOURCES_HEALTHY++ # Test: All healthy → HEALTHY+ self.base_status.api_status_map.clear()+ for i, status in enumerate([ApiHealthStatusType.HEALTHY, ApiHealthStatusType.HEALTHY, ApiHealthStatusType.HEALTHY]):+ info, api_status = self._create_api_status(f"source{i}", status)+ self.base_status.api_status_map[info] = api_status++ result = self.base_status.aggregate_health()+ self.assertEqual(result, HealthStatusType.HEALTHY)++ # Test: 3 healthy + 1 disabled → HEALTHY (disabled should be excluded)+ self.base_status.api_status_map.clear()+ statuses = [ApiHealthStatusType.HEALTHY, ApiHealthStatusType.HEALTHY, ApiHealthStatusType.HEALTHY, ApiHealthStatusType.DISABLED]+ for i, status in enumerate(statuses):+ info, api_status = self._create_api_status(f"source{i}", status)+ self.base_status.api_status_map[info] = api_status++ result = self.base_status.aggregate_health()+ self.assertEqual(result, HealthStatusType.HEALTHY, "3 healthy + 1 disabled should be HEALTHY")++ # Test: Has failing → ERROR+ self.base_status.api_status_map.clear()+ statuses = [ApiHealthStatusType.HEALTHY, ApiHealthStatusType.FAILING]+ for i, status in enumerate(statuses):+ info, api_status = self._create_api_status(f"source{i}", status)+ self.base_status.api_status_map[info] = api_status++ result = self.base_status.aggregate_health()+ self.assertEqual(result, HealthStatusType.ERROR)++ # Test: Has unavailable → ERROR+ self.base_status.api_status_map.clear()+ statuses = [ApiHealthStatusType.HEALTHY, ApiHealthStatusType.UNAVAILABLE]+ for i, status in enumerate(statuses):+ info, api_status = self._create_api_status(f"source{i}", status)+ self.base_status.api_status_map[info] = api_status++ result = self.base_status.aggregate_health()+ self.assertEqual(result, HealthStatusType.ERROR)++ # Test: Has degraded → WARNING+ self.base_status.api_status_map.clear()+ statuses = [ApiHealthStatusType.HEALTHY, ApiHealthStatusType.DEGRADED]+ for i, status in enumerate(statuses):+ info, api_status = self._create_api_status(f"source{i}", status)+ self.base_status.api_status_map[info] = api_status++ result = self.base_status.aggregate_health()+ self.assertEqual(result, HealthStatusType.WARNING)++ # Test: Has unknown → WARNING+ self.base_status.api_status_map.clear()+ statuses = [ApiHealthStatusType.HEALTHY, ApiHealthStatusType.UNKNOWN]+ for i, status in enumerate(statuses):+ info, api_status = self._create_api_status(f"source{i}", status)+ self.base_status.api_status_map[info] = api_status++ result = self.base_status.aggregate_health()+ self.assertEqual(result, HealthStatusType.WARNING)++ def test_majority_sources_healthy_rule(self):+ """Test MAJORITY_SOURCES_HEALTHY aggregation rule."""+ self.base_status.aggregation_rule = HealthAggregationRule.MAJORITY_SOURCES_HEALTHY++ # Test: 3 healthy out of 4 → HEALTHY+ self.base_status.api_status_map.clear()+ statuses = [ApiHealthStatusType.HEALTHY, ApiHealthStatusType.HEALTHY, ApiHealthStatusType.HEALTHY, ApiHealthStatusType.DEGRADED]+ for i, status in enumerate(statuses):+ info, api_status = self._create_api_status(f"source{i}", status)+ self.base_status.api_status_map[info] = api_status++ result = self.base_status.aggregate_health()+ self.assertEqual(result, HealthStatusType.HEALTHY)++ # Test: 2 healthy out of 4 → WARNING (not majority)+ self.base_status.api_status_map.clear()+ statuses = [ApiHealthStatusType.HEALTHY, ApiHealthStatusType.HEALTHY, ApiHealthStatusType.DEGRADED, ApiHealthStatusType.DEGRADED]+ for i, status in enumerate(statuses):+ info, api_status = self._create_api_status(f"source{i}", status)+ self.base_status.api_status_map[info] = api_status++ result = self.base_status.aggregate_health()+ self.assertEqual(result, HealthStatusType.WARNING)++ # Test: 2 healthy + 1 disabled out of 3 total → HEALTHY (disabled excluded, 2 > 1)+ self.base_status.api_status_map.clear()+ statuses = [ApiHealthStatusType.HEALTHY, ApiHealthStatusType.HEALTHY, ApiHealthStatusType.DISABLED]+ for i, status in enumerate(statuses):+ info, api_status = self._create_api_status(f"source{i}", status)+ self.base_status.api_status_map[info] = api_status++ result = self.base_status.aggregate_health()+ self.assertEqual(result, HealthStatusType.HEALTHY, "2 healthy + 1 disabled should be HEALTHY")++ def test_any_source_healthy_rule(self):+ """Test ANY_SOURCE_HEALTHY aggregation rule."""+ self.base_status.aggregation_rule = HealthAggregationRule.ANY_SOURCE_HEALTHY++ # Test: 1 healthy + 3 degraded → HEALTHY+ self.base_status.api_status_map.clear()+ statuses = [ApiHealthStatusType.HEALTHY, ApiHealthStatusType.DEGRADED, ApiHealthStatusType.DEGRADED, ApiHealthStatusType.DEGRADED]+ for i, status in enumerate(statuses):+ info, api_status = self._create_api_status(f"source{i}", status)+ self.base_status.api_status_map[info] = api_status++ result = self.base_status.aggregate_health()+ self.assertEqual(result, HealthStatusType.HEALTHY)++ # Test: 1 healthy + 1 disabled → HEALTHY+ self.base_status.api_status_map.clear()+ statuses = [ApiHealthStatusType.HEALTHY, ApiHealthStatusType.DISABLED]+ for i, status in enumerate(statuses):+ info, api_status = self._create_api_status(f"source{i}", status)+ self.base_status.api_status_map[info] = api_status++ result = self.base_status.aggregate_health()+ self.assertEqual(result, HealthStatusType.HEALTHY, "1 healthy + 1 disabled should be HEALTHY")++ # Test: Only degraded (no healthy) → WARNING+ self.base_status.api_status_map.clear()+ statuses = [ApiHealthStatusType.DEGRADED, ApiHealthStatusType.DEGRADED]+ for i, status in enumerate(statuses):+ info, api_status = self._create_api_status(f"source{i}", status)+ self.base_status.api_status_map[info] = api_status++ result = self.base_status.aggregate_health()+ self.assertEqual(result, HealthStatusType.WARNING)++ def test_all_sources_disabled(self):+ """Test that when all sources are disabled, base status is used."""+ self.base_status.api_status_map.clear()+ statuses = [ApiHealthStatusType.DISABLED, ApiHealthStatusType.DISABLED]+ for i, status in enumerate(statuses):+ info, api_status = self._create_api_status(f"source{i}", status)+ self.base_status.api_status_map[info] = api_status++ # Should return base status since all API sources are disabled+ result = self.base_status.aggregate_health()+ self.assertEqual(result, HealthStatusType.HEALTHY)++ def test_base_status_and_api_aggregation_combine(self):+ """Test that base status and API aggregation combine correctly using worst status."""+ # Set base status to WARNING+ self.base_status.status = HealthStatusType.WARNING++ # Add all healthy API sources+ self.base_status.api_status_map.clear()+ for i in range(3):+ info, api_status = self._create_api_status(f"source{i}", ApiHealthStatusType.HEALTHY)+ self.base_status.api_status_map[info] = api_status++ # Even though all APIs are healthy, overall should be WARNING due to base status+ result = self.base_status.status+ self.assertEqual(result, HealthStatusType.WARNING, "Base WARNING should override API HEALTHY")++ # Now set base status to ERROR+ self.base_status.status = HealthStatusType.ERROR+ result = self.base_status.status+ self.assertEqual(result, HealthStatusType.ERROR, "Base ERROR should be worst status")++ # Set base status to HEALTHY with one API FAILING+ self.base_status.status = HealthStatusType.HEALTHY+ self.base_status.api_status_map.clear()+ info1, api_status1 = self._create_api_status("source1", ApiHealthStatusType.HEALTHY)+ info2, api_status2 = self._create_api_status("source2", ApiHealthStatusType.FAILING)+ self.base_status.api_status_map[info1] = api_status1+ self.base_status.api_status_map[info2] = api_status2++ result = self.base_status.status+ self.assertEqual(result, HealthStatusType.ERROR, "API FAILING should override base HEALTHY")++ def test_disabled_sources_excluded(self):+ """Test comprehensive scenarios where DISABLED sources are properly excluded."""+ test_cases = [+ # (statuses, rule, expected, description)+ ([ApiHealthStatusType.HEALTHY, ApiHealthStatusType.DISABLED],+ HealthAggregationRule.ALL_SOURCES_HEALTHY, HealthStatusType.HEALTHY,+ "1 healthy + 1 disabled with ALL_SOURCES_HEALTHY"),++ ([ApiHealthStatusType.DEGRADED, ApiHealthStatusType.DISABLED],+ HealthAggregationRule.ALL_SOURCES_HEALTHY, HealthStatusType.WARNING,+ "1 degraded + 1 disabled with ALL_SOURCES_HEALTHY"),++ ([ApiHealthStatusType.FAILING, ApiHealthStatusType.DISABLED],+ HealthAggregationRule.ALL_SOURCES_HEALTHY, HealthStatusType.ERROR,+ "1 failing + 1 disabled with ALL_SOURCES_HEALTHY"),+ ]++ for statuses, rule, expected, description in test_cases:+ with self.subTest(description=description):+ self.base_status.aggregation_rule = rule+ self.base_status.api_status_map.clear()++ for i, status in enumerate(statuses):+ info, api_status = self._create_api_status(f"source{i}", status)+ self.base_status.api_status_map[info] = api_status++ result = self.base_status.aggregate_health()+ self.assertEqual(result, expected, f"Failed for: {description}")+++if __name__ == '__main__':+ unittest.main()\ No newline at end of filediff --git a/src/hi/apps/system/tests/ui/views.py b/src/hi/apps/system/tests/ui/views.pyindex d703a661..1dbd33e9 100644--- a/src/hi/apps/system/tests/ui/views.py+++ b/src/hi/apps/system/tests/ui/views.py@@ -18,7 +18,7 @@ class SystemTestUiHomeView(View):class SystemTestUiHealthStatusView(View):"""View for testing health status modals with various synthetic data scenarios.- Supports all HealthStatusType values with both regular HealthStatus and ApiHealthAggregator data.+ Supports all HealthStatusType values with both regular HealthStatus and AggregateHealthStatus data.URL patterns:- /test/health-status/<status_type>/<api_flag>/@@ -49,13 +49,8 @@ class SystemTestUiHealthStatusView(View):status_type,with_api_data = with_api_data,)- if with_api_data:- template_name = 'system/modals/aggregate_health_status.html'- else:- template_name = 'system/modals/health_status.html'-# Render template with scenario data (matching existing modal template expectations)context = {'health_status': health_status,}- return render(request, template_name, context)+ return render(request, 'system/modals/health_status.html', context)diff --git a/src/hi/apps/system/urls.py b/src/hi/apps/system/urls.pyindex ec9cc938..65f24e41 100644--- a/src/hi/apps/system/urls.py+++ b/src/hi/apps/system/urls.py@@ -9,7 +9,15 @@ urlpatterns = [views.SystemInfoView.as_view(),name = 'system_info' ),- re_path( r'^health/<str:provider_id>$',+ re_path( r'^health/(?P<provider_id>[\w\.\-]+)$',views.SystemHealthStatusView.as_view(),name = 'system_health_status' ),++ re_path( r'^api-health/(?P<provider_id>[\w\.\-]+)$',+ views.SystemApiHealthStatusView.as_view(),+ name = 'system_api_health_status' ),++ re_path( r'^background-tasks/details$',+ views.BackgroundTaskDetailsView.as_view(),+ name = 'background_task_details' ),]diff --git a/src/hi/apps/system/views.py b/src/hi/apps/system/views.pyindex 58ba07b1..deffe319 100644--- a/src/hi/apps/system/views.py+++ b/src/hi/apps/system/views.py@@ -7,6 +7,12 @@ from hi.hi_async_view import HiModalViewfrom hi.apps.common.asyncio_utils import BackgroundTaskMonitorfrom hi.apps.config.enums import ConfigPageTypefrom hi.apps.config.views import ConfigPageView+from hi.apps.monitor.monitor_manager import AppMonitorManager+from hi.apps.weather.weather_source_manager import WeatherSourceManager++from hi.integrations.integration_manager import IntegrationManager++from .asyncio_health_provider import AsyncioHealthStatusProviderlogger = logging.getLogger(__name__)@@ -21,8 +27,19 @@ class SystemInfoView( ConfigPageView ):return 'system/panes/system_info.html'def get_main_template_context( self, request, *args, **kwargs ):+ app_monitor_providers = sorted(+ AppMonitorManager().get_health_status_providers(),+ key = lambda m: m.get_provider_info().provider_name+ )+ integration_providers = sorted(+ IntegrationManager().get_health_status_providers(),+ key = lambda m: m.get_provider_info().provider_name+ )return {- 'async_diagnostics': BackgroundTaskMonitor.get_background_task_status(),+ 'app_monitor_providers': app_monitor_providers,+ 'integration_providers': integration_providers,+ 'weather_provider': WeatherSourceManager(),+ 'background_task_provider': AsyncioHealthStatusProvider(),}@@ -30,11 +47,117 @@ class SystemHealthStatusView(HiModalView):"""View for displaying monitor health status in a modal."""def get_template_name(self) -> str:- return 'system/modals/system_health_status.html'+ return 'system/modals/health_status.html'def get(self, request, *args, **kwargs):provider_id = kwargs.get('provider_id')if not provider_id:raise Http404("Provider ID is required")- raise NotImplementedError("Health status integration not yet implemented")+ # Handle background task health status+ if provider_id == 'hi.apps.system.background_tasks':+ return BackgroundTaskDetailsView().get(request, *args, **kwargs)++ if provider_id == 'hi.apps.weather.weather_sources':+ return WeatherHealthStatusDetailsView().get( request, *args, **kwargs )++ if provider_id.startswith( 'hi.services' ):+ return self.get_integration_status_response(+ request = request,+ provider_id = provider_id,+ )++ if provider_id.startswith( 'hi.apps' ):+ return self.get_app_monitor_status_response(+ request = request,+ provider_id = provider_id,+ )++ raise Http404( f'Unrecognized provider id "{provider_id}"')++ def get_integration_status_response( self, request, provider_id : str ):+ integration_manager = IntegrationManager()+ providers = integration_manager.get_health_status_providers()++ # Find the monitor with matching provider_id+ target_integration = None+ for provider in providers:+ if provider.get_provider_info().provider_id == provider_id:+ target_integration = provider+ break++ if not target_integration:+ raise Http404(f"Integration with provider_id '{provider_id}' not found")++ context = {+ 'health_status': target_integration.health_status,+ }+ return self.modal_response(request, context)++ def get_app_monitor_status_response( self, request, provider_id : str ):+ app_monitor_manager = AppMonitorManager()+ monitors = app_monitor_manager.get_health_status_providers()++ # Find the monitor with matching provider_id+ target_monitor = None+ for monitor in monitors:+ if monitor.get_provider_info().provider_id == provider_id:+ target_monitor = monitor+ break++ if not target_monitor:+ raise Http404(f"Monitor with provider_id '{provider_id}' not found")++ context = {+ 'health_status': target_monitor.health_status,+ }+ return self.modal_response(request, context)+++class SystemApiHealthStatusView(HiModalView):++ def get_template_name(self) -> str:+ return 'system/modals/api_health_status.html'++ def get(self, request, *args, **kwargs):+ provider_id = kwargs.get('provider_id')+ if not provider_id:+ raise Http404("Provider ID is required")++ if provider_id.startswith( 'hi.apps.weather.weather_sources' ):+ return WeatherHealthStatusDetailsView().get( request, *args, **kwargs )+ else:+ raise NotImplementedError(f'Api health status for "{provider_id}" not implemented.')++ api_health_status = None+ context = {+ 'api_health_status': api_health_status+ }+ return self.modal_response(request, context)+++class WeatherHealthStatusDetailsView(HiModalView):+ """View for displaying detailed background task information in a modal."""++ def get_template_name(self) -> str:+ return 'system/modals/health_status.html'++ def get(self, request, *args, **kwargs):+ context = {+ 'health_status': WeatherSourceManager().health_status,+ }+ return self.modal_response(request, context)+++class BackgroundTaskDetailsView(HiModalView):+ """View for displaying detailed background task information in a modal."""++ def get_template_name(self) -> str:+ return 'system/modals/background_task_status.html'++ def get(self, request, *args, **kwargs):+ async_diagnostics = BackgroundTaskMonitor.get_background_task_status()+ context = {+ 'async_diagnostics': async_diagnostics,+ }+ return self.modal_response(request, context)diff --git a/src/hi/apps/weather/daily_weather_tracker.py b/src/hi/apps/weather/daily_weather_tracker.pyindex 5a086902..bf705fe5 100644--- a/src/hi/apps/weather/daily_weather_tracker.py+++ b/src/hi/apps/weather/daily_weather_tracker.py@@ -58,6 +58,8 @@ class DailyWeatherTracker(Singleton):# Field namesFIELD_TEMPERATURE = 'temperature'++ TRACE = False # For debuggingdef __init_singleton__(self):self._fallback_source = DataPointSource(@@ -119,7 +121,8 @@ class DailyWeatherTracker(Singleton):"""try:field_stats = self._get_field_stats_today(location_key, self.FIELD_TEMPERATURE)- logger.debug( f'GET field stats [today] = {field_stats}' )+ if self.TRACE:+ logger.debug( f'GET field stats [today] = {field_stats}' )min_data = field_stats.get(self.STAT_MIN)max_data = field_stats.get(self.STAT_MAX)@@ -146,9 +149,11 @@ class DailyWeatherTracker(Singleton):source_datetime=datetime.fromisoformat(max_data['timestamp']),quantity_ave=UnitQuantity(max_data['value'], max_data['units']))-- logger.debug(f"Retrieved today's temperature min/max for location {location_key}:"- f" {min_data['value']:.1f}°C / {max_data['value']:.1f}°C")++ if self.TRACE:+ logger.debug(+ f"Retrieved today's temperature min/max for location {location_key}:"+ f" {min_data['value']:.1f}°C / {max_data['value']:.1f}°C")return min_datapoint, max_datapoint@@ -255,7 +260,8 @@ class DailyWeatherTracker(Singleton):cache_key = self._get_cache_key(location_key, date_key, field_name)stats_json = cache.get(cache_key)- logger.debug( f'Retrieve field stats [key={cache_key}] - {stats_json}' )+ if self.TRACE:+ logger.debug( f'Retrieve field stats [key={cache_key}] - {stats_json}' )if stats_json:try:diff --git a/src/hi/apps/weather/monitors.py b/src/hi/apps/weather/monitors.pyindex 65c9027f..c9db2197 100644--- a/src/hi/apps/weather/monitors.py+++ b/src/hi/apps/weather/monitors.py@@ -32,28 +32,32 @@ class WeatherMonitor( PeriodicMonitor, AlertMixin, SettingsMixin ):async def initialize(self) -> None:discovered_sources = WeatherSourceDiscovery.discover_weather_data_source_instances()-- # Log discovered sources and their enabled status- for source in discovered_sources:- enabled_status = "enabled" \- if await self._settings_helper.is_weather_source_enabled_async(source.id) else "disabled"- logger.info( f'Discovered weather source:'- f' {source.label} ({source.id}, priority {source.priority}) - {enabled_status}' )- continue-self._weather_data_source_instance_list = discovered_sources- WeatherSourceManager().add_api_health_status_provider_multi(++ weather_source_manager = WeatherSourceManager()+ weather_source_manager.add_api_health_status_provider_multi(api_health_status_provider_sequence = discovered_sources,)++ # During startup safety/warmup, consider everything healthy.+ for weather_data_source in self._weather_data_source_instance_list:+ is_enabled = await self._settings_helper.is_weather_source_enabled_async(+ weather_data_source.id+ )+ if is_enabled:+ weather_data_source.set_healthy()+ else:+ weather_data_source.set_disabled()+ continuereturn@classmethoddef get_provider_info(cls) -> ProviderInfo:- """ Subclasses should override with something more meaningful. """return ProviderInfo(provider_id = 'hi.apps.weather',provider_name = 'Weather Monitor',- description = '',+ description = 'Weather data collection and monitoring',+ expected_heartbeat_interval_secs = cls.WEATHER_POLLING_INTERVAL_SECS,)async def do_work(self):@@ -76,6 +80,7 @@ class WeatherMonitor( PeriodicMonitor, AlertMixin, SettingsMixin ):task = asyncio.create_task( weather_data_source.fetch() )task_list.append( task )else:+ weather_data_source.set_disabled()logger.debug( f'Weather source {weather_data_source.id} is disabled, skipping' )continuediff --git a/src/hi/apps/weather/urls.py b/src/hi/apps/weather/urls.pyindex 03b8c1c1..a9425068 100644--- a/src/hi/apps/weather/urls.py+++ b/src/hi/apps/weather/urls.py@@ -17,7 +17,7 @@ urlpatterns = [views.ForecastView.as_view(),name='weather_forecast'),- re_path( r'^history$',- views.HistoryView.as_view(),+ re_path( r'^history$',+ views.HistoryView.as_view(),name='weather_history'),]diff --git a/src/hi/apps/weather/views.py b/src/hi/apps/weather/views.pyindex beb0ef41..e5c42724 100644--- a/src/hi/apps/weather/views.py+++ b/src/hi/apps/weather/views.py@@ -2,7 +2,6 @@ import loggingfrom hi.hi_async_view import HiModalViewfrom .weather_mixins import WeatherMixin-from .weather_source_manager import WeatherSourceManagerfrom .weather_sources.sunrise_sunset_org import SunriseSunsetOrgfrom .weather_sources.usno import USNO@@ -80,16 +79,3 @@ class HistoryView( HiModalView, WeatherMixin ):'interval_daily_history_list': daily_history.data_list,}return self.modal_response( request, context )---class WeatherSourceStatusView( HiModalView ):-- def get_template_name( self ) -> str:- return 'system/modals/aggregate_health_status.html'-- def get( self, request, *args, **kwargs ):- health_status = WeatherSourceManager().health_status- context = {- 'health_status': health_status,- }- return self.modal_response( request, context )diff --git a/src/hi/apps/weather/weather_data_source.py b/src/hi/apps/weather/weather_data_source.pyindex 13f7ef03..23ce2461 100644--- a/src/hi/apps/weather/weather_data_source.py+++ b/src/hi/apps/weather/weather_data_source.py@@ -142,7 +142,7 @@ class WeatherDataSource( ApiHealthStatusProvider ):def get_api_provider_info(cls) -> ProviderInfo:""" Subclasses should override with something more meaningful. """return ProviderInfo(- provider_id = cls.weather_source_id(),+ provider_id = f'hi.apps.weather.weather_sources.{cls.weather_source_id()}',provider_name = cls.weather_source_label(),description = f'{cls.weather_source_label()} ({cls.weather_source_abbreviation})',)diff --git a/src/hi/apps/weather/weather_settings_helper.py b/src/hi/apps/weather/weather_settings_helper.pyindex c453c5d1..f4e3b413 100644--- a/src/hi/apps/weather/weather_settings_helper.py+++ b/src/hi/apps/weather/weather_settings_helper.py@@ -34,17 +34,13 @@ class WeatherSettingsHelper( SettingsMixin ):return self._get_weather_source_enabled_value(source_id, self.settings_manager())async def is_weather_source_enabled_async(self, source_id: str) -> bool:- """Check if a specific weather source is enabled (async version)."""settings_manager = await self.settings_manager_async()if not settings_manager:return Falsereturn self._get_weather_source_enabled_value(source_id, settings_manager)def get_weather_source_api_key(self, source_id: str) -> str:- """Get the API key for a specific weather source."""- # Dynamically find the API key setting for this sourceapi_key_setting_name = f"{source_id.upper()}_API_KEY"-try:setting_enum = getattr(WeatherSetting, api_key_setting_name)except AttributeError:diff --git a/src/hi/apps/weather/weather_source_manager.py b/src/hi/apps/weather/weather_source_manager.pyindex 0ad50a08..9247bc97 100644--- a/src/hi/apps/weather/weather_source_manager.py+++ b/src/hi/apps/weather/weather_source_manager.py@@ -10,10 +10,8 @@ class WeatherSourceManager( Singleton, AggregateHealthProvider ):@classmethoddef get_provider_info(cls) -> ProviderInfo:- """ Subclasses should override with something more meaningful. """return ProviderInfo(provider_id = 'hi.apps.weather.weather_sources',provider_name = 'Weather API Monitor',description = '',)-diff --git a/src/hi/apps/weather/weather_sources/nws.py b/src/hi/apps/weather/weather_sources/nws.pyindex baf6f82d..6279fa9c 100644--- a/src/hi/apps/weather/weather_sources/nws.py+++ b/src/hi/apps/weather/weather_sources/nws.py@@ -44,8 +44,9 @@ logger = logging.getLogger(__name__)class NationalWeatherService( WeatherDataSource, WeatherMixin ):+ SOURCE_ID = 'nws'BASE_URL = "https://api.weather.gov/"-+POINTS_DATA_CACHE_EXPIRY_SECS = 12 * 60 * 60 # Data can change, but not oftenSTATIONS_DATA_CACHE_EXPIRY_SECS = 12 * 60 * 60 # Data can change, but not oftenOBSERVATIONS_DATA_CACHE_EXPIRY_SECS = 5 * 60 # Cache for rate-limit risk reduction@@ -56,7 +57,7 @@ class NationalWeatherService( WeatherDataSource, WeatherMixin ):@classmethoddef weather_source_id(cls):- return 'nws'+ return cls.SOURCE_ID@classmethoddef weather_source_label(cls):@@ -497,9 +498,11 @@ class NationalWeatherService( WeatherDataSource, WeatherMixin ):if observations_data_str:logger.debug( 'NWS observations data from cache.' )+ self.record_cache_hit()observations_data = json.loads( observations_data_str )return observations_data+ self.record_cache_miss()observations_data = self._get_observations_data_from_api( station = station )if observations_data:observations_data_str = json.dumps( observations_data )@@ -529,9 +532,11 @@ class NationalWeatherService( WeatherDataSource, WeatherMixin ):if forecast_hourly_data_str:logger.debug( 'NWS hourly forecast data from cache.' )+ self.record_cache_hit()forecast_hourly_data = json.loads( forecast_hourly_data_str )return forecast_hourly_data+ self.record_cache_miss()forecast_hourly_data = self._get_forecast_hourly_data_from_api( station = station )if forecast_hourly_data:forecast_hourly_data_str = json.dumps( forecast_hourly_data )@@ -560,9 +565,11 @@ class NationalWeatherService( WeatherDataSource, WeatherMixin ):if forecast_12h_data_str:logger.debug( 'NWS 12h forecast data from cache.' )+ self.record_cache_hit()forecast_12h_data = json.loads( forecast_12h_data_str )return forecast_12h_data+ self.record_cache_miss()forecast_12h_data = self._get_forecast_12h_data_from_api( station = station )if forecast_12h_data:forecast_12h_data_str = json.dumps( forecast_12h_data )@@ -598,9 +605,11 @@ class NationalWeatherService( WeatherDataSource, WeatherMixin ):if stations_data_str:logger.debug( 'NWS stations data from cache.' )+ self.record_cache_hit()stations_data = json.loads( stations_data_str )return stations_data-++ self.record_cache_miss()stations_data = self._get_stations_data_from_api( geographic_location = geographic_location )if stations_data:stations_data_str = json.dumps( stations_data )@@ -633,8 +642,11 @@ class NationalWeatherService( WeatherDataSource, WeatherMixin ):if points_data_str:logger.debug( 'NWS points data from cache.' )+ self.record_cache_hit()points_data = json.loads( points_data_str )return points_data++ self.record_cache_miss()points_data = self._get_points_data_from_api( geographic_location = geographic_location )if points_data:points_data_str = json.dumps( points_data )@@ -1052,9 +1064,11 @@ class NationalWeatherService( WeatherDataSource, WeatherMixin ):if alerts_data_str:logger.debug('NWS alerts data from cache.')+ self.record_cache_hit()alerts_data = json.loads(alerts_data_str)return alerts_data+ self.record_cache_miss()alerts_data = self._get_alerts_data_from_api(geographic_location = geographic_location,)diff --git a/src/hi/apps/weather/weather_sources/openmeteo.py b/src/hi/apps/weather/weather_sources/openmeteo.pyindex 13e0e462..621f680a 100644--- a/src/hi/apps/weather/weather_sources/openmeteo.py+++ b/src/hi/apps/weather/weather_sources/openmeteo.py@@ -31,9 +31,10 @@ logger = logging.getLogger(__name__)class OpenMeteo(WeatherDataSource, WeatherMixin):+ SOURCE_ID = 'openmeteo'BASE_URL = "https://api.open-meteo.com/v1/"ARCHIVE_BASE_URL = "https://archive-api.open-meteo.com/v1/archive"-+CURRENT_DATA_CACHE_EXPIRY_SECS = 10 * 60 # Cache for 10 minutesFORECAST_DATA_CACHE_EXPIRY_SECS = 60 * 60 # Cache for 1 hourHISTORICAL_DATA_CACHE_EXPIRY_SECS = 30 * 24 * 60 * 60 # 30 days - historical data rarely changes@@ -42,7 +43,7 @@ class OpenMeteo(WeatherDataSource, WeatherMixin):@classmethoddef weather_source_id(cls):- return 'openmeteo'+ return cls.SOURCE_ID@classmethoddef weather_source_label(cls):@@ -725,9 +726,11 @@ class OpenMeteo(WeatherDataSource, WeatherMixin):if current_data_str:logger.debug('OpenMeteo current weather data from cache.')+ self.record_cache_hit()current_data = json.loads(current_data_str)return current_data+ self.record_cache_miss()current_data = self._get_current_weather_data_from_api(geographic_location = geographic_location)if current_data:current_data_str = json.dumps(current_data)@@ -764,9 +767,11 @@ class OpenMeteo(WeatherDataSource, WeatherMixin):if forecast_data_str:logger.debug('OpenMeteo hourly forecast data from cache.')+ self.record_cache_hit()forecast_data = json.loads(forecast_data_str)return forecast_data+ self.record_cache_miss()forecast_data = self._get_hourly_forecast_data_from_api(geographic_location = geographic_location)if forecast_data:forecast_data_str = json.dumps(forecast_data)@@ -803,9 +808,11 @@ class OpenMeteo(WeatherDataSource, WeatherMixin):if forecast_data_str:logger.debug('OpenMeteo daily forecast data from cache.')+ self.record_cache_hit()forecast_data = json.loads(forecast_data_str)return forecast_data+ self.record_cache_miss()forecast_data = self._get_daily_forecast_data_from_api(geographic_location = geographic_location)if forecast_data:forecast_data_str = json.dumps(forecast_data)@@ -845,9 +852,11 @@ class OpenMeteo(WeatherDataSource, WeatherMixin):if historical_data_str:logger.debug('OpenMeteo historical data from cache.')+ self.record_cache_hit()historical_data = json.loads(historical_data_str)return historical_data+ self.record_cache_miss()historical_data = self._get_historical_weather_data_from_api(geographic_location = geographic_location,start_date = start_date,diff --git a/src/hi/apps/weather/weather_sources/sunrise_sunset_org.py b/src/hi/apps/weather/weather_sources/sunrise_sunset_org.pyindex 45e30959..00b99340 100644--- a/src/hi/apps/weather/weather_sources/sunrise_sunset_org.py+++ b/src/hi/apps/weather/weather_sources/sunrise_sunset_org.py@@ -255,9 +255,11 @@ class SunriseSunsetOrg(WeatherDataSource, WeatherMixin):if api_data_str:logger.debug('Sunrise-Sunset.org astronomical data from cache.')+ self.record_cache_hit()api_data = json.loads(api_data_str)return api_data+ self.record_cache_miss()api_data = self._get_astronomical_api_data_from_api(geographic_location = geographic_location,target_date = target_date,diff --git a/src/hi/apps/weather/weather_sources/usno.py b/src/hi/apps/weather/weather_sources/usno.pyindex 1f13d620..3de3e6b1 100644--- a/src/hi/apps/weather/weather_sources/usno.py+++ b/src/hi/apps/weather/weather_sources/usno.py@@ -362,9 +362,11 @@ class USNO( WeatherDataSource, WeatherMixin ):if api_data_str:logger.debug('USNO astronomical data from cache.')+ self.record_cache_hit()api_data = json.loads(api_data_str)return api_data+ self.record_cache_miss()api_data = self._get_astronomical_api_data_from_api(geographic_location = geographic_location,target_date = target_date,diff --git a/src/hi/integrations/integration_manager.py b/src/hi/integrations/integration_manager.pyindex d3240d80..4e8792cd 100644--- a/src/hi/integrations/integration_manager.py+++ b/src/hi/integrations/integration_manager.py@@ -15,6 +15,7 @@ from hi.apps.attribute.enums import AttributeTypefrom hi.apps.common.delayed_signal_processor import DelayedSignalProcessorfrom hi.apps.common.singleton import Singletonfrom hi.apps.common.module_utils import import_module_safe+from hi.apps.system.health_status_provider import HealthStatusProviderfrom .enums import IntegrationAttributeTypefrom .integration_data import IntegrationData@@ -72,6 +73,10 @@ class IntegrationManager( Singleton ):return self._integration_data_map[integration_id].integration_gatewayraise KeyError( f'Unknown integration id "{integration_id}".' )+ def get_health_status_providers(self) -> List[HealthStatusProvider]:+ with self._data_lock:+ return list( self._monitor_map.values() )+async def initialize( self, event_loop ) -> None:"""This should be initialized from the background thread where the@@ -185,7 +190,8 @@ class IntegrationManager( Singleton ):returnlogger.debug(f"Starting integration monitor: {integration_id}")- asyncio.create_task( monitor.start() )+ asyncio.create_task( monitor.start(),+ name=f'Integration-{integration_id}' )returndef _stop_integration_monitor( self, integration_data : IntegrationData ):diff --git a/src/hi/integrations/templates/integrations/pages/integration_manage.html b/src/hi/integrations/templates/integrations/pages/integration_manage.htmlindex 4a4a5f19..b0439a93 100644--- a/src/hi/integrations/templates/integrations/pages/integration_manage.html+++ b/src/hi/integrations/templates/integrations/pages/integration_manage.html@@ -18,7 +18,7 @@data-async="true"><div class="d-flex justify-content-between align-items-center"><span>{{ integration_data.label }}</span>- {% with health_status=integration_data.integration_gateway.health_status %}+ {% with health_status=integration_data.integration_gateway.get_health_status %}{% if health_status.is_error %}<span class="text-danger"> {% icon "warning" size="lg" css_class="mr-1" %}diff --git a/src/hi/integrations/views.py b/src/hi/integrations/views.pyindex 3a5e3983..f39c17ff 100644--- a/src/hi/integrations/views.py+++ b/src/hi/integrations/views.py@@ -55,7 +55,7 @@ class IntegrationSelectView( HiModalView, IntegrationViewMixin ):class IntegrationHealthStatusView( HiModalView, IntegrationViewMixin ):def get_template_name( self ) -> str:- return 'system/modals/aggregate_health_status.html'+ return 'system/modals/health_status.html'def get( self, request, *args, **kwargs ):integration_id = kwargs.get('integration_id')diff --git a/src/hi/services/hass/hass_manager.py b/src/hi/services/hass/hass_manager.pyindex fefdeb6d..0520c396 100644--- a/src/hi/services/hass/hass_manager.py+++ b/src/hi/services/hass/hass_manager.py@@ -46,7 +46,6 @@ class HassManager( SingletonManager, AggregateHealthProvider, ApiHealthStatusPro@classmethoddef get_provider_info(cls) -> ProviderInfo:- """ Subclasses should override with something more meaningful. """return ProviderInfo(provider_id = 'hass_integration',provider_name = 'Home Assistant Integration',diff --git a/src/hi/services/hass/monitors.py b/src/hi/services/hass/monitors.pyindex 64a03bb0..311b9c9d 100644--- a/src/hi/services/hass/monitors.py+++ b/src/hi/services/hass/monitors.py@@ -14,7 +14,7 @@ logger = logging.getLogger(__name__)class HassMonitor( PeriodicMonitor, HassMixin, SensorResponseMixin ):- HASS_POLLING_INTERVAL_SECS = 2+ HASS_POLLING_INTERVAL_SECS = 4HASS_API_TIMEOUT_SECS = 10.0 # Shorter timeout appropriate for 2-second pollingdef __init__( self ):@@ -52,11 +52,11 @@ class HassMonitor( PeriodicMonitor, HassMixin, SensorResponseMixin ):@classmethoddef get_provider_info(cls) -> ProviderInfo:- """ Subclasses should override with something more meaningful. """return ProviderInfo(- provider_id = 'hi.sevices.hass',+ provider_id = 'hi.services.hass',provider_name = 'Home Assistant Monitor',- description = '',+ description = 'Home Assistant device state monitoring',+ expected_heartbeat_interval_secs = cls.HASS_POLLING_INTERVAL_SECS,)async def do_work(self):diff --git a/src/hi/services/zoneminder/monitors.py b/src/hi/services/zoneminder/monitors.pyindex 32adda70..ca69260a 100644--- a/src/hi/services/zoneminder/monitors.py+++ b/src/hi/services/zoneminder/monitors.py@@ -59,11 +59,11 @@ class ZoneMinderMonitor( PeriodicMonitor, ZoneMinderMixin, SensorResponseMixin )@classmethoddef get_provider_info(cls) -> ProviderInfo:- """ Subclasses should override with something more meaningful. """return ProviderInfo(- provider_id = 'hi.sevices.zoneminder',+ provider_id = 'hi.services.zoneminder',provider_name = 'ZoneMinder Monitor',- description = '',+ description = 'ZoneMinder camera motion detection',+ expected_heartbeat_interval_secs = cls.ZONEMINDER_POLLING_INTERVAL_SECS,)def refresh( self ):diff --git a/src/hi/services/zoneminder/zm_manager.py b/src/hi/services/zoneminder/zm_manager.pyindex c645f790..6d9673b3 100644--- a/src/hi/services/zoneminder/zm_manager.py+++ b/src/hi/services/zoneminder/zm_manager.py@@ -76,7 +76,6 @@ class ZoneMinderManager( SingletonManager, AggregateHealthProvider, ApiHealthSta@classmethoddef get_provider_info(cls) -> ProviderInfo:- """ Subclasses should override with something more meaningful. """return ProviderInfo(provider_id = 'zm_integration',provider_name = 'ZoneMinder Integration',diff --git a/src/hi/static/css/main.css b/src/hi/static/css/main.cssindex efd75651..cd9e0d5c 100644--- a/src/hi/static/css/main.css+++ b/src/hi/static/css/main.css@@ -15,6 +15,7 @@--on-tertiary-color: #ffffff;--tertiary-highlight-color: #7e7e81;--success-color: #177219;+ --info-color: #177072;--on-success-color: #ffffff;--success-bg-light: #e8f5e8;--warning-color: #ECA500;@@ -1198,27 +1199,25 @@ g[hover] {100% { opacity: 1; }}+.border-healthy { border-color: var(--success-color); }+.border-warning { border-color: var(--warning-color); }+.border-info { border-color: var(--info-color); }+.border-error { border-color: var(--error-color); }+.border-muted { border-color: var(--muted-color); }+.border-unknown { border-color: var(--muted-color); }+.api-source-section {border-left: 3px solid var(--line-color);padding-left: 1rem;margin-left: 0.5rem;}-.api-source-healthy {- border-left-color: var(--success-color);-}--.api-source-warning {- border-left-color: var(--warning-color);-}--.api-source-error {- border-left-color: var(--error-color);-}--.api-source-muted {- border-left-color: var(--muted-color);-}+.api-source-healthy { border-left-color: var(--success-color); }+.api-source-warning { border-left-color: var(--warning-color); }+.api-source-info { border-left-color: var(--info-color); }+.api-source-error { border-left-color: var(--error-color); }+.api-source-muted { border-left-color: var(--muted-color); }+.api-source-unknown { border-left-color: var(--muted-color); }.api-metrics-grid {display: grid;diff --git a/src/hi/templates/icons/minus-circle.html b/src/hi/templates/icons/minus-circle.htmlnew file mode 100644index 00000000..dab080a1--- /dev/null+++ b/src/hi/templates/icons/minus-circle.html@@ -0,0 +1,3 @@+<svg class="{{ class_attr }}" viewBox="0 0 24 24" fill="currentColor" {{ accessibility_attrs }}>+ <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11H7v-2h10v2z"/>+</svg>\ No newline at end of filediff --git a/src/hi/templates/icons/tasks.html b/src/hi/templates/icons/tasks.htmlnew file mode 100644index 00000000..841db378--- /dev/null+++ b/src/hi/templates/icons/tasks.html@@ -0,0 +1,6 @@+<svg class="{{ class_attr }}" viewBox="0 0 24 24" fill="currentColor" {{ accessibility_attrs }}>+ <path d="M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zM16 18H8v-2h8v2zm0-4H8v-2h8v2zm0-4H8V8h8v2zm-3-5V3.5L18.5 9H13z"/>+ <circle cx="6" cy="9" r="1"/>+ <circle cx="6" cy="13" r="1"/>+ <circle cx="6" cy="17" r="1"/>+</svg>\ No newline at end of file