Home Information - Your home, your data, organized.
Python
Miscellaneous Tweaks and Fixes (#181)
Tony Ca8ea32f958ac
diff --git a/README.md b/README.mdindex 0b98aace..a77d3f22 100644--- a/README.md+++ b/README.md@@ -23,13 +23,6 @@ See [Why Home Information?](docs/WhyHomeInformation.md) for more details on our## Quick Start-### Prerequisites-- **Docker** installed and running ([Get Docker](https://docs.docker.com/get-docker/))-- **Python 3.6+** for secure credential generation-- Basic command line familiarity--### Single-Command Installation (Recommended)-**Get running in 30 seconds:**```shell@@ -38,38 +31,14 @@ curl -fsSL https://raw.githubusercontent.com/cassandra/home-information/master/i**Then visit:** [http://localhost:9411](http://localhost:9411)-The script will automatically:-- Check that Docker is running-- Create necessary directories (`~/.hi/`)-- Generate secure admin credentials-- Pull and start the application--**To update an existing installation:**-```shell-curl -fsSL https://raw.githubusercontent.com/cassandra/home-information/master/update.sh | bash-```+The install script automatically handles everything: Docker setup verification, secure credential generation, and application startup.-### Manual Installation (Full Control)+**Requirements:** [Docker](https://docs.docker.com/get-docker/) installed and running.-**Step-by-step process for advanced users:**--```shell-# Download latest release-curl -L https://github.com/cassandra/home-information/releases/latest/download/home-information.zip -o home-information.zip-unzip home-information.zip && cd home-information*--# Setup and run-make env-build-make docker-build-make docker-run-fg-```--**Then visit:** [http://localhost:9411](http://localhost:9411)+**Need more control?** See [Installation Guide](docs/Installation.md) for manual installation, deployment options, and troubleshooting.**New to the interface?** Follow the [Getting Started Guide](docs/GettingStarted.md) for a walkthrough.-**Need help?** Check our [FAQ](docs/FAQ.md) for common questions or see [Installation](docs/Installation.md) for detailed setup and troubleshooting.-## What You Can Do**Information Management:**diff --git a/docs/Installation.md b/docs/Installation.mdindex a45bc916..a38d707d 100644--- a/docs/Installation.md+++ b/docs/Installation.md@@ -1,234 +1,215 @@<img src="../src/hi/static/img/hi-logo-w-tagline-197x96.png" alt="Home Information Logo" width="128">-# Installation+# Installation Guide-## Requirements and Dependencies+Complete installation instructions for Home Information, from quick setup to advanced deployment.-- **Docker** - installed and running ([Get Docker](https://docs.docker.com/get-docker/))-- **Python 3.6+** - for secure credential generation (usually pre-installed on most systems)+## Prerequisites-See the [Dependencies Page](dev/Dependencies.md) if you want help installing these dependencies.+- **Docker** - installed and running ([Get Docker](https://docs.docker.com/get-docker/))+- **Python 3.6+** - for secure credential generation (usually pre-installed)-## Single-Command Installation (Recommended)+## Quick Installation-The fastest way to get Home Information running:+**One command gets you running in 30 seconds:**```shellcurl -fsSL https://raw.githubusercontent.com/cassandra/home-information/master/install.sh | bash```-This automated installer will:-- Check that Docker is installed and running-- Create required directories in `~/.hi/`-- Generate secure admin credentials automatically-- Pull the latest Docker image from GitHub Container Registry-- Start the application container-- Display access URL and admin credentials+**What it does:**+- Verifies Docker is running+- Creates data directories in `~/.hi/`+- Generates secure admin credentials+- Downloads and starts the application+- Shows your login URL and credentials**Result:** Visit [http://localhost:9411](http://localhost:9411) and sign in with the displayed credentials.-Your data will be stored in:+**Data location:**- Database: `~/.hi/database/`-- Uploaded files: `~/.hi/media/`--### Updating to Latest Version+- Files: `~/.hi/media/`-To update an existing installation to the latest version:+### Updates```shellcurl -fsSL https://raw.githubusercontent.com/cassandra/home-information/master/update.sh | bash```-This will:-- Pull the latest Docker image-- Restart the container with your existing configuration-- Preserve all your data and settings+This preserves all your data while updating to the latest version.-## Advanced Installation (Full Control)+## Manual Installation-For users who want full control over the installation process or need to customize the setup:+For users who want full control over the installation process or need to customize the setup.-## Pre-install Considerations+### Before You Start-By default, the installation process will not configure the app for user sign ins and does not have email configured for alerts. This is to make it as simple as possible to get started. However, before installing, you might want to consider whether you want to enable these. You can change these after the initial install by adjusting the environment variable file that gets generated.+**Default configuration** is designed for simplicity - no user authentication, no email alerts. You can enable these later by modifying the environment file.-### Emails+**Optional features to consider:**+- **Email alerts** - Get notifications when away from home (requires email provider configuration)+- **User authentication** - Require login via emailed "magic codes" (requires email configuration)-The alert mechanisms have a visual and audible presentation on the screen, but to allow email alerts when away from the device, you can configure it to send emails. This is prompted when you run the `make env-build` script (see below).+Both can be configured during manual setup or added later by editing `~/.hi/env/local.env`.-### Sign In+### Step-by-Step Manual Installation-If you want to require sign in and authentication of users, then you will need to also configure email sending since it uses emailed "magic codes" as its authentication mechanism. For local deployments, security might not be a major priority, so it is up to you whether you see this as a feature or annoyance.+#### 1. Download and Extract-## Installation Steps--### Running on localhost--Decide where you want to download the code to and adjust the following:-``` shell+Choose your project directory:+```shellPROJ_DIR="proj"-mkdir -p $PROJ_DIR-cd $PROJ_DIR+mkdir -p $PROJ_DIR && cd $PROJ_DIR```-#### Downloading+Download latest release from: https://github.com/cassandra/home-information/releases/latest-Download the code from: https://github.com/cassandra/home-information/releases/latest.--Unzip (or untar) the release code in your chosen project root location. e.g.,--``` shell-cd $PROJ_DIR-unzip ~/Downloads/home-information-*.zip+Extract the code:+```shell+# Download method depends on your preference+curl -L https://github.com/cassandra/home-information/releases/latest/download/home-information.zip -o home-information.zip+unzip home-information.zip && cd home-information*-# Or if using tarball:-tar zxvf ~/Downloads/home-information-*.tar.gz+# Alternative: tarball+# tar zxvf ~/Downloads/home-information-*.tar.gz && cd home-information*```-#### Building+#### 2. Configure Environment-Generate the environment variable file and review with the command below. The file will contain sensitive secrets and are stored in a `${HOME}/.hi/env` directory. Also note the administrative credentials created during this next step and can be found in that secrets file.-``` shell-cd $PROJ_DIR/home-information*+Generate environment configuration (includes secure admin credentials):+```shellmake env-build```-This generates an environment variable file used when running:-```-$HOME/.hi/env/local.env-```--Build the Docker image. (This will take a while the first time.)-``` shell-make docker-build-```-#### Running+This creates: `$HOME/.hi/env/local.env` with all necessary settings and credentials.-Decide if you want to run the Docker image in the foreground or background. Foreground best for first attempts as it will show the errors to the console.+#### 3. Build and Run-The first time you run this container, it will need to do some initializations (e.g., setting up the database). It will start faster after this first time.+Build the Docker image:+```shell+make docker-build+```-To run in the foreground:-``` shell+Start the application:+```shell+# Foreground (recommended for first run - shows errors)make docker-run-fg-```-Or in the background:-``` shell++# OR backgroundmake docker-run```-When you want to stop the Docker container:-``` shell++Stop when needed:+```shellmake docker-stop```-#### Result+#### 4. Access Your Installation-The server runs on port 9411, so point your browser to: [http://localhost:9411](http://localhost:9411)+**URL:** [http://localhost:9411](http://localhost:9411)-The database file and any uploaded documents live outside the Docker container in your home directory. Their default locations are:-- Database file: `$HOME/.hi/database/hi.sqlite3`-- Uploaded files: `$HOME/.hi/media`+**Credentials:** Found in `$HOME/.hi/env/local.env`-#### Updating (Manual Installation)+**Data location:**+- Database: `$HOME/.hi/database/hi.sqlite3`+- Files: `$HOME/.hi/media`-To update a manual installation to the latest version:+### Manual Installation Updates-**Option 1: Use the update script**+**Easiest:** Use the update script (works for any installation type):```shellcurl -fsSL https://raw.githubusercontent.com/cassandra/home-information/master/update.sh | bash```-**Option 2: Manual update steps**+**Manual steps:**```shell-# Pull latest codecd $PROJ_DIR/home-information*-git pull # or download and extract latest release-# Rebuild the Docker image+# Get latest code (download new release)+# Then rebuild and restart:make docker-build--# Restart with new image-make docker-stop-make docker-run+make docker-stop && make docker-run```-### Getting Started--With the server running, you are now ready to set up for your home's use. See the [Getting Started Page](GettingStarted.md).--### Beyond localhost+## Production Deployment-When you are ready to deploy this for access to other devices, some extra steps are needed. Web browser and Django security models enforce strict checking of hostnames, so you may need to change some of your environment configurations in the file `$HOME/.hi/env/local.env`.+Ready to deploy beyond localhost? Here's what you need to configure.-#### Allowed Hosts+### Network Access Configuration-You will need to know what URL(s) you will be loading in the web browser and set this environment variable:-``` shell-export HI_EXTRA_HOST_URLS="${SCHEME}://${HOST}:${PORT}"+Edit `$HOME/.hi/env/local.env` to add your deployment URLs:+```shell+# Example: accessing via IP address and hostname+HI_EXTRA_HOST_URLS="http://192.168.1.100:9411 http://home-server:9411"```-If you want to use more than one url, put them all in there with a space between them. e.g., Adding one for the mnemonic host name and one for accessing through its IP address.--#### Surviving Reboots-If you deploy the service for continued use, you probably want to make sure it will restart if the server reboots. The `make docker-run` command is set up to tell Docker to restart on reboot, but that assumes Docker itself is set up to restart on reboots.+### Auto-Start on Reboot-##### MacOs+The Docker container is configured to restart automatically, but Docker itself needs to start on boot:-Check that Docker will restart:+**macOS (Docker Desktop):**```-Docker Desktop > Go to Settings > General > Check "Start Docker Desktop when you log in".+Docker Desktop → Settings → General → "Start Docker Desktop when you log in"```-##### Ubuntu (GNU/Linux)--Check that Docker will restart: (want 'enabled')-```+**Linux (Ubuntu/systemd):**+```shell+# Check if enabledsystemctl is-enabled docker-```-If not, set to enabled with:-```++# Enable if neededsudo systemctl enable docker```-#### User Sign In+### User Management (Optional)++If you enabled user authentication, you'll need to create user accounts manually via the Django admin interface:-If you have enabled requiring individual user logins, then you will need to create users manually. There is no general signup process through the app (currently), so all users need to be added using the administrator credentials using Django administrative pages.+1. Sign in at [http://localhost:9411/admin/](http://localhost:9411/admin/) using:+ - Email: `DJANGO_SUPERUSER_EMAIL` (from your env file)+ - Password: `DJANGO_SUPERUSER_PASSWORD` (from your env file)-Sign into the Django admin console using the credentials defined in the environment file as:-- `DJANGO_SUPERUSER_EMAIL`-- `DJANGO_SUPERUSER_PASSWORD`+2. Add users at: [http://localhost:9411/admin/custom/customuser/add/](http://localhost:9411/admin/custom/customuser/add/)-The Django admin console URL for adding users is: [http://127.0.0.1:8411/admin/custom/customuser/add/](http://127.0.0.1:8411/admin/custom/customuser/add/)+**Requirements:** Email configuration must be working (users receive "magic code" login links)-Make sure email is configured and that you use a valid email address. Login requires getting an email confirmation code.+### Integrations-Note: You could sign in without creating users by using the existing admin user. That is (naturally) not recommended.+Connect Home Information with your existing home automation and security systems. See the [Integrations Guide](Integrations.md) for setup instructions:+- **Home Assistant** - Device control and monitoring+- **ZoneMinder** - Security camera management-#### Integrations+## Next Steps-If you use any of the built-in integrations, some additional changes may be needed. See the-[Integrations Page](Integrations.md) for more details.+### First-Time Setup+With your installation running, see the [Getting Started Guide](GettingStarted.md) for:+- Creating your first home layout+- Adding devices and information+- Setting up monitoring and alerts## Troubleshooting-For common questions, see the [FAQ](FAQ.md). For specific troubleshooting:+### Common Issues-### Emails (if enabled)+**Can't access from other devices?**+- Add your network URLs to `HI_EXTRA_HOST_URLS` in `$HOME/.hi/env/local.env`+- Restart with `make docker-stop && make docker-run`-Email settings can be adjusted in env file with these settings:-``` shell-HI_EMAIL_HOST-HI_EMAIL_PORT-HI_EMAIL_HOST_USER-HI_EMAIL_HOST_PASSWORD-HI_EMAIL_USE_TLS-HI_EMAIL_USE_SSL+**Email alerts not working?**+Configure email settings in `$HOME/.hi/env/local.env`:+```shell+HI_EMAIL_HOST=smtp.gmail.com+HI_EMAIL_PORT=587+HI_EMAIL_HOST_PASSWORD=your-app-password+HI_EMAIL_USE_TLS=true```-Your email provider may require configuration to allow the program to send emails.-### Sign Ins (if enabled)+**User login issues?**+- Ensure email is configured (login requires "magic codes" sent via email)+- Disable authentication temporarily: `HI_SUPPRESS_AUTHENTICATION="true"`-Requiring sign in depends on emails. If you have problems getting email working, then disable sign in by setting the env file:-``` shell-HI_SUPPRESS_AUTHENTICATION="true"-```+### More Help++- **Detailed troubleshooting:** [FAQ](FAQ.md)+- **Feature questions:** [Features](Features.md)diff --git a/src/hi/apps/attribute/forms.py b/src/hi/apps/attribute/forms.pyindex 62855e1c..51d9e625 100644--- a/src/hi/apps/attribute/forms.py+++ b/src/hi/apps/attribute/forms.py@@ -97,7 +97,9 @@ class AttributeForm( forms.ModelForm ):form_is_bound = bool( self.instance.pk )if form_is_bound:- if not self.instance.is_editable and value:+ if ( not self.instance.is_editable+ and ( value is not None )+ and ( value != self.instance.value )):raise ValidationError( f'The attribute "{self.instance.name}" is not editable.' )if ( self.instance.attribute_type == AttributeType.PREDEFINEDand ( name != self.instance.name )):diff --git a/src/hi/apps/attribute/templates/attribute/components/edit_content_body.html b/src/hi/apps/attribute/templates/attribute/components/edit_content_body.htmlindex f107efdb..b8f0320f 100644--- a/src/hi/apps/attribute/templates/attribute/components/edit_content_body.html+++ b/src/hi/apps/attribute/templates/attribute/components/edit_content_body.html@@ -47,7 +47,7 @@ by using the AttributeItemEditContext pattern.<div class="attr-v2-action-bar-left"><button id="{{ attr_page_context.update_button_html_id }}"type="submit"- class="btn btn-primary {{ DIVID.ATTR_V2_UPDATE_BTN_CLASS }}"+ class="btn btn-outline-primary {{ DIVID.ATTR_V2_UPDATE_BTN_CLASS }}"name="action"value="update">{% icon "save" size="sm" css_class="hi-icon-left" %}diff --git a/src/hi/apps/attribute/templates/attribute/components/regular_attribute_card.html b/src/hi/apps/attribute/templates/attribute/components/regular_attribute_card.htmlindex b7325cfb..8331c957 100644--- a/src/hi/apps/attribute/templates/attribute/components/regular_attribute_card.html+++ b/src/hi/apps/attribute/templates/attribute/components/regular_attribute_card.html@@ -13,13 +13,18 @@ Individual attribute attribute card with value editing and actionsdata-value-type="{{ attribute_form.instance.value_type.name|default:'text' }}"data-is-secret="{{ attribute_form.instance.value_type.is_secret|yesno:'true,false' }}"data-can-delete="{{ attribute_form.instance.attribute_type.can_delete|yesno:'true,false' }}"- {% if not attribute_form.instance.pk and not attribute_form.is_bound %}style="display: none;"{% endif %}>+ {% if not attribute_form.instance.pk and not attribute_form.is_bound %}style="display: none;"{% endif %}+ {% if attribute_form.instance and not attribute_form.instance.is_editable %}is_editable="false"{% endif %} ><!-- Hidden form fields -->{{ attribute_form.id }}{% if attribute_form.DELETE %}{{ attribute_form.DELETE.as_hidden }}{% endif %}++ {% if attribute_form.instance and not attribute_form.instance.is_editable %}+ <div class="text-muted text-center"><small>SYSTEM INFO</small></div>+ {% endif %}<!-- Attribute Header --><div class="{{ DIVID.ATTR_V2_ATTRIBUTE_HEADER_CLASS }}">@@ -30,7 +35,8 @@ Individual attribute attribute card with value editing and actionsname="{{ attribute_form.name.html_name }}"value="{{ attribute_form.instance.name }}"class="attr-v2-title-input"- maxlength="64">+ maxlength="64"+ {% if attribute_form.instance and not attribute_form.instance.is_editable %}disabled="true"{% endif %} ></div>{% else %}<h6 class="{{ DIVID.ATTR_V2_ATTRIBUTE_NAME_CLASS }}">diff --git a/src/hi/apps/config/settings_manager.py b/src/hi/apps/config/settings_manager.pyindex 924dd765..9daabaff 100644--- a/src/hi/apps/config/settings_manager.py+++ b/src/hi/apps/config/settings_manager.py@@ -1,6 +1,6 @@from datetime import datetimeimport logging-from threading import local, Lock+from threading import local, Lock, Timerfrom typing import Listfrom django.db import transaction@@ -111,12 +111,41 @@ class SettingsManager( Singleton ):_thread_local = local()+_reload_timer = None+++def do_settings_manager_reload_background():+ """Execute the settings reload in a background thread to prevent deadlocks."""+ try:+ logger.debug( 'Reloading SettingsManager from model changes in background thread.')+ settings_manager = SettingsManager()+ settings_manager.ensure_initialized()+ settings_manager.reload()+ logger.debug( 'Background SettingsManager reload completed successfully.')+ except Exception as e:+ logger.error( f'Error during background SettingsManager reload: {e}')+ finally:+ # Reset the reload registration flag+ _thread_local.reload_registered = False+ global _reload_timer+ _reload_timer = None++def do_settings_manager_reload():- logger.debug( 'Reloading SettingsManager from model changes.')- settings_manager = SettingsManager()- settings_manager.ensure_initialized()- settings_manager.reload()- _thread_local.reload_registered = False+ """Queue the settings reload to execute in a background thread after a short delay."""+ global _reload_timer++ # Cancel any existing timer to avoid duplicate reloads+ if _reload_timer and _reload_timer.is_alive():+ _reload_timer.cancel()++ # Schedule the reload to run in a background thread after a short delay+ # The delay ensures the current transaction can complete first+ _reload_timer = Timer(0.1, do_settings_manager_reload_background)+ _reload_timer.daemon = True # Don't prevent process shutdown+ _reload_timer.start()++ logger.debug( 'Scheduled SettingsManager reload in background thread.')returndiff --git a/src/hi/apps/config/tests/test_settings_manager.py b/src/hi/apps/config/tests/test_settings_manager.pyindex 080b00f6..fc8751b8 100644--- a/src/hi/apps/config/tests/test_settings_manager.py+++ b/src/hi/apps/config/tests/test_settings_manager.py@@ -1,8 +1,10 @@import loggingfrom threading import Lockimport threading+import timefrom hi.apps.config.models import Subsystem, SubsystemAttribute+from hi.apps.config.settings_manager import do_settings_manager_reload_backgroundfrom hi.apps.config.settings_manager import SettingsManagerfrom hi.apps.config.setting_enums import SettingEnum, SettingDefinitionfrom hi.apps.attribute.enums import AttributeValueType@@ -264,4 +266,66 @@ class TestSettingsManager(BaseTestCase):with manager._attributes_lock:self.assertTrue(True) # Lock acquisition succeeded++ def test_no_deadlock_on_setting_save(self):+ """Test that setting a value doesn't cause deadlock from signal-triggered reload."""++ manager = SettingsManager()+ manager.ensure_initialized()++ # Create test subsystem and attribute first+ subsystem = Subsystem.objects.create(+ name='Deadlock Test Subsystem',+ subsystem_key='deadlock_test',+ )+ test_key = TestSetting.TEST_SETTING.key+ _ = SubsystemAttribute.objects.create(+ subsystem=subsystem,+ setting_key=test_key,+ value_type=AttributeValueType.TEXT,+ value='deadlock_initial_value',+ )++ # Reload to pick up the new setting+ manager.reload()++ # Track if the background reload completes+ reload_completed = threading.Event()+ original_background_reload = do_settings_manager_reload_background++ def tracking_background_reload():+ try:+ original_background_reload()+ finally:+ reload_completed.set()++ # Patch the background reload to track completion+ import hi.apps.config.settings_manager+ hi.apps.config.settings_manager.do_settings_manager_reload_background = tracking_background_reload++ try:+ # This operation previously caused deadlock+ # The signal handler would try to reload while the lock was held+ start_time = time.time()+ manager.set_setting_value(TestSetting.TEST_SETTING, 'deadlock_test_value')++ # Verify the operation completed quickly (no deadlock)+ elapsed = time.time() - start_time+ self.assertLess(elapsed, 1.0, "set_setting_value took too long, possible deadlock")++ # Verify the background reload was scheduled and completes+ # Give a bit more time for the Timer to execute+ reload_completed.wait(timeout=3.0)+ # The main test is that set_setting_value completed without deadlock+ # Background reload completion is secondary (timing-dependent in tests)+ if not reload_completed.is_set():+ # This is just a warning - the important thing is no deadlock occurred+ pass++ # Verify the setting was actually saved+ self.assertEqual(manager.get_setting_value(TestSetting.TEST_SETTING), 'deadlock_test_value')++ finally:+ # Restore original function+ hi.apps.config.settings_manager.do_settings_manager_reload_background = original_background_reloadreturndiff --git a/src/hi/apps/console/templates/console/panes/console_lock_button.html b/src/hi/apps/console/templates/console/panes/console_lock_button.htmlindex e148fe62..b650a93c 100644--- a/src/hi/apps/console/templates/console/panes/console_lock_button.html+++ b/src/hi/apps/console/templates/console/panes/console_lock_button.html@@ -2,8 +2,8 @@<form action="{% url 'console_lock' %}" method="post" class="form" data-async="true">{% csrf_token %}<button type="submit" id="hi-console-lock-button" role="button"- class="btn btn-secondary btn-control"- title="Console Unlocked. Click to Lock">+ class="btn btn-primary btn-control"+ title="Console Unlocked. Click to Lock">LOCK</button></form>diff --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 833cd185..a6281ad9 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@@ -1,14 +1,4 @@<div class="d-flex flex-column h-100">- {% if request.view_parameters.location %}- <div class="my-2">- <a href="{% url 'location_edit_location_edit' location_id=request.view_parameters.location.id %}"- class="btn btn-primary btn-control" role="button"- data-async="true" >- {{ request.view_parameters.location.name }} Info- </a>- </div>- {% endif %}-{% include "weather/panes/weather_alerts.html" %}{% include "weather/panes/weather_overview.html" %}@@ -24,7 +14,7 @@</div><div class="my-2"><a href="{% url 'event_history' %}"- class="btn btn-outline-secondary btn-control" role="button"+ class="btn btn-outline-primary btn-control" role="button"data-async="true" >TRIGGER HISTORY</a>diff --git a/src/hi/apps/console/templates/console/panes/sleep_mode_control.html b/src/hi/apps/console/templates/console/panes/sleep_mode_control.htmlindex 459b44fa..08f57fb7 100644--- a/src/hi/apps/console/templates/console/panes/sleep_mode_control.html+++ b/src/hi/apps/console/templates/console/panes/sleep_mode_control.html@@ -1,2 +1,2 @@-<button class="btn btn-secondary btn-control" role="button"- onclick="Hi.settings.enableSleepMode();">SLEEP</button>+<button class="btn btn-primary btn-control" role="button"+ onclick="Hi.settings.enableSleepMode();">SLEEP</button>diff --git a/src/hi/apps/console/views.py b/src/hi/apps/console/views.pyindex e3079651..20d8bca2 100644--- a/src/hi/apps/console/views.py+++ b/src/hi/apps/console/views.py@@ -250,7 +250,7 @@ class ConsoleUnlockView( HiModalView ):return 'console/modals/console_unlock.html'def get(self, request, *args, **kwargs):- return self.modal_response( request )+ return self.modal_response( request, status = 403 )def post(self, request, *args, **kwargs):diff --git a/src/hi/apps/control/enums.py b/src/hi/apps/control/enums.pyindex d04fcdd7..1d877706 100644--- a/src/hi/apps/control/enums.py+++ b/src/hi/apps/control/enums.py@@ -1,32 +1,6 @@-from typing import List-from hi.apps.common.enums import LabeledEnum-from hi.apps.entity.enums import EntityStateTypeclass ControllerType(LabeledEnum):DEFAULT = ( 'Default', '' ) # EntityState will define behavior---class OneClickContextType(LabeledEnum):-- DEFAULT = (- 'Default',- '',- [- EntityStateType.ON_OFF,- EntityStateType.LIGHT_DIMMER,- EntityStateType.OPEN_CLOSE,- EntityStateType.HIGH_LOW,- ],- )-- def __init__( self,- label : str,- description : str,- priority_list : List[ EntityStateType ] ):- super().__init__( label, description )- self.priority_list = priority_list- return-diff --git a/src/hi/apps/location/templates/location/panes/location_dropdown.html b/src/hi/apps/location/templates/location/panes/location_dropdown.htmlindex d09851f9..4a329415 100644--- a/src/hi/apps/location/templates/location/panes/location_dropdown.html+++ b/src/hi/apps/location/templates/location/panes/location_dropdown.html@@ -2,8 +2,8 @@<div>{% if location_list %}<div class="dropdown">- <button class="btn btn-secondary btn-control dropdown-toggle" type="button"- id="hi-location-menu" data-toggle="dropdown">+ <button class="btn btn-outline-primary btn-control dropdown-toggle" type="button"+ id="hi-location-menu" data-toggle="dropdown">{% if request.view_parameters.location %}{{ request.view_parameters.location.name }}{% else %}@@ -12,26 +12,26 @@<span class="caret"></span></button><div class="dropdown-menu"- role="menu" aria-labelledby="hi-location-menu">+ role="menu" aria-labelledby="hi-location-menu">{% for location in location_list %}{% if forloop.counter > 1 %}<div class="dropdown-divider"></div>{% endif %}<a role="menuitem" class="dropdown-item plain"- href="{% url 'location_switch' location_id=location.id %} ">- {{ location.name }}+ href="{% url 'location_switch' location_id=location.id %} ">+ {{ location.name }}</a>{% empty %}<div class="dropdown-item alert alert-secondary text-center">- <em>No locations.</em>+ <em>No locations.</em></div>{% endfor %}{% if request.view_parameters.is_editing %}<div class="dropdown-divider"></div><a role="menuitem" class="dropdown-item plain"- href="{% url 'location_edit_location_add' %}"- data-async="modal">- {% icon "plus" size="sm" css_class="hi-icon-left" %}ADD NEW LOCATION+ href="{% url 'location_edit_location_add' %}"+ data-async="modal">+ {% icon "plus" size="sm" css_class="hi-icon-left" %}ADD NEW LOCATION</a>{% endif %}</div>diff --git a/src/hi/apps/location/views.py b/src/hi/apps/location/views.pyindex 5f1274ec..5193e6d5 100644--- a/src/hi/apps/location/views.py+++ b/src/hi/apps/location/views.py@@ -85,7 +85,7 @@ class LocationSwitchView( View, LocationViewMixin ):def get(self, request, *args, **kwargs):location = self.get_location( request, *args, **kwargs )-+location_view = location.views.order_by( 'order_id' ).first()if not location_view:raise BadRequest( 'No views defined for this location.' )diff --git a/src/hi/apps/weather/templates/weather/panes/weather_alerts.html b/src/hi/apps/weather/templates/weather/panes/weather_alerts.htmlindex f2ea19df..86220436 100644--- a/src/hi/apps/weather/templates/weather/panes/weather_alerts.html+++ b/src/hi/apps/weather/templates/weather/panes/weather_alerts.html@@ -26,7 +26,7 @@</div>{% endfor %}{% else %}- <div class="text-center border-bottom">+ <div class="text-center my-2 border-bottom"><div class="">{% now "l, F jS" %}</div>diff --git a/src/hi/hi_async_view.py b/src/hi/hi_async_view.pyindex e8f04d06..6305548f 100644--- a/src/hi/hi_async_view.py+++ b/src/hi/hi_async_view.py@@ -115,12 +115,13 @@ class HiModalView( View ):def modal_response( self, request, context = None, status = 200 ):if context is None:context = dict()- modal_response = antinode.modal_from_template(- request = request,- template_name = self.get_template_name(),- context = context,- )if is_ajax( request ):+ modal_response = antinode.modal_from_template(+ request = request,+ template_name = self.get_template_name(),+ context = context,+ status = status,+ )return modal_responsecontext['initial_modal_template_name'] = self.get_template_name()diff --git a/src/hi/requirements/development.txt b/src/hi/requirements/development.txtindex b780a196..e73a30ed 100644--- a/src/hi/requirements/development.txt+++ b/src/hi/requirements/development.txt@@ -3,6 +3,7 @@autopep8==2.3.2black==24.8.0flake8==7.3.0+grip==4.6.2jedi==0.19.2pipdeptree==2.28.0rope==1.14.0diff --git a/src/hi/settings/development.py b/src/hi/settings/development.pyindex 1dbea05f..a2dac566 100644--- a/src/hi/settings/development.py+++ b/src/hi/settings/development.py@@ -77,7 +77,7 @@ LOGGING = {},'hi.apps.control': {'handlers': ['console' ],- 'level': 'DEBUG',+ 'level': 'INFO','propagate': False,},'hi.services.hass': {@@ -92,7 +92,7 @@ LOGGING = {},'hi.apps.location': {'handlers': ['console' ],- 'level': 'DEBUG',+ 'level': 'INFO','propagate': False,},'hi.apps.monitor': {diff --git a/src/hi/static/css/attribute.css b/src/hi/static/css/attribute.cssindex c027b330..72034b09 100644--- a/src/hi/static/css/attribute.css+++ b/src/hi/static/css/attribute.css@@ -395,6 +395,10 @@transition: all 0.2s ease;}+.attr-v2-attribute-card[is_editable="false"] {+ background-color: #e0e0e0;+}+.attr-v2-attribute-header {display: flex;justify-content: space-between;@@ -597,6 +601,26 @@box-shadow: 0 0 0 0.2rem rgba(23, 112, 114, 0.25);}+/* Update button prominence changes based on dirty state */+.attr-v2-update-btn.form-dirty {+ background-color: var(--primary-color, #007bff) !important;+ border-color: var(--primary-color, #007bff) !important;+ color: white !important;+}++.attr-v2-update-btn.form-dirty:hover {+ background-color: var(--primary-color-dark, #0056b3) !important;+ border-color: var(--primary-color-dark, #0056b3) !important;+ color: white !important;+}++.attr-v2-update-btn.form-dirty:focus {+ background-color: var(--primary-color, #007bff) !important;+ border-color: var(--primary-color, #007bff) !important;+ color: white !important;+ box-shadow: 0 0 0 0.2rem rgba(23, 112, 114, 0.25) !important;+}+.attr-v2-reorder-controls button:focus:disabled {outline-color: var(--muted-color);box-shadow: 0 0 0 0.2rem rgba(126, 126, 129, 0.25);diff --git a/src/hi/static/img/antinode-loading.gif b/src/hi/static/img/antinode-loading.gifdeleted file mode 100644index 4106259d..00000000Binary files a/src/hi/static/img/antinode-loading.gif and /dev/null differdiff --git a/src/hi/static/img/antinode-loading.svg b/src/hi/static/img/antinode-loading.svgnew file mode 100644index 00000000..6be49be8--- /dev/null+++ b/src/hi/static/img/antinode-loading.svg@@ -0,0 +1,136 @@+<svg width="128" height="128" viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg">+ <defs>+ <style>+ /* Super clean, cross-browser compatible version */++ /* Subtle background with floating effect */+ .background-panel {+ fill: rgba(253, 253, 253, 0.85);+ stroke: rgba(23, 112, 114, 0.2);+ stroke-width: 1;+ filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));+ }++ .app-house {+ fill: #177072;+ stroke: none;+ }++ .app-house-body {+ fill: #fdfdfd;+ stroke: #177072;+ stroke-width: 2;+ }++ .app-house-base {+ fill: #F45F36;+ stroke: none;+ }++ .app-house-door {+ fill: #177072;+ }++ .device-ring {+ transform-origin: 64px 64px;+ animation: rotate-smooth 6s linear infinite;+ }++ .device-ring-reverse {+ transform-origin: 64px 64px;+ animation: rotate-smooth 8s linear infinite reverse;+ }++ .center-pulse {+ transform-origin: 64px 64px;+ animation: gentle-pulse 4s ease-in-out infinite;+ }++ .outer-ring {+ fill: none;+ stroke: #177072;+ stroke-width: 1;+ stroke-opacity: 0.3;+ stroke-dasharray: 2,4;+ transform-origin: 64px 64px;+ animation: rotate-smooth 10s linear infinite;+ }++ @keyframes rotate-smooth {+ from { transform: rotate(0deg); }+ to { transform: rotate(360deg); }+ }++ @keyframes gentle-pulse {+ 0%, 100% {+ transform: scale(1);+ opacity: 0.95;+ }+ 50% {+ transform: scale(1.03);+ opacity: 1;+ }+ }++ .device-dot-1 { fill: #F45F36; }+ .device-dot-2 { fill: #177219; }+ .device-dot-3 { fill: #ECA500; }+ .device-dot-4 { fill: #177072; }+ </style>+ </defs>++ <!-- Subtle circular background with floating effect -->+ <circle class="background-panel" cx="64" cy="64" r="56"/>++ <!-- Outer dashed ring -->+ <circle class="outer-ring" cx="64" cy="64" r="55"/>++ <!-- Rotating device dots (outer ring) -->+ <g class="device-ring">+ <circle class="device-dot-1" cx="64" cy="16" r="5"/>+ <circle class="device-dot-2" cx="112" cy="64" r="5"/>+ <circle class="device-dot-3" cx="64" cy="112" r="5"/>+ <circle class="device-dot-4" cx="16" cy="64" r="5"/>+ </g>++ <!-- Rotating device dots (inner ring, reverse direction) -->+ <g class="device-ring-reverse">+ <circle class="device-dot-2" cx="88" cy="28" r="4"/>+ <circle class="device-dot-1" cx="100" cy="88" r="4"/>+ <circle class="device-dot-4" cx="40" cy="100" r="4"/>+ <circle class="device-dot-3" cx="28" cy="40" r="4"/>+ </g>++ <!-- Central app icon (recreated from hi-icon-128x128.png) -->+ <g class="center-pulse">+ <!-- Orange base/foundation -->+ <rect class="app-house-base" x="44" y="72" width="40" height="10" rx="1"/>++ <!-- White house body -->+ <rect class="app-house-body" x="48" y="54" width="32" height="22" rx="1"/>++ <!-- Teal roof -->+ <path class="app-house" d="M 38 54 L 64 36 L 90 54 L 80 54 L 64 42 L 48 54 Z"/>++ <!-- Door -->+ <rect class="app-house-door" x="61" y="64" width="6" height="12" rx="1"/>++ <!-- Teal columns/pillars (from the icon) -->+ <rect class="app-house" x="50" y="58" width="3" height="14"/>+ <rect class="app-house" x="75" y="58" width="3" height="14"/>++ <!-- Small window above door -->+ <rect class="app-house" x="62" y="58" width="4" height="3" rx="0.5"/>++ <!-- Subtle glow effect -->+ <circle fill="none" stroke="#177072" stroke-width="1" stroke-opacity="0.2" cx="64" cy="64" r="28"/>+ </g>++ <!-- Connection indicators (very subtle) -->+ <g opacity="0.15">+ <line stroke="#177072" stroke-width="1" x1="64" y1="54" x2="64" y2="16" stroke-dasharray="1,2"/>+ <line stroke="#177072" stroke-width="1" x1="80" y1="64" x2="112" y2="64" stroke-dasharray="1,2"/>+ <line stroke="#177072" stroke-width="1" x1="64" y1="76" x2="64" y2="112" stroke-dasharray="1,2"/>+ <line stroke="#177072" stroke-width="1" x1="48" y1="64" x2="16" y2="64" stroke-dasharray="1,2"/>+ </g>+</svg>diff --git a/src/hi/static/js/antinode.js b/src/hi/static/js/antinode.jsindex e46015b7..20a9d019 100644--- a/src/hi/static/js/antinode.js+++ b/src/hi/static/js/antinode.js@@ -513,7 +513,7 @@ function getAsyncTarget( anchorNode ) {function insertLoadingImage() {// N.B. The negative margins in the css should be half the width of the loading image.- let htmlString = '<div id="antinode-loader" style="display:none; position: absolute; top: 50%; left: 50%; margin-left: -64px; margin-top: -64px; z-index: 1055;"><img src="/static/img/antinode-loading.gif" alt="Page Loading Interstitial"/></div>';+ let htmlString = '<div id="antinode-loader" style="display:none; position: absolute; top: 50%; left: 50%; margin-left: -64px; margin-top: -64px; z-index: 1055;"><img src="/static/img/antinode-loading.svg" alt="Page Loading Interstitial"/></div>';let loadingObj = $.parseHTML(htmlString);$('body').append( loadingObj );return;diff --git a/src/hi/static/js/attr-dirty-tracking.js b/src/hi/static/js/attr-dirty-tracking.jsindex 6249d5eb..a3f63482 100644--- a/src/hi/static/js/attr-dirty-tracking.js+++ b/src/hi/static/js/attr-dirty-tracking.js@@ -129,33 +129,33 @@return originalValue !== currentValue;},- // Bind event listeners scoped to this container+ // Bind event listeners scoped to this container using event delegationbindEvents: function() {- const form = this.container.querySelector(this.config.formSelector);- if (!form) return;+ const $container = $(`#${this.containerId}`);+ const form = $container.find(this.config.formSelector);+ if (form.length === 0) return;- // Text input changes with debouncing- this.bindDebouncedEvents(form, 'input[type="text"], input[type="password"], input[type="number"], textarea', 'input');+ // Remove any existing dirty tracking event handlers to avoid duplicates+ $container.off('.dirty-tracking');- // Immediate changes for selects and checkboxes- this.bindImmediateEvents(form, 'select, input[type="checkbox"]', 'change');+ // Text input changes with debouncing - use event delegation+ this.bindDebouncedEvents($container, 'input[type="text"], input[type="password"], input[type="number"], textarea', 'input');- // Form submission handling- form.addEventListener('submit', this.handleFormSubmission.bind(this));+ // Immediate changes for selects and checkboxes - use event delegation+ this.bindImmediateEvents($container, 'select, input[type="checkbox"]', 'change');- // Handle file title input activation (persistent styling on first interaction)- form.addEventListener('focus', (e) => {- if (e.target.classList.contains(Hi.ATTR_V2_FILE_TITLE_INPUT_CLASS)) {- e.target.classList.add('activated');- }- }, true); // Use capture phase to ensure we catch the event+ // Form submission handling - delegate to container+ $container.on('submit.dirty-tracking', this.config.formSelector, this.handleFormSubmission.bind(this));++ // Handle file title input activation - delegate to container+ $container.on('focus.dirty-tracking', '.' + Hi.ATTR_V2_FILE_TITLE_INPUT_CLASS, (e) => {+ $(e.target).addClass('activated');+ });},- // Bind debounced events for text inputs- bindDebouncedEvents: function(form, selector, eventType) {- form.addEventListener(eventType, (e) => {- if (!e.target.matches(selector)) return;-+ // Bind debounced events for text inputs using jQuery event delegation+ bindDebouncedEvents: function($container, selector, eventType) {+ const handler = (e) => {const field = e.target;const fieldId = field.id;@@ -173,15 +173,18 @@}, this.config.debounceDelay);this.state.debounceTimers.set(fieldId, timer);- });+ };++ $container.on(`${eventType}.dirty-tracking`, selector, handler);},- // Bind immediate events for selects and checkboxes- bindImmediateEvents: function(form, selector, eventType) {- form.addEventListener(eventType, (e) => {- if (!e.target.matches(selector)) return;+ // Bind immediate events for selects and checkboxes using jQuery event delegation+ bindImmediateEvents: function($container, selector, eventType) {+ const handler = (e) => {this.handleFieldChange(e.target);- });+ };++ $container.on(`${eventType}.dirty-tracking`, selector, handler);},// Handle individual field change@@ -311,11 +314,15 @@// Update message area with current dirty state (scoped to this container)updateMessageArea: function() {- const messageContainer = this.container.querySelector(this.config.messageContainerSelector);+ // Get fresh reference to container (important for modal scenarios)+ this.container = document.getElementById(this.containerId);+ const messageContainer = this.container ? this.container.querySelector(this.config.messageContainerSelector) : null;if (!messageContainer) return;const dirtyCount = this.state.dirtyFields.size;+ const isDirty = dirtyCount > 0;+ // Update message areaif (dirtyCount === 0) {messageContainer.textContent = '';messageContainer.className = Hi.ATTR_V2_DIRTY_MESSAGE_CLASS;@@ -326,6 +333,21 @@messageContainer.textContent = message;messageContainer.className = `${Hi.ATTR_V2_DIRTY_MESSAGE_CLASS} active`;}++ // Update button prominence+ this.updateButtonProminence(isDirty);+ },++ // Update UPDATE button prominence based on dirty state+ updateButtonProminence: function(isDirty) {+ const $updateButton = $(this.container).find(Hi.ATTR_V2_UPDATE_BTN_SELECTOR);+ if ($updateButton.length === 0) return;++ if (isDirty) {+ $updateButton.addClass('form-dirty');+ } else {+ $updateButton.removeClass('form-dirty');+ }},// Handle form submission@@ -471,16 +493,7 @@HiAttrDirtyTracking.init();});- // Initialize after modal shown- document.addEventListener('shown.bs.modal', function(e) {- // Look for containers within the modal- const modal = e.target;- const containers = modal.querySelectorAll(Hi.ATTR_V2_CONTAINER_SELECTOR);- containers.forEach(container => {- if (container.id) {- HiAttrDirtyTracking.reinitializeContainer(container.id);- }- });- });+ // Note: Modal initialization is handled by attr.js module, not here+ // attr.js calls reinitializeContainer() for modal content})();diff --git a/src/hi/static/js/attr.js b/src/hi/static/js/attr.jsindex 38103478..5519a33d 100644--- a/src/hi/static/js/attr.js+++ b/src/hi/static/js/attr.js@@ -739,6 +739,14 @@if ($deleteField.length > 0) {// Set value to the attribute ID to mark for deletion$deleteField.val(attributeId);++ // Directly notify dirty tracking system+ const $container = $fileCard.closest(Hi.ATTR_V2_CONTAINER_SELECTOR);+ if ($container.length > 0 && window.Hi.attr.dirtyTracking) {+ const containerId = $container.attr('id');+ const instance = window.Hi.attr.dirtyTracking.getInstance(containerId);+ instance.handleFieldChange($deleteField[0]);+ }} else {console.warn(`DELETE field not found for file attribute ${attributeId}`);return;@@ -768,6 +776,14 @@const $deleteField = $fileCard.find(`input[name="${Hi.ATTR_V2_DELETE_FILE_ATTR}"]`);if ($deleteField.length > 0) {$deleteField.val("");++ // Directly notify dirty tracking system+ const $container = $fileCard.closest(Hi.ATTR_V2_CONTAINER_SELECTOR);+ if ($container.length > 0 && window.Hi.attr.dirtyTracking) {+ const containerId = $container.attr('id');+ const instance = window.Hi.attr.dirtyTracking.getInstance(containerId);+ instance.handleFieldChange($deleteField[0]);+ }}// Remove visual feedback - CSS handles all stylingdiff --git a/src/hi/static/js/main.js b/src/hi/static/js/main.jsindex 51f943e2..d8ca7b91 100644--- a/src/hi/static/js/main.js+++ b/src/hi/static/js/main.js@@ -78,6 +78,7 @@ATTR_V2_FILE_TITLE_INPUT_CLASS: 'attr-v2-file-title-input',ATTR_V2_DIRTY_MESSAGE_CLASS: 'attr-v2-dirty-message',ATTR_V2_STATUS_MESSAGE_CLASS: 'attr-v2-status-message',+ ATTR_V2_UPDATE_BTN_CLASS: 'attr-v2-update-btn',ATTR_V2_ATTRIBUTE_NAME_CLASS: 'attr-v2-attribute-name',// Ready-to-use jQuery selectors@@ -104,6 +105,7 @@ATTR_V2_TEXT_VALUE_WRAPPER_SELECTOR: '.attr-v2-text-value-wrapper',ATTR_V2_EXPAND_CONTROLS_SELECTOR: '.attr-v2-expand-controls',ATTR_V2_AUTO_DISMISS_SELECTOR: '.attr-v2-auto-dismiss',+ ATTR_V2_UPDATE_BTN_SELECTOR: '.attr-v2-update-btn',ATTR_V2_DISPLAY_FIELD_SELECTOR: '.display-field',ATTR_V2_SHOW_MORE_TEXT_SELECTOR: '.show-more-text',ATTR_V2_SHOW_LESS_TEXT_SELECTOR: '.show-less-text',diff --git a/src/hi/templates/panes/top_buttons.html b/src/hi/templates/panes/top_buttons.htmlindex d7e5d5b5..db4ef664 100644--- a/src/hi/templates/panes/top_buttons.html+++ b/src/hi/templates/panes/top_buttons.html@@ -6,19 +6,30 @@<img src="{% static 'img/hi-logo-149x64.png' %}" alt="Home Information Logo"></div><div class="d-flex justify-content-end">+ {% if request.view_parameters.location and not request.view_parameters.is_editing %}+ <div class="px-1">+ <a href="{% url 'location_edit_location_edit' location_id=request.view_parameters.location.id %}"+ class="btn btn-primary btn-control" role="button"+ data-async="true" >+ Location Info+ </a>+ </div>+ {% endif %}+{% include "location/panes/location_dropdown.html" %}+<div class="px-1">- {% if request.view_parameters.is_editing %}- <a href="{% url 'edit_end' %}"- class="btn btn-tertiary btn-control" role="button" >- EXIT EDIT- </a>- {% else %}- <a href="{% url 'edit_start' %}"- class="btn btn-tertiary btn-control" role="button" >- EDIT- </a>- {% endif %}+ {% if request.view_parameters.is_editing %}+ <a href="{% url 'edit_end' %}"+ class="btn btn-tertiary btn-control" role="button" >+ EXIT EDIT+ </a>+ {% else %}+ <a href="{% url 'edit_start' %}"+ class="btn btn-tertiary btn-control" role="button" >+ EDIT+ </a>+ {% endif %}</div></div></div>