forked from platypush/platypush
Implemented meta property for entities (for now it only include icon_class
)
This commit is contained in:
parent
e40b668380
commit
db7c2095ea
4 changed files with 30 additions and 1 deletions
|
@ -51,6 +51,13 @@ class Entity(Base):
|
||||||
'polymorphic_on': type,
|
'polymorphic_on': type,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@property
|
||||||
|
def meta(cls) -> Mapping:
|
||||||
|
return {
|
||||||
|
'icon_class': 'fa-solid fa-circle-question',
|
||||||
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@property
|
@property
|
||||||
def columns(cls) -> Tuple[ColumnProperty]:
|
def columns(cls) -> Tuple[ColumnProperty]:
|
||||||
|
@ -66,7 +73,10 @@ class Entity(Base):
|
||||||
return val
|
return val
|
||||||
|
|
||||||
def to_json(self) -> dict:
|
def to_json(self) -> dict:
|
||||||
return {col.key: self._serialize_value(col) for col in self.columns}
|
return {
|
||||||
|
**{col.key: self._serialize_value(col) for col in self.columns},
|
||||||
|
'meta': self.meta,
|
||||||
|
}
|
||||||
|
|
||||||
def get_plugin(self):
|
def get_plugin(self):
|
||||||
from platypush.context import get_plugin
|
from platypush.context import get_plugin
|
||||||
|
|
|
@ -12,3 +12,9 @@ class Device(Entity):
|
||||||
'polymorphic_identity': __tablename__,
|
'polymorphic_identity': __tablename__,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@property
|
||||||
|
def meta(cls):
|
||||||
|
return {
|
||||||
|
'icon_class': 'fa-solid fa-gear',
|
||||||
|
}
|
||||||
|
|
|
@ -12,3 +12,9 @@ class Light(Device):
|
||||||
'polymorphic_identity': __tablename__,
|
'polymorphic_identity': __tablename__,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@property
|
||||||
|
def meta(cls):
|
||||||
|
return {
|
||||||
|
'icon_class': 'fa-solid fa-lightbulb',
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,13 @@ class Switch(Device):
|
||||||
'polymorphic_identity': __tablename__,
|
'polymorphic_identity': __tablename__,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@property
|
||||||
|
def meta(cls):
|
||||||
|
return {
|
||||||
|
'icon_class': 'fa-solid fa-light-switch',
|
||||||
|
}
|
||||||
|
|
||||||
def on(self):
|
def on(self):
|
||||||
return self.get_plugin().on(self)
|
return self.get_plugin().on(self)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue