How cassandra/home-information works
Purpose and Runtime Entry Points
Home Information is a local-first Django application for spatially organizing home records, devices, controls, and security data on floor-plan/location views. HTTP entry points are the Django URL root and ASGI/WSGI servers: src/hi/urls.py, src/hi/asgi.py, src/hi/wsgi.py; src/manage.py is the management CLI. Production runs in Docker behind Nginx/Supervisor/Gunicorn (Dockerfile, package/docker_entrypoint.sh, src/bin/docker-start-gunicorn.sh).
Presentation and Spatial Workspace
The server-rendered Bootstrap/JavaScript UI centers on the reusable grid view and location-backed visual maps. Root views/templates provide the application shell; location views render and edit SVG floor plans, positioned entities, and collections.
• src/hi/hi_grid_view.py
• src/hi/apps/location/models.py
• src/hi/apps/location/svg_item_factory.py
• src/hi/apps/location/edit/views.py
Flow: browser interactions use static JS and Django routes; views invoke managers/models and return HTML fragments/pages. SVG geometry and persisted placement form the boundary between visual presentation and the domain model.
Core Home Domain
Entities represent home items/devices; locations and collections organize them; typed attributes attach documents, notes, values, thumbnails, history, and soft-delete behavior. Entity state panels select type-specific rendering for cameras, thermostats, smoke detectors, or a fallback.
• src/hi/apps/entity/models.py
• src/hi/apps/entity/entity_manager.py
• src/hi/apps/attribute/models.py
• src/hi/apps/entity/state_panel_registry.py
• src/hi/apps/collection/models.py
Integration Gateway and Synchronization
The integrations layer is the normalization boundary between third-party systems and internal entities, controllers, events, locations, and external references. Connector workflows discover/preview/synchronize remote data; importer and referencer workflows ingest or link external records. Integration metadata and identity fields allow sync reconciliation.
• src/hi/integrations/integration_gateway.py
• src/hi/integrations/integration_manager.py
• src/hi/integrations/connector/integration_connector.py
• src/hi/integrations/importer/integration_importer.py
• src/hi/integrations/referencer/integration_referencer.py
Concrete adapters support Home Assistant, Frigate, ZoneMinder, HomeBox, Immich, and Paperless-ngx under src/hi/services/, each using clients, converters, controllers/connectors, and integration registrations (for example src/hi/services/hass/integration.py, src/hi/services/frigate/frigate_connector.py).
Automation, Monitoring, and Notification Flow
Sensor updates/history feed event rules and monitor status. Event actions can invoke controllers or alarms; alert and notification queues manage user-visible/audio alarms and email delivery. Security aggregates relevant monitored state into modes/views.
• src/hi/apps/sense/sensor_response_manager.py
• src/hi/apps/event/event_manager.py
• src/hi/apps/control/controller_manager.py
• src/hi/apps/alert/alert_manager.py
• src/hi/apps/notify/notification_manager.py
• src/hi/apps/security/security_manager.py
Background Health and Weather
Periodic/background orchestration is centralized at src/hi/background_tasks.py; subsystems expose monitors and health providers aggregated into UI/API status. Weather independently discovers configured data sources, fetches/converts interval data, tracks daily aggregates, and can map weather alerts into alarms.
• src/hi/apps/system/aggregate_health_provider.py
• src/hi/apps/monitor/periodic_monitor.py
• src/hi/apps/weather/weather_manager.py
• src/hi/apps/weather/weather_source_manager.py
• src/hi/apps/weather/weather_alert_alarm_mapper.py
External weather sources include NWS, Open-Meteo, Sunrise-Sunset.org, and USNO.
Persistence, Deployment, and Simulation
Django ORM models/migrations persist application data; README specifies SQLite as the default local storage. Redis support exists in shared infrastructure (src/hi/apps/common/redis_client.py) and AWS utilities are isolated (src/hi/apps/common/aws_manager.py). Configuration is environment/Django-settings based: src/hi/settings/base.py, src/hi/settings/production.py.
A built-in simulator provides controllable substitute APIs, scenes, faults, and weather sources for development/testing without real integrations: src/hi/simulator/services/service_simulator.py, src/hi/simulator/scenes/player.py, src/hi/simulator/weather_sources/registry.py.
Main entry points: entity_manager.py Entities & managers · hi_grid_view.py Spatial workspace · models.py Locations & SVG maps · event_manager.py Events & controllers
Components 22
Runtime & UI
- Django HTTP entry points · URL root and ASGI/WSGI application servers.
src/hi/urls.py - Management CLI
src/manage.py - Spatial workspace · Grid and location views render home records on floor plans.
src/hi/hi_grid_view.py - Locations & SVG maps · Persisted locations and SVG placement bridge the visual and domain models.
src/hi/apps/location/models.py - SVG item factory
src/hi/apps/location/svg_item_factory.py
Home Domain
- Entities & managers · Home items and devices are managed as internal entities.
src/hi/apps/entity/entity_manager.py - Typed attributes · Attaches values, documents, notes, media, history, and soft-delete state.
src/hi/apps/attribute/models.py - Collections
src/hi/apps/collection/models.py - Entity state panels · Selects type-specific device state rendering.
src/hi/apps/entity/state_panel_registry.py
Integrations
- Integration gateway · Normalizes external records into internal domain concepts.
src/hi/integrations/integration_gateway.py - Sync workflows · Discovers, previews, synchronizes, imports, and links remote records.
src/hi/integrations/integration_manager.py - External service adapters · Home Assistant, Frigate, ZoneMinder, HomeBox, Immich, and Paperless-ngx adapters.
src/hi/services/hass/integration.py
Automation & Monitoring
- Sensor responses & monitors · Processes sensor updates, history, and periodic monitored state.
src/hi/apps/sense/sensor_response_manager.py - Events & controllers · Rules trigger actions that invoke controllers or alarms.
src/hi/apps/event/event_manager.py - Alerts & notifications · Queues user-visible/audio alarms and email delivery.
src/hi/apps/alert/alert_manager.py - Security status · Aggregates monitored state into security modes and views.
src/hi/apps/security/security_manager.py
Operations & Data
- Background tasks & weather · Runs subsystem work and weather source, aggregate, and alert processing.
src/hi/background_tasks.py - Aggregate health · Aggregates subsystem health for UI/API status.
src/hi/apps/system/aggregate_health_provider.py - Django ORM storage · Models and migrations persist local-first application data.
- Redis support
src/hi/apps/common/redis_client.py - Built-in simulator · Provides substitute APIs, scenes, faults, and weather sources.
src/hi/simulator/services/service_simulator.py - Production container · Docker runs behind Nginx, Supervisor, and Gunicorn.
Dockerfile
Connections 23
- Django HTTP entry points → Spatial workspace: routes requests
- Management CLI → Django ORM storage: manages
- Spatial workspace → Locations & SVG maps: renders and edits
- Locations & SVG maps → SVG item factory: builds visual items
- SVG item factory → Entities & managers: positions entities
- Spatial workspace → Entity state panels: renders state
- Entities & managers → Typed attributes: owns typed data
- Collections → Entities & managers: organizes
- Locations & SVG maps → Django ORM storage: persists placement
- Entities & managers → Django ORM storage: persists
- Sync workflows → Integration gateway: normalizes through
- External service adapters → Sync workflows: discover and sync
- Integration gateway → Entities & managers: reconciles entities
- Sensor responses & monitors → Events & controllers: feeds rules
- Events & controllers → Alerts & notifications: raises alarms
- Events & controllers → Entities & managers: invokes controllers
- Sensor responses & monitors → Security status: provides monitored state
- Background tasks & weather → Sensor responses & monitors: runs periodically
- Background tasks & weather → Alerts & notifications: maps weather alerts
- Aggregate health → Spatial workspace: exposes status
- Built-in simulator → External service adapters: substitutes external APIs
- Production container → Django HTTP entry points: serves
- Redis support → Background tasks & weather: shared support