Skip to content

Home Information - Your home, your data, organized.

Python

Merged StatusDisplayType into LocationViewType

Anthony Cassandra69059aafb80f
diff --git a/src/hi/apps/location/enums.py b/src/hi/apps/location/enums.py
index b44ce8e7..4a89bc54 100644
--- a/src/hi/apps/location/enums.py
+++ b/src/hi/apps/location/enums.py
@@ -6,31 +6,6 @@ from hi.apps.entity.enums import EntityStateType
class LocationViewType(LabeledEnum):
- CONTROL = ('Control', '' )
- INFORMATION = ('Information', '' )
-
-
-class SvgItemType(LabeledEnum):
-
- ICON = ( 'Icon', '' )
- OPEN_PATH = ( 'Open Path ', '' )
- CLOSED_PATH = ( 'Closed Path ', '' )
-
- @property
- def is_icon(self):
- return bool( self == SvgItemType.ICON )
-
- @property
- def is_path(self):
- return bool( self in [ SvgItemType.OPEN_PATH, SvgItemType.CLOSED_PATH ] )
-
- @property
- def is_path_closed(self):
- return bool( self == SvgItemType.CLOSED_PATH )
-
-
-class StatusDisplayType(LabeledEnum):
-
def __init__( self,
label : str,
description : str,
@@ -39,7 +14,7 @@ class StatusDisplayType(LabeledEnum):
self.entity_state_type_priority_list = entity_state_type_priority_list
return
- DEFAULT = (
+ DEFAULT = (
'Default',
'',
[ EntityStateType.MOVEMENT,
@@ -59,7 +34,7 @@ class StatusDisplayType(LabeledEnum):
],
)
- SECURITY = (
+ SECURITY = (
'Security',
'',
[ EntityStateType.MOVEMENT,
@@ -67,19 +42,19 @@ class StatusDisplayType(LabeledEnum):
EntityStateType.OPEN_CLOSE,
],
)
- LIGHT = (
- 'Light',
+ LIGHTS = (
+ 'Lights',
'',
[ EntityStateType.LIGHT_LEVEL,
],
)
- SOUND = (
- 'Sound',
+ SOUNDS = (
+ 'Sounds',
'',
[ EntityStateType.SOUND_LEVEL,
],
)
- CLIMATE = (
+ CLIMATE = (
'Climate',
'',
[ EntityStateType.TEMPERATURE,
@@ -90,7 +65,7 @@ class StatusDisplayType(LabeledEnum):
EntityStateType.AIR_PRESSURE,
],
)
- ENERGY = (
+ ENERGY = (
'Energy',
'',
[ EntityStateType.ELECTRIC_USAGE,
@@ -98,9 +73,27 @@ class StatusDisplayType(LabeledEnum):
EntityStateType.HIGH_LOW,
],
)
- SUPPRESS = (
+ SUPPRESS = (
'Suppress',
'',
[],
)
+
+class SvgItemType(LabeledEnum):
+
+ ICON = ( 'Icon', '' )
+ OPEN_PATH = ( 'Open Path ', '' )
+ CLOSED_PATH = ( 'Closed Path ', '' )
+
+ @property
+ def is_icon(self):
+ return bool( self == SvgItemType.ICON )
+
+ @property
+ def is_path(self):
+ return bool( self in [ SvgItemType.OPEN_PATH, SvgItemType.CLOSED_PATH ] )
+
+ @property
+ def is_path_closed(self):
+ return bool( self == SvgItemType.CLOSED_PATH )
diff --git a/src/hi/apps/location/location_manager.py b/src/hi/apps/location/location_manager.py
index b228e0a1..897c0751 100644
--- a/src/hi/apps/location/location_manager.py
+++ b/src/hi/apps/location/location_manager.py
@@ -116,7 +116,7 @@ class LocationManager(Singleton):
return LocationView.objects.create(
location = location,
- location_view_type_str = LocationViewType.default(),
+ location_view_type_str = str(LocationViewType.default()),
name = name,
svg_view_box_str = str( location.svg_view_box ),
svg_rotate = Decimal( 0.0 ),
diff --git a/src/hi/apps/location/models.py b/src/hi/apps/location/models.py
index bf2f00ba..43300af6 100644
--- a/src/hi/apps/location/models.py
+++ b/src/hi/apps/location/models.py
@@ -8,7 +8,7 @@ from hi.apps.attribute.models import AttributeModel
from hi.enums import ItemType
from hi.models import ItemTypeModelMixin
-from .enums import LocationViewType, StatusDisplayType
+from .enums import LocationViewType
logger = logging.getLogger(__name__)
@@ -144,12 +144,6 @@ class LocationView( models.Model, ItemTypeModelMixin ):
'Order Id',
default = 0,
)
- status_display_type_str = models.CharField(
- 'Status Display Type',
- max_length = 32,
- default = StatusDisplayType.default_value(),
- null = False, blank = False,
- )
created_datetime = models.DateTimeField(
'Created',
auto_now_add = True,
@@ -192,15 +186,6 @@ class LocationView( models.Model, ItemTypeModelMixin ):
def svg_view_box( self, svg_view_box : SvgViewBox ):
self.svg_view_box_str = str(svg_view_box)
return
-
- @property
- def status_display_type(self) -> StatusDisplayType:
- return StatusDisplayType.from_name_safe( self.status_display_type_str )
-
- @status_display_type.setter
- def status_display_type( self, status_display_type : StatusDisplayType ):
- self.status_display_type_str = str(status_display_type)
- return
class LocationItemModelMixin( ItemTypeModelMixin ):
diff --git a/src/hi/apps/location/status_display_helper.py b/src/hi/apps/location/status_display_helper.py
index efc87ad2..eaa59b1d 100644
--- a/src/hi/apps/location/status_display_helper.py
+++ b/src/hi/apps/location/status_display_helper.py
@@ -4,7 +4,7 @@ from hi.apps.entity.enums import EntityStateType
from hi.apps.entity.models import Entity, EntityState
from hi.apps.sense.sensor_response_manager import SensorResponseManager
-from .enums import StatusDisplayType
+from .enums import LocationViewType
from .models import LocationView
from .transient_models import StatusDisplayData
@@ -20,7 +20,7 @@ class StatusDisplayLocationHelper:
def get_status_display_data_map(
self,
displayed_entities : Set[ Entity ] ) -> Dict[ Entity, StatusDisplayData ]:
- if self._status_display_type == StatusDisplayType.SUPPRESS:
+ if self._status_display_type == LocationViewType.SUPPRESS:
return dict()
entity_to_status_display_data = dict()