2022-04-04 16:50:17 +02:00
|
|
|
from sqlalchemy import Column, Integer, ForeignKey, Boolean
|
|
|
|
|
2022-10-10 01:38:15 +02:00
|
|
|
from .devices import Device, entity_types_registry
|
2022-04-04 16:50:17 +02:00
|
|
|
|
|
|
|
|
2022-10-10 01:38:15 +02:00
|
|
|
if not entity_types_registry.get('Switch'):
|
2022-04-04 16:50:17 +02:00
|
|
|
|
2022-10-10 01:38:15 +02:00
|
|
|
class Switch(Device):
|
|
|
|
__tablename__ = 'switch'
|
2022-04-04 16:50:17 +02:00
|
|
|
|
2022-10-10 01:38:15 +02:00
|
|
|
id = Column(
|
|
|
|
Integer, ForeignKey(Device.id, ondelete='CASCADE'), primary_key=True
|
|
|
|
)
|
|
|
|
state = Column(Boolean)
|
|
|
|
|
|
|
|
__mapper_args__ = {
|
|
|
|
'polymorphic_identity': __tablename__,
|
|
|
|
}
|
|
|
|
|
|
|
|
entity_types_registry['Switch'] = Switch
|
|
|
|
else:
|
|
|
|
Switch = entity_types_registry['Switch']
|