diff --git a/platypush/entities/_base.py b/platypush/entities/_base.py index 3de25334c1..aa589261e7 100644 --- a/platypush/entities/_base.py +++ b/platypush/entities/_base.py @@ -35,6 +35,7 @@ class Entity(Base): type = Column(String, nullable=False, index=True) plugin = Column(String, nullable=False) data = Column(JSON, default=dict) + meta = Column(JSON, default=dict) created_at = Column( DateTime(timezone=False), default=datetime.utcnow(), nullable=False ) @@ -51,9 +52,8 @@ class Entity(Base): 'polymorphic_on': type, } - @classmethod @property - def meta(cls) -> Mapping: + def _meta(self) -> dict: return { 'icon_class': 'fa-solid fa-circle-question', } @@ -75,7 +75,10 @@ class Entity(Base): def to_json(self) -> dict: return { **{col.key: self._serialize_value(col) for col in self.columns}, - 'meta': self.meta, + 'meta': { + **self._meta, + **(self.meta or {}), + }, } def get_plugin(self): diff --git a/platypush/entities/devices.py b/platypush/entities/devices.py index f5d596cb96..bf26c2acb8 100644 --- a/platypush/entities/devices.py +++ b/platypush/entities/devices.py @@ -12,9 +12,9 @@ class Device(Entity): 'polymorphic_identity': __tablename__, } - @classmethod @property - def meta(cls): + def _meta(self): return { + **super()._meta, 'icon_class': 'fa-solid fa-gear', } diff --git a/platypush/entities/lights.py b/platypush/entities/lights.py index a571e8698c..4df4c51cbe 100644 --- a/platypush/entities/lights.py +++ b/platypush/entities/lights.py @@ -12,9 +12,9 @@ class Light(Device): 'polymorphic_identity': __tablename__, } - @classmethod @property - def meta(cls): + def _meta(self): return { + **super()._meta, 'icon_class': 'fa-solid fa-lightbulb', } diff --git a/platypush/entities/switches.py b/platypush/entities/switches.py index 8f01350b67..f26ca6ef61 100644 --- a/platypush/entities/switches.py +++ b/platypush/entities/switches.py @@ -13,10 +13,10 @@ class Switch(Device): 'polymorphic_identity': __tablename__, } - @classmethod @property - def meta(cls): + def _meta(self): return { + **super()._meta, 'icon_class': 'fa-solid fa-light-switch', }