Skip to content

Home Information - Your home, your data, organized.

Python

Added initial integration code and beginning ZM integration. WIP

Anthony Cassandra192cc8c7e2e0
diff --git a/src/hi/apps/common/apps.py b/src/hi/apps/common/apps.py
index 031fe778..a8626224 100644
--- a/src/hi/apps/common/apps.py
+++ b/src/hi/apps/common/apps.py
@@ -1,6 +1,6 @@
from django.apps import AppConfig
-class CommonConfig(AppConfig):
+class AppsCommonConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "hi.apps.common"
diff --git a/src/hi/apps/common/database_lock.py b/src/hi/apps/common/database_lock.py
new file mode 100644
index 00000000..87279a7e
--- /dev/null
+++ b/src/hi/apps/common/database_lock.py
@@ -0,0 +1,21 @@
+from .models import DatabaseLock
+
+
+class DatabaseLockContext:
+
+ def __init__( self, name, timeout_seconds = 300 ):
+ self.name = name
+ self.timeout_seconds = timeout_seconds
+ self.lock = None
+
+ def __enter__(self):
+ self.lock = DatabaseLock( name = self.name )
+ if self.lock.acquire( self.timeout_seconds ):
+ return self.lock
+ else:
+ raise RuntimeError(f'Could not acquire lock: {self.name}')
+
+ def __exit__( self, exc_type, exc_val, exc_tb ):
+ if self.lock:
+ self.lock.release()
+ return
diff --git a/src/hi/apps/common/histogram.py b/src/hi/apps/common/histogram.py
new file mode 100644
index 00000000..59eeb1f1
--- /dev/null
+++ b/src/hi/apps/common/histogram.py
@@ -0,0 +1,70 @@
+from dataclasses import dataclass, field
+import json
+import logging
+from typing import Dict
+
+logger = logging.getLogger(__name__)
+
+
+@dataclass
+class Histogram:
+ label : str = 'Untitled'
+ category_label : str = 'Value'
+ count_label : str = 'Count'
+ total_sum : int = 0
+ sort_by_value : bool = True
+ sort_disabled : bool = False
+ histogram : Dict[ object, int ] = field( default_factory = dict )
+ limit : int = 0
+
+ def __str__(self):
+ return '%s: %s' % ( self.label,
+ json.dumps( self._stats.histogram, indent=4, sort_keys=True ))
+
+ def get( self, category, default = 0 ):
+ return self.histogram.get( category, default )
+
+ @property
+ def total_unique(self):
+ return len(self.histogram)
+
+ def increment( self, category, value = 1 ):
+ self.total_sum += value
+ if category not in self.histogram:
+ self.histogram[category] = 0
+ self.histogram[category] += value
+ return
+
+ def items( self ):
+ item_list = [ ( x, y ) for x, y in self.histogram.items() ]
+
+ # If no sorting, use insertion ordering
+ if not self.sort_disabled:
+ if self.sort_by_value:
+ item_list.sort( key = lambda item: item[1], reverse = True )
+ else:
+ item_list.sort( key = lambda item: item[0], reverse = True )
+
+ for idx, item in enumerate( item_list ):
+ if self.limit and idx >= self.limit:
+ return
+ if self.total_sum > 0:
+ percentage = 100.0 * item[1] / self.total_sum
+ else:
+ percentage = 0.0
+ yield ( item[1], item[0], percentage )
+ continue
+ return
+
+ def update( self, histogram ):
+ for category, count in histogram.histogram.items():
+ self.increment( category, value = count )
+ continue
+ return
+
+ def to_django_choices(self):
+ choices = list()
+ for value, category, _ in self.items():
+ choices.append( ( category, f'{category} ({value})' ) )
+ continue
+ return choices
diff --git a/src/hi/apps/common/models.py b/src/hi/apps/common/models.py
index 45adc2f3..a84aae16 100644
--- a/src/hi/apps/common/models.py
+++ b/src/hi/apps/common/models.py
@@ -1,72 +1,36 @@
-from dataclasses import dataclass, field
-import json
-import logging
-from typing import Dict
+from datetime import timedelta
-from django.db import models
+from django.db import models, transaction
+from django.utils import timezone
-logger = logging.getLogger(__name__)
+class DatabaseLock(models.Model):
-@dataclass
-class Histogram:
- label : str = 'Untitled'
- category_label : str = 'Value'
- count_label : str = 'Count'
- total_sum : int = 0
- sort_by_value : bool = True
- sort_disabled : bool = False
- histogram : Dict[ object, int ] = field( default_factory = dict )
- limit : int = 0
+ name = models.CharField(
+ max_length = 64,
+ unique = True
+ )
+ acquired_at = models.DateTimeField()
- def __str__(self):
- return '%s: %s' % ( self.label,
- json.dumps( self._stats.histogram, indent=4, sort_keys=True ))
-
- def get( self, category, default = 0 ):
- return self.histogram.get( category, default )
+ def is_expired( self, timeout_seconds = 300 ):
+ return timezone.now() > self.acquired_at + timedelta( seconds = timeout_seconds )
- @property
- def total_unique(self):
- return len(self.histogram)
-
- def increment( self, category, value = 1 ):
- self.total_sum += value
- if category not in self.histogram:
- self.histogram[category] = 0
- self.histogram[category] += value
- return
-
- def items( self ):
- item_list = [ ( x, y ) for x, y in self.histogram.items() ]
+ def acquire( self, timeout_seconds = 300 ):
+ """
+ Attempt to acquire the lock. Returns True if the lock is acquired, False otherwise.
+ """
+ with transaction.atomic():
+ lock, created = DatabaseLock.objects.get_or_create(
+ name = self.name,
+ defaults={ "acquired_at": timezone.now() }
+ )
+ if not created and not lock.is_expired( timeout_seconds ):
+ return False
- # If no sorting, use insertion ordering
- if not self.sort_disabled:
- if self.sort_by_value:
- item_list.sort( key = lambda item: item[1], reverse = True )
- else:
- item_list.sort( key = lambda item: item[0], reverse = True )
-
- for idx, item in enumerate( item_list ):
- if self.limit and idx >= self.limit:
- return
- if self.total_sum > 0:
- percentage = 100.0 * item[1] / self.total_sum
- else:
- percentage = 0.0
- yield ( item[1], item[0], percentage )
- continue
- return
+ lock.acquired_at = timezone.now()
+ lock.save()
+ return True
- def update( self, histogram ):
- for category, count in histogram.histogram.items():
- self.increment( category, value = count )
- continue
+ def release(self):
+ self.delete()
return
-
- def to_django_choices(self):
- choices = list()
- for value, category, _ in self.items():
- choices.append( ( category, f'{category} ({value})' ) )
- continue
- return choices
diff --git a/src/hi/apps/entity/models.py b/src/hi/apps/entity/models.py
index 6fe9b164..7809baef 100644
--- a/src/hi/apps/entity/models.py
+++ b/src/hi/apps/entity/models.py
@@ -253,6 +253,9 @@ class Attribute(models.Model):
class Meta:
verbose_name = 'Attribute'
verbose_name_plural = 'Attributes'
+ indexes = [
+ models.Index( fields=[ 'name', 'value' ] ),
+ ]
@property
def attribute_value_type(self):
diff --git a/src/hi/integrations/__init__.py b/src/hi/integrations/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/hi/integrations/core/__init__.py b/src/hi/integrations/core/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/hi/integrations/core/admin.py b/src/hi/integrations/core/admin.py
new file mode 100644
index 00000000..8c38f3f3
--- /dev/null
+++ b/src/hi/integrations/core/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/src/hi/integrations/core/apps.py b/src/hi/integrations/core/apps.py
new file mode 100644
index 00000000..58f2e11e
--- /dev/null
+++ b/src/hi/integrations/core/apps.py
@@ -0,0 +1,38 @@
+import asyncio
+import sys
+import threading
+
+from django.apps import AppConfig
+
+
+class IntegrationCommonConfig(AppConfig):
+
+ default_auto_field = "django.db.models.BigAutoField"
+ name = "hi.integrations.core"
+
+ INITIALIZATION_LOCK_NAME = 'integration_initialization'
+
+ def ready(self):
+ if not self.is_runserver_command():
+ return
+ threading.Thread( target = self.initialize_integrations ).start()
+ return
+
+ def initialize_integrations(self):
+ from hi.apps.common.database_lock import DatabaseLockContext
+ from .initialize import initialize_integrations # Need to be inside this method
+
+ try:
+ with DatabaseLockContext( name = self.INITIALIZATION_LOCK_NAME ):
+ loop = asyncio.new_event_loop()
+ asyncio.set_event_loop(loop)
+ loop.run_until_complete( initialize_integrations() )
+ loop.close()
+
+ except RuntimeError:
+ pass
+
+ return
+
+ def is_runserver_command(self):
+ return bool( len(sys.argv) > 1 and sys.argv[1] == 'runserver' )
diff --git a/src/hi/integrations/core/enums.py b/src/hi/integrations/core/enums.py
new file mode 100644
index 00000000..ccfb7717
--- /dev/null
+++ b/src/hi/integrations/core/enums.py
@@ -0,0 +1,16 @@
+from hi.apps.common.enums import LabeledEnum
+
+
+class PropertyValueType(LabeledEnum):
+
+ STRING = ('String', '' )
+ INTEGER = ('Integer', '' )
+ FLOAT = ('Float', '' )
+
+
+class IntegrationType(LabeledEnum):
+
+ ZONEMINDER = ( 'ZoneMinder', 'ZoneMinder camera streaming and motion detection.' )
+ INSTEON_HASS = ( 'InsteonHASS', 'Insteon devices via Home Assistant API and its integration' )
+ INSTEON_DIRECT = ( 'InsteonDirect', 'Insteon devices via modem on serial port.' )
+
diff --git a/src/hi/integrations/core/exceptions.py b/src/hi/integrations/core/exceptions.py
new file mode 100644
index 00000000..97364a5a
--- /dev/null
+++ b/src/hi/integrations/core/exceptions.py
@@ -0,0 +1,6 @@
+class IntegrationPropertyError(Exception):
+ pass
+
+
+class IntegrationConnectionError(Exception):
+ pass
diff --git a/src/hi/integrations/core/initialize.py b/src/hi/integrations/core/initialize.py
new file mode 100644
index 00000000..877e4c1e
--- /dev/null
+++ b/src/hi/integrations/core/initialize.py
@@ -0,0 +1,25 @@
+from asgiref.sync import sync_to_async
+import logging
+import traceback
+
+from hi.integrations.zoneminder.zm_manager import ZoneMinderManager
+
+logger = logging.getLogger(__name__)
+
+
+async def initialize_integrations():
+ """
+ Each integration should:
+ - run asynchronously;
+ - check if they are enabled or not; and
+ - sanity check their configuration properties.
+ """
+ try:
+ await sync_to_async( ZoneMinderManager().initialize)() # Need wrapper for ORM operations
+ except Exception as e:
+ logger.error( 'ZM initialization error: {}'.format(str(e)) )
+ logger.info( traceback.format_exc() )
+
+ # Add other integration initializations here.
+
+ return
diff --git a/src/hi/integrations/core/integration_manager.py b/src/hi/integrations/core/integration_manager.py
new file mode 100644
index 00000000..2fe5032c
--- /dev/null
+++ b/src/hi/integrations/core/integration_manager.py
@@ -0,0 +1,23 @@
+import logging
+
+from hi.apps.common.singleton import Singleton
+
+from .enums import IntegrationType
+from .models import Integration
+
+logger = logging.getLogger(__name__)
+
+
+class IntegrationManager( Singleton ):
+
+ def __init_singleton__( self ):
+ return
+
+ def get_integration( self, integration_type : IntegrationType ) -> Integration:
+ try:
+ return Integration.objects.get( integration_type_str = str(integration_type) )
+ except Integration.DoesNotExist:
+ return Integration(
+ integration_type_str = str(integration_type),
+ is_enabled = False,
+ )
diff --git a/src/hi/integrations/core/migrations/__init__.py b/src/hi/integrations/core/migrations/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/hi/integrations/core/models.py b/src/hi/integrations/core/models.py
new file mode 100644
index 00000000..fed9cf29
--- /dev/null
+++ b/src/hi/integrations/core/models.py
@@ -0,0 +1,105 @@
+from typing import Dict
+
+from django.db import models
+
+from .enums import IntegrationType, PropertyValueType
+
+
+class Integration( models.Model ):
+
+ integration_type_str = models.CharField(
+ 'Integration Type',
+ max_length = 64,
+ null = False, blank = False,
+ unique = True,
+ )
+ is_enabled = models.BooleanField(
+ 'Enabled?',
+ default = False,
+ )
+ created_datetime = models.DateTimeField(
+ 'Created',
+ auto_now_add = True,
+ blank = True,
+ )
+ updated_datetime = models.DateTimeField(
+ 'Updated',
+ auto_now = True,
+ blank = True,
+ )
+
+ class Meta:
+ verbose_name = 'Integration'
+ verbose_name_plural = 'Integrations'
+
+ def __str__(self):
+ return f'{self.integration_type_str}'
+
+ @property
+ def integration_type(self):
+ return IntegrationType.from_name_safe( self.integration_type_str )
+
+ @integration_type.setter
+ def integration_type( self, integration_type : IntegrationType ):
+ self.integration_type_str = str(integration_type)
+ return
+
+ @property
+ def property_dict(self) -> Dict[ str, 'IntegrationProperty' ] :
+ property_dict = dict()
+ for prop in self.properties.all():
+ property_dict[prop.name] = prop
+ continue
+ return property_dict
+
+
+class IntegrationProperty(models.Model):
+
+ integration = models.ForeignKey(
+ Integration,
+ related_name = 'properties',
+ verbose_name = 'Integration',
+ on_delete=models.CASCADE,
+ )
+ name = models.CharField(
+ 'Name',
+ max_length = 64,
+ )
+ value = models.TextField(
+ 'Value',
+ )
+ value_type_str = models.CharField(
+ 'Value Type',
+ max_length = 32,
+ null = False, blank = False,
+ )
+ is_editable = models.BooleanField(
+ 'Editable?',
+ default = True,
+ )
+ is_required = models.BooleanField(
+ 'Required?',
+ default = False,
+ )
+ created_datetime = models.DateTimeField(
+ 'Created',
+ auto_now_add = True,
+ )
+ updated_datetime = models.DateTimeField(
+ 'Updated',
+ auto_now=True,
+ blank = True,
+ )
+
+ class Meta:
+ verbose_name = 'Property'
+ verbose_name_plural = 'Properties'
+
+ @property
+ def value_type(self):
+ return PropertyValueType.from_name_safe( self.value_type_str )
+
+ @value_type.setter
+ def value_type( self, value_type : PropertyValueType ):
+ self.value_type_str = str(value_type)
+ return
diff --git a/src/hi/integrations/zoneminder/__init__.py b/src/hi/integrations/zoneminder/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/hi/integrations/zoneminder/apps.py b/src/hi/integrations/zoneminder/apps.py
new file mode 100644
index 00000000..579bcb08
--- /dev/null
+++ b/src/hi/integrations/zoneminder/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class ZoneminderConfig(AppConfig):
+ default_auto_field = "django.db.models.BigAutoField"
+ name = "hi.integrations.zoneminder"
diff --git a/src/hi/integrations/zoneminder/enums.py b/src/hi/integrations/zoneminder/enums.py
new file mode 100644
index 00000000..e302139c
--- /dev/null
+++ b/src/hi/integrations/zoneminder/enums.py
@@ -0,0 +1,46 @@
+from hi.apps.common.enums import LabeledEnum
+
+from hi.integrations.core.enums import PropertyValueType
+
+
+class ZmPropertyName(LabeledEnum):
+
+ def __init__( self,
+ label : str,
+ description : str,
+ value_type : PropertyValueType,
+ is_editable : bool,
+ is_required : bool ):
+ super().__init__( label, description )
+ self.is_editable = is_editable
+ self.is_required = is_required
+ return
+
+ API_URL = (
+ 'API URL',
+ 'e.g., https://myserver:8443/zm/api',
+ PropertyValueType.STRING,
+ True,
+ True,
+ )
+ PORTAL_URL = (
+ 'Portal URL',
+ 'e.g., https://myserver:8443/zm',
+ PropertyValueType.STRING,
+ True,
+ True,
+ )
+ API_USER = (
+ 'Username',
+ '',
+ PropertyValueType.STRING,
+ True,
+ True,
+ )
+ API_PASSWORD = (
+ 'Password',
+ '',
+ PropertyValueType.STRING,
+ True,
+ True,
+ )
diff --git a/src/hi/integrations/zoneminder/management/__init__.py b/src/hi/integrations/zoneminder/management/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/hi/integrations/zoneminder/management/commands/__init__.py b/src/hi/integrations/zoneminder/management/commands/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/hi/integrations/zoneminder/management/commands/zm_test.py b/src/hi/integrations/zoneminder/management/commands/zm_test.py
new file mode 100644
index 00000000..c7b19372
--- /dev/null
+++ b/src/hi/integrations/zoneminder/management/commands/zm_test.py
@@ -0,0 +1,111 @@
+import pyzm.api as zmapi
+import traceback
+
+from django.core.management.base import BaseCommand
+
+from hi.apps.common.command_utils import CommandLoggerMixin
+
+
+class Command( BaseCommand, CommandLoggerMixin ):
+ """ Used for ad-hoc testing and explorations during development of the Zoneminder integration. """
+
+ help = 'Check ZoneMinder API functionality.'
+
+ def handle(self, *args, **options):
+ self.info( 'ZoneMinder Test' )
+
+ cam_name = 'FrontCamera'
+
+ api_options = {
+ 'apiurl': 'https://bordeaux:8443/zm/api',
+ 'portalurl': 'https://bordeaux:8443/zm',
+ 'user': 'admin',
+ 'password': '--REDACTED--', # TODO: Need to manuallyt tweak this.
+ # 'disable_ssl_cert_check': True
+ }
+ try:
+ zmApi = zmapi.ZMApi(options=api_options)
+ except Exception as e:
+ self.error( 'Error: {}'.format(str(e)) )
+ self.info( traceback.format_exc() )
+ exit(1)
+
+ self.info("--------| Getting Monitors |-----------")
+ ms = zmApi.monitors()
+ for m in ms.list():
+ self.info('Name:{} Enabled:{} Type:{} Dims:{}'.format( m.name(),
+ m.enabled(),
+ m.type(),
+ m.dimensions()))
+ self.info(m.status())
+ continue
+
+ self.info( "--------| Getting Events |-----------" )
+ event_filter = {
+ 'from': '24 hours ago', # this will use localtimezone, use 'tz' for other timezones
+ 'object_only': False,
+ 'min_alarmed_frames': 1,
+ 'max_events': 5,
+ }
+ self.info( "Getting events across all monitors" )
+ es = zmApi.events(event_filter)
+ self.info('I got {} events'.format(len(es.list())))
+
+ self.info('Getting events for {} with filter: {}'.format( cam_name, event_filter))
+ cam_events = ms.find( name = cam_name ).events(options=event_filter)
+ for e in cam_events.list():
+ self.info('Event:{} Cause:{} Notes:{}'.format(e.name(), e.cause(), e.notes()))
+ continue
+
+ self.info("--------| Getting ZM States |-----------")
+ states = zmApi.states()
+ for state in states.list():
+ self.info('State:{}[{}], active={}, details={}'.format(state.name(), state.id(), state.active(), state.definition()))
+
+ i = input('Test Monitor State Change? [y/N]').lower()
+ if i == 'y':
+ self.info("--------| Setting Monitors |-----------")
+ m = ms.find( name = cam_name )
+ try:
+ old_function = m.function()
+ input('Going to change state of {}[{}] to Monitor from {}'.format(m.name(),m.id(), old_function))
+ self.info(m.set_parameter(options={'function':'Monitor'}))
+ input('Switching back to {}'.format(old_function))
+ self.info(m.set_parameter(options={'function':old_function}))
+ except Exception as e:
+ self.info('Error: {}'.format(str(e)))
+
+ self.info("--------| Setting Alarms |-----------")
+ try:
+ input('Arming {}, press enter'.format(m.name()))
+ self.info(m.arm())
+ input('Disarming {}, press enter'.format(m.name()))
+ self.info(m.disarm())
+ except Exception as e:
+ self.info('Error: {}'.format(str(e)))
+
+ i = input('Test ZM State Changes? [y/N]').lower()
+ if i == 'y':
+ self.info("--------| Setting States |-----------")
+ try:
+ input('Stopping ZM press enter')
+ self.info(zmApi.stop())
+ input('Starting ZM press enter')
+ self.info(zmApi.start())
+ for idx,state in enumerate(states.list()):
+ self.info('{}:{}'.format(idx,state.name()))
+ i = int(input('enter state number to switch to:'))
+ name = states.list()[i].name()
+ self.info('Changing state to: {}'.format(name))
+ self.info(zmApi.set_state(state=name))
+ except Exception as e:
+ self.info('Error: {}'.format(str(e)))
+
+ self.info("--------| Configs Test |-----------")
+ try:
+ conf = zmApi.configs()
+ self.info(conf.find(name='ZM_AUTH_HASH_LOGINS'))
+ except Exception as e:
+ self.info('Error: {}'.format(str(e)))
+
+ return
diff --git a/src/hi/integrations/zoneminder/migrations/__init__.py b/src/hi/integrations/zoneminder/migrations/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/src/hi/integrations/zoneminder/zm_manager.py b/src/hi/integrations/zoneminder/zm_manager.py
new file mode 100644
index 00000000..2bcbf1d2
--- /dev/null
+++ b/src/hi/integrations/zoneminder/zm_manager.py
@@ -0,0 +1,71 @@
+import logging
+import pyzm.api as zmapi
+
+from hi.apps.common.singleton import Singleton
+
+from hi.integrations.core.enums import IntegrationType
+from hi.integrations.core.exceptions import IntegrationPropertyError
+from hi.integrations.core.integration_manager import IntegrationManager
+
+from .enums import ZmPropertyName
+
+logger = logging.getLogger(__name__)
+
+
+class ZoneMinderManager( Singleton ):
+
+ def __init_singleton__( self ):
+ self.zmClient = None
+ self._is_loading = False
+ return
+
+ def initialize( self ):
+ if self._is_loading:
+ logger.warning( 'ZoneMinder initialization already started.' )
+ return
+ try:
+ logger.debug( 'Loading ZoneMinder data ...' )
+ self._is_loading = True
+ self.zmClient = None
+ zm_integration = IntegrationManager().get_integration( IntegrationType.ZONEMINDER )
+ if not zm_integration.is_enabled:
+ logger.debug( 'ZoneMinder integration is not enabled.' )
+ return
+
+ property_dict = zm_integration.property_dict
+ for zm_prop_name in ZmPropertyName:
+ zm_prop = property_dict.get( zm_prop_name.label )
+ if not zm_prop:
+ raise IntegrationPropertyError( f'Missing ZM property {zm_prop_name.label}' )
+ if zm_prop.is_required and not zm_prop.value.strip():
+ raise IntegrationPropertyError( f'Missing ZM property value for {zm_prop_name.label}' )
+
+ continue
+
+ api_options = {
+ 'apiurl': property_dict.get( ZmPropertyName.API_URL.label ).value,
+ 'portalurl': property_dict.get( ZmPropertyName.PORTAL_URL.label ).value,
+ 'user': property_dict.get( ZmPropertyName.API_USER.label ).value,
+ 'password': property_dict.get( ZmPropertyName.API_PASSWORD.label ).value,
+ # 'disable_ssl_cert_check': True
+ }
+
+ self.zmClient = zmapi.ZMApi(options=api_options)
+
+ logger.debug("Getting ZM Monitors")
+ ms = self.zmClient.monitors()
+ for m in ms.list():
+ logger.debug('Name:{} Enabled:{} Type:{} Dims:{}'.format( m.name(),
+ m.enabled(),
+ m.type(),
+ m.dimensions()) )
+ logger.debug( m.status() )
+
+ # TODO: Add new cameras if needed
+
+ continue
+
+ finally:
+ self._is_loading = False
+ logger.debug( 'ZoneMinder initialization completed.' )
+ return
diff --git a/src/hi/requirements/base.txt b/src/hi/requirements/base.txt
index fbbdad75..45e7dddc 100644
--- a/src/hi/requirements/base.txt
+++ b/src/hi/requirements/base.txt
@@ -1,9 +1,33 @@
-asgiref==3.8.1
Django==4.2.15
+SQLAlchemy==1.3.24
+asgiref==3.8.1
+certifi==2024.7.4
+charset-normalizer==3.3.2
+dateparser==1.2.0
django-constance==3.1.0
django-csp==3.8
django-picklefield==3.2
django-pipeline-csscompressor==0.1
django-pipeline==3.1.0
+idna==3.7
+imutils==0.5.4
+mysql-connector-python==9.0.0
+numpy==2.1.0
+pillow==10.4.0
+portalocker==2.10.1
+progressbar2==4.4.2
+psutil==6.0.0
+python-dateutil==2.9.0.post0
+python-dotenv==1.0.1
+python-utils==3.8.2
+pytz==2024.1
pytz==2024.1
+pyzm==0.3.64
+regex==2024.7.24
+shapely==2.0.6
+six==1.16.0
sqlparse==0.5.1
+typing_extensions==4.12.2
+tzlocal==5.2
+urllib3==2.2.2
+websocket-client==1.8.0
diff --git a/src/hi/settings/base.py b/src/hi/settings/base.py
index d0c14138..ddb28648 100644
--- a/src/hi/settings/base.py
+++ b/src/hi/settings/base.py
@@ -141,6 +141,8 @@ INSTALLED_APPS = [
'hi.apps.collection',
'hi.apps.sense',
'hi.apps.control',
+ 'hi.integrations.core',
+ 'hi.integrations.zoneminder',
]
MIDDLEWARE = [