Home Information - Your home, your data, organized.
Python
Pre-release tweaks across simulator, attributes, weather, Frigate, naming (#376)
Tony C1a6a70487509
diff --git a/docs/Features.md b/docs/Features.mdindex 8cef5160..32cb1e9c 100644--- a/docs/Features.md+++ b/docs/Features.md@@ -49,7 +49,7 @@ Home Information provides comprehensive tools for organizing, monitoring, and co- **Device control** - lights, switches, sensors, and other Home Assistant-managed devices- **Status monitoring** - real-time device states displayed visually on your home layout- **Historical data** - device state change histories and usage patterns-- **Automated rules** - create event triggers and automation rules+- **Automated rules** - create rules that raise alerts or run actions when entity states match defined conditions**Real-world benefit:** Instead of opening a separate app and navigating device lists, you see device status right on your home map and control them in context.diff --git a/docs/GettingStarted.md b/docs/GettingStarted.mdindex cd396566..5b5ae13e 100644--- a/docs/GettingStarted.md+++ b/docs/GettingStarted.md@@ -91,13 +91,13 @@ If the integation provides cameras with video feeds (e.g., ZoneMinder), the came<img src="img/getting-started/video-stream-live-1024x768.png" alt="video-stream-live-1024x768.png" width="400" /> <img src="img/getting-started/video-stream-history-1024x768.png" alt="video-stream-history-1024x768.png" width="400" />-### Alert Triggering Rules and Security Modes+### Alert Rules and Security Modes-By default, if you have motion sensors, open/close sensors, camera motion, etc. the integration item import automatically creates alert triggering rules. You can view, refine and manage these in the configuration pages.+By default, if you have motion sensors, open/close sensors, camera motion, etc. the integration item import automatically creates alert rules. You can view, refine and manage these in the configuration pages.-<img src="img/getting-started/trigger-rules-1024x768.png" alt="trigger-rules-1024x768" width="400" />+<img src="img/getting-started/trigger-rules-1024x768.png" alt="rules-1024x768" width="400" />-The triggering rules allows you to target different "security modes" for better control of what alerts and when.+The rules allow you to target different "security modes" for better control of what alerts and when.<img src="img/getting-started/security-modes.png" alt="security-modes" width="250" />diff --git a/docs/integrations/frigate.md b/docs/integrations/frigate.mdindex 4e885b78..a3a1281d 100644--- a/docs/integrations/frigate.md+++ b/docs/integrations/frigate.md@@ -34,15 +34,14 @@ motion bit and label.The integration was validated against Frigate with authenticationdisabled. No credentials are required in that mode. For installsthat gate Frigate behind authentication, see-[Authentication caveat](#authentication-caveat) at the end of this-page.+[Authentication](#authentication) at the end of this page.## Configuration values| Field | What to enter | Notes ||-------|---------------|-------|| Base URL | Frigate's API root, e.g. `http://frigate.local:5000` | No trailing slash. |-| Authorization Header | Optional verbatim `Authorization` header value. | See [Authentication caveat](#authentication-caveat). |+| Authorization Header | Optional verbatim `Authorization` header value. | See [Authentication](#authentication). |## Setup walkthrough@@ -122,16 +121,22 @@ about).originates from Frigate. Configure detection sensitivity, zones,and recording in Frigate's own config.-## Authentication caveat+## Authentication-The integration was validated only against Frigate installs with-authentication disabled. It exposes an optional-**Authorization Header** field that, when set, is sent verbatim on-every request — intended for installs that either use Frigate's-internal auth with a static token, or place Frigate behind a-reverse proxy that enforces auth. **This path has not been tested.**-No other authentication flow is supported: no login, no token-refresh, no JWT handling.+The integration was validated against Frigate with authentication+disabled — the default on a local network. For installs that gate+Frigate behind auth, the supported options are:++| Your Frigate setup | What to put in **Authorization Header** |+|---|---|+| No auth (LAN default) | Leave blank. |+| Reverse proxy with HTTP Basic auth | `Basic <base64(user:pass)>` |+| Reverse proxy with a long-lived bearer token | `Bearer <token>` |+| Reverse proxy with anonymous backend access (proxy enforces auth, but the **HI** server reaches Frigate on an internal address) | Leave blank. |+| Frigate's built-in username/password login | **Not supported in v1.** Frigate issues short-lived JWTs that require a login flow not implemented here. Workaround: front Frigate with a reverse proxy that handles auth and either expose the unauthenticated backend to **HI** on an internal network, or use one of the static schemes above. |++The value you provide is sent verbatim as the `Authorization` HTTP+header on every request to Frigate.## Referencesdiff --git a/src/hi/apps/attribute/view_mixins.py b/src/hi/apps/attribute/view_mixins.pyindex cccca51f..a78edec1 100644--- a/src/hi/apps/attribute/view_mixins.py+++ b/src/hi/apps/attribute/view_mixins.py@@ -246,6 +246,7 @@ class AttributeMultiEditViewMixin( AttributeEditCommonMixin ):multi_edit_form_data_list = form_handler.create_multi_edit_form_data(attr_item_context_list = attr_item_context_list,)+return renderer.render_restore_success_response_multi(attr_page_context = attr_page_context,multi_edit_form_data_list = multi_edit_form_data_list,diff --git a/src/hi/apps/config/enums.py b/src/hi/apps/config/enums.pyindex f893b657..ace9bde2 100644--- a/src/hi/apps/config/enums.py+++ b/src/hi/apps/config/enums.py@@ -17,7 +17,7 @@ class ConfigPageType(LabeledEnum):returnSETTINGS = ('Settings' , '' , 'config_settings' )- EVENTS = ('Triggers' , '' , 'event_definitions' )+ EVENTS = ('Rules' , '' , 'event_definitions' )INTEGRATIONS_CONNECT = ('Connectors' , '' , 'integrations_connect_home' )INTEGRATIONS_REFERENCE = ('Content Sources' , '' , 'integrations_reference_home' )INTEGRATIONS_IMPORT = ('Data Import' , '' , 'integrations_import_home' )diff --git a/src/hi/apps/config/subsystem_attribute_edit_context.py b/src/hi/apps/config/subsystem_attribute_edit_context.pyindex 32842daf..e1265634 100644--- a/src/hi/apps/config/subsystem_attribute_edit_context.py+++ b/src/hi/apps/config/subsystem_attribute_edit_context.py@@ -16,11 +16,26 @@ from .models import Subsystem, SubsystemAttributeclass SubsystemAttributePageEditContext(AttributePageEditContext):- def __init__( self, selected_subsystem_id : str ) -> None:- """Initialize context for Subsystem attribute editing."""- # Use 'subsystem' as owner_type to match URL patterns+ def __init__( self, selected_subsystem_id ) -> None:+ """Initialize context for Subsystem attribute editing.++ ``selected_subsystem_id`` is normalized to a string so the+ template's tab-pane ``show active`` comparison+ (``selected_subsystem_id == owner.id|stringformat:'s'``)+ works regardless of whether the caller's URL captured the+ id as ``<int:>`` (restore views) or ``\\d+`` via ``re_path``+ (the initial config-settings view). Without this, restore+ responses render every tab-pane inactive — the action bar+ stays visible but the attribute body is hidden by Bootstrap's+ ``.fade`` rule, looking exactly like 'only the UPDATE button+ re-rendered'.+ """super().__init__( owner_type = 'subsystem' )- self.selected_subsystem_id = selected_subsystem_id+ self.selected_subsystem_id = (+ str( selected_subsystem_id )+ if selected_subsystem_id is not None+ else None+ )return@propertydiff --git a/src/hi/apps/console/templates/console/panes/hi_grid_side.html b/src/hi/apps/console/templates/console/panes/hi_grid_side.htmlindex 5eae6c07..822b3ba1 100644--- a/src/hi/apps/console/templates/console/panes/hi_grid_side.html+++ b/src/hi/apps/console/templates/console/panes/hi_grid_side.html@@ -20,7 +20,7 @@<a href="{% url 'event_history' %}"class="btn btn-outline-primary btn-control" role="button"data-async="true" >- TRIGGER HISTORY+ RULE MATCHES</a></div>{% endif %}diff --git a/src/hi/apps/event/edit/forms.py b/src/hi/apps/event/edit/forms.pyindex 9fc73a73..cf83234d 100644--- a/src/hi/apps/event/edit/forms.py+++ b/src/hi/apps/event/edit/forms.py@@ -28,7 +28,7 @@ class EventDefinitionForm( forms.ModelForm ):)event_type_str = forms.ChoiceField(- label = 'Trigger Type',+ label = 'Match Type',choices = EventType.choices,initial = EventType.default_value(),required = True,diff --git a/src/hi/apps/event/enums.py b/src/hi/apps/event/enums.pyindex b8a5bdfa..779d6e59 100644--- a/src/hi/apps/event/enums.py+++ b/src/hi/apps/event/enums.py@@ -18,13 +18,13 @@ class EventClauseOperator(LabeledEnum):via ``float()`` at match time and silently no-op on parse failureso a malformed wire value never raises into the matcher."""- EQ = ( 'Equals' , 'Trigger when the value equals the target string.' )- NEQ = ( 'Not Equals' , 'Trigger when the value does not equal the target string.' )- IN = ( 'Is One Of' , 'Trigger when the value matches any item in a comma-separated list.' )- LT = ( 'Less Than' , 'Trigger when the numeric value drops below the threshold.' )- LTE = ( 'At Most' , 'Trigger when the numeric value is at or below the threshold.' )- GT = ( 'Greater Than' , 'Trigger when the numeric value rises above the threshold.' )- GTE = ( 'At Least' , 'Trigger when the numeric value is at or above the threshold.' )+ EQ = ( 'Equals' , 'Match when the value equals the target string.' )+ NEQ = ( 'Not Equals' , 'Match when the value does not equal the target string.' )+ IN = ( 'Is One Of' , 'Match when the value matches any item in a comma-separated list.' )+ LT = ( 'Less Than' , 'Match when the numeric value drops below the threshold.' )+ LTE = ( 'At Most' , 'Match when the numeric value is at or below the threshold.' )+ GT = ( 'Greater Than' , 'Match when the numeric value rises above the threshold.' )+ GTE = ( 'At Least' , 'Match when the numeric value is at or above the threshold.' )@classmethoddef default(cls):diff --git a/src/hi/apps/event/migrations/0009_alter_eventclause_options_and_more.py b/src/hi/apps/event/migrations/0009_alter_eventclause_options_and_more.pynew file mode 100644index 00000000..68fd9721--- /dev/null+++ b/src/hi/apps/event/migrations/0009_alter_eventclause_options_and_more.py@@ -0,0 +1,83 @@+# Generated by Django 5.2.14 on 2026-05-27 21:12++import django.db.models.deletion+from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("event", "0008_add_eventclause_value_operator"),+ ]++ operations = [+ migrations.AlterModelOptions(+ name="eventclause",+ options={+ "verbose_name": "Rule Condition",+ "verbose_name_plural": "Rule Conditions",+ },+ ),+ migrations.AlterModelOptions(+ name="eventdefinition",+ options={"verbose_name": "Rule", "verbose_name_plural": "Rules"},+ ),+ migrations.AlterModelOptions(+ name="eventhistory",+ options={+ "ordering": ["-event_datetime"],+ "verbose_name": "Rule Match",+ "verbose_name_plural": "Rule Matches",+ },+ ),+ migrations.AlterField(+ model_name="alarmaction",+ name="event_definition",+ field=models.ForeignKey(+ on_delete=django.db.models.deletion.CASCADE,+ related_name="alarm_actions",+ to="event.eventdefinition",+ verbose_name="Rule",+ ),+ ),+ migrations.AlterField(+ model_name="controlaction",+ name="event_definition",+ field=models.ForeignKey(+ on_delete=django.db.models.deletion.CASCADE,+ related_name="control_actions",+ to="event.eventdefinition",+ verbose_name="Rule",+ ),+ ),+ migrations.AlterField(+ model_name="eventclause",+ name="event_definition",+ field=models.ForeignKey(+ on_delete=django.db.models.deletion.CASCADE,+ related_name="event_clauses",+ to="event.eventdefinition",+ verbose_name="Rule",+ ),+ ),+ migrations.AlterField(+ model_name="eventdefinition",+ name="event_type_str",+ field=models.CharField(max_length=32, verbose_name="Match Type"),+ ),+ migrations.AlterField(+ model_name="eventdefinition",+ name="event_window_secs",+ field=models.PositiveIntegerField(verbose_name="Match Window Secs"),+ ),+ migrations.AlterField(+ model_name="eventhistory",+ name="event_definition",+ field=models.ForeignKey(+ on_delete=django.db.models.deletion.CASCADE,+ related_name="history",+ to="event.eventdefinition",+ verbose_name="Rule",+ ),+ ),+ ]diff --git a/src/hi/apps/event/models.py b/src/hi/apps/event/models.pyindex d2f5bb1b..fd232d32 100644--- a/src/hi/apps/event/models.py+++ b/src/hi/apps/event/models.py@@ -34,7 +34,7 @@ class EventDefinition( IntegrationDetailsModel ):max_length = 64,)event_type_str = models.CharField(- 'Trigger Type',+ 'Match Type',max_length = 32,null = False, blank = False,)@@ -43,7 +43,7 @@ class EventDefinition( IntegrationDetailsModel ):# need to satisfied.#event_window_secs = models.PositiveIntegerField(- 'Trigger Window Secs',+ 'Match Window Secs',)# Rate limits how many events will be generated for this@@ -69,8 +69,8 @@ class EventDefinition( IntegrationDetailsModel ):)class Meta:- verbose_name = 'Trigger Definition'- verbose_name_plural = 'Trigger Definitions'+ verbose_name = 'Rule'+ verbose_name_plural = 'Rules'@propertydef event_type(self):@@ -87,7 +87,7 @@ class EventClause( models.Model ):event_definition = models.ForeignKey(EventDefinition,related_name = 'event_clauses',- verbose_name = 'Trigger Definition',+ verbose_name = 'Rule',on_delete = models.CASCADE,)entity_state = models.ForeignKey(@@ -123,8 +123,8 @@ class EventClause( models.Model ):)class Meta:- verbose_name = 'Trigger Clause'- verbose_name_plural = 'Trigger Clauses'+ verbose_name = 'Rule Condition'+ verbose_name_plural = 'Rule Conditions'IN_VALUE_DELIMITER = ','@@ -163,7 +163,7 @@ class AlarmAction( models.Model ):event_definition = models.ForeignKey(EventDefinition,related_name = 'alarm_actions',- verbose_name = 'Trigger Definition',+ verbose_name = 'Rule',on_delete = models.CASCADE,)security_level_str = models.CharField(@@ -226,7 +226,7 @@ class ControlAction( models.Model ):event_definition = models.ForeignKey(EventDefinition,related_name = 'control_actions',- verbose_name = 'Trigger Definition',+ verbose_name = 'Rule',on_delete = models.CASCADE,)controller = models.ForeignKey(@@ -260,7 +260,7 @@ class EventHistory( models.Model ):event_definition = models.ForeignKey(EventDefinition,related_name = 'history',- verbose_name = 'Trigger Definition',+ verbose_name = 'Rule',on_delete = models.CASCADE,)event_datetime = models.DateTimeField(@@ -269,6 +269,6 @@ class EventHistory( models.Model ):)class Meta:- verbose_name = 'Trigger History'- verbose_name_plural = 'Trigger History'+ verbose_name = 'Rule Match'+ verbose_name_plural = 'Rule Matches'ordering = [ '-event_datetime' ]diff --git a/src/hi/apps/event/templates/event/edit/modals/event_definition_add.html b/src/hi/apps/event/templates/event/edit/modals/event_definition_add.htmlindex da08eddb..15c9c54b 100644--- a/src/hi/apps/event/templates/event/edit/modals/event_definition_add.html+++ b/src/hi/apps/event/templates/event/edit/modals/event_definition_add.html@@ -11,7 +11,7 @@{% endblock %}{% block title_text %}-New Trigger Rule+New Rule{% endblock %}{% block body %}diff --git a/src/hi/apps/event/templates/event/edit/modals/event_definition_delete.html b/src/hi/apps/event/templates/event/edit/modals/event_definition_delete.htmlindex 79940628..0cdaa63c 100644--- a/src/hi/apps/event/templates/event/edit/modals/event_definition_delete.html+++ b/src/hi/apps/event/templates/event/edit/modals/event_definition_delete.html@@ -11,12 +11,12 @@{% endblock %}{% block title_text %}-Delete Trigger Rule?+Delete Rule?{% endblock %}{% block body %}<p>-Please confirm that you want to delete this trigger rule.+Please confirm that you want to delete this rule.</p><p class="lead"><ul>diff --git a/src/hi/apps/event/templates/event/edit/modals/event_definition_edit.html b/src/hi/apps/event/templates/event/edit/modals/event_definition_edit.htmlindex e61a66fc..0448a638 100644--- a/src/hi/apps/event/templates/event/edit/modals/event_definition_edit.html+++ b/src/hi/apps/event/templates/event/edit/modals/event_definition_edit.html@@ -11,7 +11,7 @@{% endblock %}{% block title_text %}-Edit Trigger Rule+Edit Rule{% endblock %}{% block body %}diff --git a/src/hi/apps/event/templates/event/modals/event_history.html b/src/hi/apps/event/templates/event/modals/event_history.htmlindex dc85423e..2e418ae2 100644--- a/src/hi/apps/event/templates/event/modals/event_history.html+++ b/src/hi/apps/event/templates/event/modals/event_history.html@@ -4,7 +4,7 @@{% block modal_dialog_class %}hi-modal-dialog-800{% endblock %}{% block title_text %}-Trigger History+Rule Matches{% endblock %}{% block body %}@@ -13,9 +13,9 @@ Trigger History<div class="col-12"><h5 class="mb-0">{% icon "history" size="sm" color="primary" css_class="hi-icon-left" %}- Trigger History+ Rule Matches</h5>- <small class="text-muted">Recent trigger events and their details</small>+ <small class="text-muted">Recent rule matches and their details</small></div></div>diff --git a/src/hi/apps/event/templates/event/panes/event_definitions.html b/src/hi/apps/event/templates/event/panes/event_definitions.htmlindex 17c12b05..9e013fe7 100644--- a/src/hi/apps/event/templates/event/panes/event_definitions.html+++ b/src/hi/apps/event/templates/event/panes/event_definitions.html@@ -5,7 +5,7 @@<div class="container-fluid"><div class="d-flex justify-content-between my-1"><div class="h3">- Trigger Rules+ Rules<span class="badge badge-secondary align-middle ml-1" style="font-size: 0.5em;">BETA</span></div><div>@@ -17,7 +17,7 @@</div></div><p class="text-muted mb-3">- Triggers alerts or actions when entity states match a defined condition.+ Raises alerts or runs actions when entity states match a defined condition.The current interface covers the core cases; richer editing is planned.</p>@@ -73,7 +73,7 @@</td></tr>{% empty %}- <tr><td colspan="6"><div class="col-12 alert alert-info" >No event definitions.</div></td></tr>+ <tr><td colspan="6"><div class="col-12 alert alert-info" >No rules defined.</div></td></tr>{% endfor %}</tbody></table>diff --git a/src/hi/apps/event/templates/event/panes/event_history_list.html b/src/hi/apps/event/templates/event/panes/event_history_list.htmlindex 110991e9..43149ddb 100644--- a/src/hi/apps/event/templates/event/panes/event_history_list.html+++ b/src/hi/apps/event/templates/event/panes/event_history_list.html@@ -64,8 +64,8 @@<div class="card border-0 bg-light"><div class="card-body text-center py-4">{% icon "clock" size="xl" color="muted" css_class="mb-3" %}- <h6 class="text-muted">No Event History</h6>- <p class="text-muted mb-0">No trigger events have been recorded yet.</p>+ <h6 class="text-muted">No Rule Matches</h6>+ <p class="text-muted mb-0">No rule matches have been recorded yet.</p></div></div>{% endif %}diff --git a/src/hi/apps/weather/monitors.py b/src/hi/apps/weather/monitors.pyindex 648e7f4e..c3b88eb5 100644--- a/src/hi/apps/weather/monitors.py+++ b/src/hi/apps/weather/monitors.py@@ -2,10 +2,8 @@ import asyncioimport loggingimport hi.apps.common.datetimeproxy as datetimeproxy-from hi.apps.alert.enums import AlarmLevelfrom hi.apps.monitor.periodic_monitor import PeriodicMonitor-from hi.apps.alert.alert_mixins import AlertMixinfrom hi.apps.config.settings_mixins import SettingsMixinfrom hi.apps.system.provider_info import ProviderInfo@@ -16,7 +14,7 @@ from .weather_source_manager import WeatherSourceManagerlogger = logging.getLogger(__name__)-class WeatherMonitor( PeriodicMonitor, AlertMixin, SettingsMixin ):+class WeatherMonitor( PeriodicMonitor, SettingsMixin ):MONITOR_ID = 'hi.apps.weather.monitor'@@ -69,15 +67,6 @@ class WeatherMonitor( PeriodicMonitor, AlertMixin, SettingsMixin ):),)- def alarm_ceiling(self):- # Cap at INFO for two reasons:- # 1. Weather staleness is informational — the user is not- # typically depending on the configured freshness window.- # 2. The monitor records WARNING during its startup-safety- # window. Capping at INFO prevents that startup transition- # from firing alarms on every server restart.- return AlarmLevel.INFO-async def do_work(self):# To help guard against hitting API rate limits, hold off ondiff --git a/src/hi/apps/weather/templates/weather/panes/conditions.html b/src/hi/apps/weather/templates/weather/panes/conditions.htmlindex d17ca35b..5e664300 100644--- a/src/hi/apps/weather/templates/weather/panes/conditions.html+++ b/src/hi/apps/weather/templates/weather/panes/conditions.html@@ -75,9 +75,12 @@<div class="weather-pane-status mt-2">{% if weather_pane_status.caption_text %}- <div class="alert {{ weather_pane_status.caption_alert_class }} py-1 px-2 mb-0 d-flex align-items-center small" role="status">+ <a href="{% url 'system_health_status' provider_id='hi.apps.weather.monitor' %}"+ class="alert {{ weather_pane_status.caption_alert_class }} py-1 px-2 mb-0 d-flex align-items-center small"+ role="status"+ data-async="modal">{% icon weather_pane_status.caption_icon size="sm" css_class="hi-icon-left" %}<span>{{ weather_pane_status.caption_text }}</span>- </div>+ </a>{% if conditions.temperature.source %}<small class="text-muted d-block mt-1"><em>Last reading: {{ conditions.temperature.source_datetime |localtime|date:"g:i A" }} from {{ conditions.temperature.source.abbreviation }}</em></small>{% endif %}diff --git a/src/hi/middleware.py b/src/hi/middleware.pyindex b5f8815c..79299ce2 100644--- a/src/hi/middleware.py+++ b/src/hi/middleware.py@@ -28,7 +28,7 @@ class ViewMiddleware:def __init__(self, get_response):self.get_response = get_responsereturn-+def __call__(self, request):self._set_view_parameters( request )return self.get_response( request )@@ -37,6 +37,41 @@ class ViewMiddleware:request.view_parameters = ViewParameters.from_session( request )return++class NoStoreMiddleware:+ """Set ``Cache-Control: no-store`` on dynamic HTML and JSON+ responses.++ Without an explicit cache directive, browsers apply heuristic+ caching to HTML and may serve a previously-rendered page from+ cache when the server is unreachable — controls in the cached+ JS appear to work but every AJAX call silently fails. ``no-store``+ opts out so a reload while the server is down shows the browser's+ native error page, not a deceptive working-looking UI.++ Static assets (CSS, JS, images, fonts) are untouched — their+ content type doesn't match, and they should remain cacheable.+ Views that explicitly set ``Cache-Control`` (e.g. streaming+ endpoints with their own directives) are respected.+ """++ _DYNAMIC_CONTENT_PREFIXES = ( 'text/html', 'application/json' )++ def __init__( self, get_response ):+ self.get_response = get_response+ return++ def __call__( self, request ):+ response = self.get_response( request )+ if response.has_header( 'Cache-Control' ):+ return response+ content_type = response.get( 'Content-Type', '' )+ for prefix in self._DYNAMIC_CONTENT_PREFIXES:+ if content_type.startswith( prefix ):+ response[ 'Cache-Control' ] = 'no-store'+ break+ return response+class ExceptionMiddleware:diff --git a/src/hi/services/frigate/enums.py b/src/hi/services/frigate/enums.pyindex 0151cc3b..134bf167 100644--- a/src/hi/services/frigate/enums.py+++ b/src/hi/services/frigate/enums.py@@ -4,14 +4,6 @@ from hi.integrations.enums import IntegrationAttributeTypeclass FrigateAttributeType( IntegrationAttributeType ):- """Operator-configurable settings for the Frigate integration.-- v1 assumes Frigate is reachable directly (or behind an operator-managed- reverse proxy that handles auth). The optional ``AUTH_HEADER`` slot is a- stretch for installs that gate Frigate behind basic-auth / a static- bearer token; JWT login is out of v1 scope and will be revisited once- we have real-install validation.- """BASE_URL = ('Base URL',@@ -23,12 +15,11 @@ class FrigateAttributeType( IntegrationAttributeType ):)AUTH_HEADER = ('Authorization Header',- 'Optional. Verbatim Authorization header value (e.g., '- '"Bearer xyz" or "Basic <base64>"). Leave blank for unauthenticated '- 'access or when auth is handled by a reverse proxy.',+ 'Optional. Sent verbatim as the Authorization header '+ '(e.g., "Basic <base64>" or "Bearer <token>").',AttributeValueType.SECRET,None,- False,+ True,False,)ADD_ALARM_EVENTS = (diff --git a/src/hi/services/hass/hass_converter.py b/src/hi/services/hass/hass_converter.pyindex 7bcbc52b..af004f26 100644--- a/src/hi/services/hass/hass_converter.py+++ b/src/hi/services/hass/hass_converter.py@@ -513,7 +513,16 @@ class HassConverter:hass_device.add_state( hass_state = hass_state )continue- # Next case is when the short name matches to another state+ # Next case is when the short name matches to another state.+ # NOTE: pairing happens only across states present in the+ # *current* sync pass. If the operator excludes a domain+ # (e.g. ``camera``) on one sync and re-enables it on a+ # later sync, the previously-orphaned partner (e.g.+ # ``binary_sensor.X_motion``) is already a standalone HI+ # entity of its standalone type and will not be absorbed+ # into the newly-arriving camera entity. Workaround:+ # wipe the orphan and re-sync. Rare power-user path; not+ # worth the cross-pass absorption logic until it bites.if short_name in hass_device_id_to_device:hass_device = hass_device_id_to_device[short_name]hass_device.add_state( hass_state = hass_state )diff --git a/src/hi/services/hass/hass_manager.py b/src/hi/services/hass/hass_manager.pyindex ee7d9ce3..bbfda85c 100644--- a/src/hi/services/hass/hass_manager.py+++ b/src/hi/services/hass/hass_manager.py@@ -148,7 +148,18 @@ class HassManager( SingletonManager, AggregateHealthProvider, ApiHealthStatusProintegration_id = HassMetaData.integration_id,integration_name__startswith = f'{HassApi.CAMERA_DOMAIN}.',).values_list( 'entity_state__entity_id', 'integration_name' )- self._entity_id_to_ha_state_id = dict( pairs )+ # Camera Sensors carry substate-suffixed integration_names+ # ('camera.front_door~state', '...~motion_detection') since+ # cameras went through the multi-substate decomposition path.+ # The latest-attrs cache is keyed by the bare HA state id+ # ('camera.front_door'); strip the suffix so the snapshot+ # lookup hits the cache. Multiple substate sensors for the+ # same camera all collapse to the same bare key — consistent+ # by construction.+ self._entity_id_to_ha_state_id = {+ entity_id: name.split( '~', 1 )[ 0 ]+ for entity_id, name in pairs+ }returndef get_ha_state_id_for_entity( self, entity ) -> Optional[ str ]:diff --git a/src/hi/settings/base.py b/src/hi/settings/base.pyindex 076361d8..bcf60c9a 100644--- a/src/hi/settings/base.py+++ b/src/hi/settings/base.py@@ -142,6 +142,7 @@ MIDDLEWARE = ['django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',+ 'hi.middleware.NoStoreMiddleware','hi.middleware.ExceptionMiddleware','hi.middleware.ViewMiddleware','hi.apps.console.middleware.ConsoleLockMiddleware',diff --git a/src/hi/settings/simulator.py b/src/hi/settings/simulator.pyindex c7eb2f1b..98503307 100644--- a/src/hi/settings/simulator.py+++ b/src/hi/settings/simulator.py@@ -36,6 +36,7 @@ MIDDLEWARE = ['django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',+ 'hi.simulator.middleware.NoStoreMiddleware','hi.simulator.services.middleware.ServiceFaultInjectionMiddleware',]diff --git a/src/hi/simulator/management/commands/seed_sim_profiles.py b/src/hi/simulator/management/commands/seed_sim_profiles.pyindex 29f741fa..68dd3463 100644--- a/src/hi/simulator/management/commands/seed_sim_profiles.py+++ b/src/hi/simulator/management/commands/seed_sim_profiles.py@@ -734,9 +734,10 @@ class Command(BaseCommand):# ----- ZoneMinder builders -----def _build_zm_baseline(self, profile: SimProfile) -> int:- # 1 server (singleton) + 2 monitors + a ★-prefixed monitor- # anchor for the ZM detach/reconnect cycle.- self._add_zm_server( profile )+ # 2 monitors + a ★-prefixed monitor anchor for the ZM+ # detach/reconnect cycle. The ZM Server entity is auto-created+ # on first access by the simulator; persisting it here would+ # double up.self._add_zm_monitor( profile, 'Front Door Camera' , monitor_id = 1 )self._add_zm_monitor( profile, 'Driveway Camera' , monitor_id = 2 )self._add_zm_monitor(@@ -757,18 +758,18 @@ class Command(BaseCommand):# avoid colliding with the# ★-prefixed Detached anchor when# flipping back.- self._add_zm_server( profile )+ # ZM Server is auto-created on first access by the simulator.self._add_zm_monitor( profile, 'Front Porch Camera' , monitor_id = 1 )self._add_zm_monitor( profile, 'Garage Camera' , monitor_id = 3 )return profile.db_sim_entities.count()def _build_zm_volume(self, profile: SimProfile) -> int:- # 1 server + 10 monitors. Stresses dispatcher group sizing.- self._add_zm_server( profile )+ # 10 monitors. Stresses dispatcher group sizing. ZM Server is+ # auto-created on first access by the simulator.for index in range(10):self._add_zm_monitor(profile,- f'Volume Camera {index + 1:02}',+ f'ZM Camera {index + 1:02}',monitor_id = 100 + index,)return profile.db_sim_entities.count()@@ -805,8 +806,8 @@ class Command(BaseCommand):for index in range(10):self._add_frigate_camera(profile,- f'Volume Camera {index + 1:02}',- camera_name = f'volume_camera_{index + 1:02}',+ f'Frigate Camera {index + 1:02}',+ camera_name = f'frigate_camera_{index + 1:02}',)return profile.db_sim_entities.count()diff --git a/src/hi/simulator/middleware.py b/src/hi/simulator/middleware.pynew file mode 100644index 00000000..b2377f58--- /dev/null+++ b/src/hi/simulator/middleware.py@@ -0,0 +1,37 @@+class NoStoreMiddleware:+ """Set ``Cache-Control: no-store`` on dynamic HTML and JSON+ responses.++ Without an explicit cache directive, browsers apply heuristic+ caching to HTML and may serve a previously-rendered page from+ cache when the server is unreachable — controls in the cached+ JS appear to work but every AJAX call silently fails. ``no-store``+ opts out so a reload while the server is down shows the browser's+ native error page, not a deceptive working-looking UI.++ Static assets (CSS, JS, images, fonts) are untouched — their+ content type doesn't match, and they should remain cacheable.+ Views that explicitly set ``Cache-Control`` (e.g. streaming+ endpoints with their own directives) are respected.++ Mirrors ``hi.middleware.NoStoreMiddleware``; the simulator is a+ separate Django app with deliberately minimal sharing, so it+ carries its own copy rather than importing from the main app.+ """++ _DYNAMIC_CONTENT_PREFIXES = ( 'text/html', 'application/json' )++ def __init__( self, get_response ):+ self.get_response = get_response+ return++ def __call__( self, request ):+ response = self.get_response( request )+ if response.has_header( 'Cache-Control' ):+ return response+ content_type = response.get( 'Content-Type', '' )+ for prefix in self._DYNAMIC_CONTENT_PREFIXES:+ if content_type.startswith( prefix ):+ response[ 'Cache-Control' ] = 'no-store'+ break+ return responsediff --git a/src/hi/simulator/services/service_simulator.py b/src/hi/simulator/services/service_simulator.pyindex 02b418bd..b741ae58 100644--- a/src/hi/simulator/services/service_simulator.py+++ b/src/hi/simulator/services/service_simulator.py@@ -154,6 +154,20 @@ class ServiceSimulator( Singleton ):"""self._sim_entity_map : Dict[ id, SimEntity ] = dict()return++ def post_load_hook( self ):+ """Called once by the ServiceSimulatorManager after a profile+ load has finished hydrating ``self._sim_entity_map`` from the+ database. Subclasses override this to ensure required default+ entities exist for the freshly-loaded profile — e.g. a+ singleton "server" entity that should be present in every+ profile. Default is a no-op.++ Implementations may call back into the manager (e.g. via+ ``add_sim_entity``) and so must NOT be called while the+ manager's data lock is held.+ """+ returndef validate_new_sim_entity_fields( self, new_sim_entity_fields : SimEntityFields ):"""diff --git a/src/hi/simulator/services/service_simulator_manager.py b/src/hi/simulator/services/service_simulator_manager.pyindex 4fb52633..964276b3 100644--- a/src/hi/simulator/services/service_simulator_manager.py+++ b/src/hi/simulator/services/service_simulator_manager.py@@ -115,8 +115,14 @@ class ServiceSimulatorManager( Singleton ):self._discover_defined_simulators()self._fetch_sim_entity_definitions()self._register_profile_callbacks()- await sync_to_async( self._load_entities_for_all_simulators,- thread_sensitive = True )()+ # Release the lock before per-simulator hydration: each+ # _load_entities_for_simulator acquires the lock for the+ # duration of its own clear+rehydrate, and post_load_hook+ # then calls back through add_sim_entity which re-acquires+ # the lock. Holding the lock across the sync_to_async hop+ # would also block any other thread that tried to acquire it.+ await sync_to_async( self._load_entities_for_all_simulators,+ thread_sensitive = True )()returnasync def shutdown( self ) -> None:@@ -206,24 +212,34 @@ class ServiceSimulatorManager( Singleton ):logger.debug(f'Loading entities for {simulator.id} from profile {profile}.')- simulator.initialize()- simulator_data = self._simulator_data_map.get( simulator.id )- if simulator_data is None:- return- sim_entity_definition_map = simulator_data.sim_entity_definition_map-- for db_sim_entity in DbSimEntity.objects.filter( sim_profile = profile ):- class_id = db_sim_entity.entity_fields_class_id- sim_entity_definition = sim_entity_definition_map.get( class_id )- if not sim_entity_definition:+ # Hold the lock for the entire clear+rehydrate so concurrent+ # add_sim_entity calls (e.g. an on-demand auto-create racing+ # in via a request while we're mid-hydration) cannot see a+ # partially-populated map and decide a singleton is missing.+ # Without this, the auto-create persists a duplicate row and+ # the duplicate sticks in the DB for that profile thereafter.+ with self._data_lock:+ simulator.initialize()+ simulator_data = self._simulator_data_map.get( simulator.id )+ if simulator_data is None:+ return+ sim_entity_definition_map = simulator_data.sim_entity_definition_map++ for db_sim_entity in DbSimEntity.objects.filter( sim_profile = profile ):+ class_id = db_sim_entity.entity_fields_class_id+ sim_entity_definition = sim_entity_definition_map.get( class_id )+ if not sim_entity_definition:+ continue+ sim_entity = SimEntity(+ db_sim_entity = db_sim_entity,+ sim_entity_definition = sim_entity_definition,+ )+ try:+ simulator.add_sim_entity( sim_entity = sim_entity )+ except SimEntityValidationError:+ logger.exception( 'Could not add DB simulator entity.' )continue- sim_entity = SimEntity(- db_sim_entity = db_sim_entity,- sim_entity_definition = sim_entity_definition,- )- try:- simulator.add_sim_entity( sim_entity = sim_entity )- except SimEntityValidationError:- logger.exception( 'Could not add DB simulator entity.' )- continue+ # Outside the lock: the hook may call back through+ # add_sim_entity, which re-acquires the lock.+ simulator.post_load_hook()returndiff --git a/src/hi/simulator/services/zoneminder/simulator.py b/src/hi/simulator/services/zoneminder/simulator.pyindex 1ca144ab..2b5545aa 100644--- a/src/hi/simulator/services/zoneminder/simulator.py+++ b/src/hi/simulator/services/zoneminder/simulator.py@@ -55,6 +55,14 @@ class ZoneMinderSimulator( ServiceSimulator ):continuereturn None+ def post_load_hook( self ):+ # Materialize the singleton ZM Server entity at profile-load+ # time so a freshly-created or freshly-switched-to profile+ # always shows it without needing a ZM-specific request to+ # trigger the on-demand creation in get_zm_server_sim_entity.+ self.get_zm_server_sim_entity()+ return+def get_zm_server_sim_entity( self ) -> ZmSimServer:for sim_entity in self.sim_entities:if sim_entity.sim_entity_definition.sim_entity_fields_class == ZmServerSimEntityFields:diff --git a/src/hi/static/js/attr.js b/src/hi/static/js/attr.jsindex 28935999..d8b2d367 100644--- a/src/hi/static/js/attr.js+++ b/src/hi/static/js/attr.js@@ -1530,6 +1530,17 @@if ($hiddenField && $hiddenField.length > 0) {$hiddenField.val(defaultValue);}++ // Refresh the read-mode display so the operator sees the+ // restored value immediately. The read content was rendered+ // server-side with attribute_text_linkify; we replace with+ // escaped plain text here. Server re-linkifies on save.+ const $readContent = $card.find(+ Hi.ATTR_V2_TEXT_READ_CONTENT_SELECTOR+ ).first();+ if ($readContent.length > 0) {+ $readContent.text(defaultValue || ' ');+ }}function _restoreSelect($card, defaultValue) {