Home Information - Your home, your data, organized.
Python
Some tweaks, buy still model WIP.
Anthony Cassandracbaad8b88b9d
diff --git a/src/hi/apps/control/enums.py b/src/hi/apps/control/enums.pyindex 9577832d..eff7bf3e 100644--- a/src/hi/apps/control/enums.py+++ b/src/hi/apps/control/enums.py@@ -3,7 +3,9 @@ from hi.apps.common.enums import LabeledEnumclass ControllerType(LabeledEnum):- SETTING = ( 'Setting', '' ) # Generic, discrete value control (incl. on/off)+ SWITCH = ( 'Switch', '' ) # Boolean on/off value+ SET_STRING = ( 'Set Value', '' ) # Generic, discrete value control+ SET_INTEGER = ( 'Set Value', '' ) # Generic, discrete value controlSLIDER = ( 'Slider', '' ) # Continuous value controlBLOB = ( 'Blob', '' ) # For custom or large chunks of text@@ -11,6 +13,7 @@ class ControllerType(LabeledEnum):# ???? !!!! There's another concept / division in here (general v. specific)# ControllerState ControllerAction?+ # Is there value in having predefined ones for convenience?diff --git a/src/hi/apps/entity/enums.py b/src/hi/apps/entity/enums.pyindex 8ab58639..638e62fd 100644--- a/src/hi/apps/entity/enums.py+++ b/src/hi/apps/entity/enums.py@@ -45,7 +45,6 @@ class EntityType(LabeledEnum):VIDEO_PLAYER = ( 'Video Player', '' )WALL_SWITCH = ( 'Wall Switch', '' )WATER_LINE = ( 'Water Line', '' )- WATER_METER = ( 'Water Meter', '' )WATER_METER = ( 'Water_Meter', '' )WATER_SHUTOFF_VALVE = ( 'Water Shutoff Valve', '' )@@ -58,7 +57,7 @@ class EntityType(LabeledEnum):raise NotImplementedError()-class EntityAttributeType(LabeledEnum):+class AttributeValueType(LabeledEnum):STRING = ('String', '' )INTEGER = ('Integer', '' )@@ -69,3 +68,9 @@ class EntityAttributeType(LabeledEnum):VIDEO = ('Video', '' ) # relative filename in MEDIA_ROOTAUDIO = ('Audio', '' ) # relative filename in MEDIA_ROOTLINK = ('Link', '' )+++class AttributeSourceType(LabeledEnum):++ PREDEFINED = ('Predefined', '' )+ CUSTOM = ('Custom', '' )diff --git a/src/hi/apps/entity/models.py b/src/hi/apps/entity/models.pyindex bb32cda6..b547fa97 100644--- a/src/hi/apps/entity/models.py+++ b/src/hi/apps/entity/models.py@@ -2,7 +2,7 @@ from django.db import modelsfrom hi.apps.location.models import Location-from .enums import EntityType, EntityAttributeType+from .enums import EntityType, AttributeValueType, AttributeSourceTypeclass Entity( models.Model ):@@ -127,7 +127,7 @@ class EntityPath(models.Model):verbose_name_plural = 'EntitiePaths'-class EntityAttribute(models.Model):+class Attribute(models.Model):"""Information related to an entity, e.g., specs, docs, notes, configs)"""@@ -138,8 +138,8 @@ class EntityAttribute(models.Model):verbose_name = 'Attributes',on_delete=models.CASCADE,)- entity_attribute_type_str = models.CharField(- 'Attribute Type',+ attribute_value_type_str = models.CharField(+ 'Attribute Value Type',max_length = 32,null = False, blank = False,)@@ -151,17 +151,39 @@ class EntityAttribute(models.Model):'Value',max_length = 255)+ attribute_source_type_str = models.CharField(+ 'Attribute Source Type',+ max_length = 32,+ null = False, blank = False,+ )+ is_editable = models.BooleanField(+ 'Editable?',+ default = True,+ )+ is_required = models.BooleanField(+ 'Required?',+ default = False,+ )class Meta:verbose_name = 'Attribute'verbose_name_plural = 'Attributes'@property- def entity_attribute_type(self):- return EntityAttributeType.from_name_safe( self.entity_attribute_type_str )+ def attribute_value_type(self):+ return AttributeValueType.from_name_safe( self.attribute_value_type_str )++ @attribute_value_type.setter+ def attribute_value_type( self, attribute_value_type : AttributeValueType ):+ self.attribute_value_type_str = str(attribute_value_type)+ return++ @property+ def attribute_source_type(self):+ return AttributeSourceType.from_name_safe( self.attribute_source_type_str )- @entity_attribute_type.setter- def entity_attribute_type( self, entity_attribute_type : EntityAttributeType ):- self.entity_attribute_type_str = str(entity_attribute_type)+ @attribute_source_type.setter+ def attribute_source_type( self, attribute_source_type : AttributeSourceType ):+ self.attribute_source_type_str = str(attribute_source_type)returndiff --git a/src/hi/apps/sense/enums.py b/src/hi/apps/sense/enums.pyindex 8ef9fa2b..06a8a44d 100644--- a/src/hi/apps/sense/enums.py+++ b/src/hi/apps/sense/enums.py@@ -5,10 +5,11 @@ class SensorType(LabeledEnum):DISCRETE_VALUE = ( 'Discrete Value', '' ) # Generic for devicesCONTINUOUS_VALUE = ( 'Continuous Value', '' ) # Generic for device controls- BLOB = ( 'Blob', '' ) # For custom or large chunks of text+ BLOB = ( 'Blob', '' ) # For custom, large chunks of text, video streams# ??? !!! Are the below not needed as just specilizations for each device type?+ # Is there value in having predefined ones for convenience?BANDWIDTH_USAGE = ( 'Bandwidth Usage', '' )@@ -20,22 +21,20 @@ class SensorType(LabeledEnum):VISUAL_STATIC = ( 'Visual Static', '' ) # For static imagesMOTION = ( 'Motion', '' )CONTACT = ( 'Contact', '' ) # For open/close or for connectivity check- TEMPERATURE = ( 'Thermometer', '' )- HUMIDITY = ( 'Humidity', '' )- AIR_PRESSURE = ( 'Air Pressure', '' )- LIGHT_LEVEL = ( 'Light Level', '' )- PRESENCE = ( 'Presence', '' )- NOISE_LEVEL = ( 'Noise Level', '' )class SensedAreaType(LabeledEnum):- VISIBLE = ( 'Visible', '' )- MOTION = ( 'Motion', '' )- PRESENCE = ( 'Presence', '' )- TEMPERATURE = ( 'Temperature', '' )- HUMIDITY = ( 'Humidity', '' )- AIR_PRESSURE = ( 'Air Pressure', '' )+ VISIBLE_CONTINUOUS = ( 'Visible', '' ) # Video stream+ VISIBLE_DISCRETE = ( 'Visible Discrete', '' ) # Pictures/Snapshots++ MOVEMENT = ( 'Movement', '' )+ PRESENCE = ( 'Presence', '' )+ TEMPERATURE = ( 'Temperature', '' )+ HUMIDITY = ( 'Humidity', '' )+ AIR_PRESSURE = ( 'Air Pressure', '' )+ LIGHT_LEVEL = ( 'Light Level', '' )+ NOISE_LEVEL = ( 'Noise Level', '' )@propertydef svg_path_style(self):