2022-11-11 01:46:38 +01:00
|
|
|
from sqlalchemy import Column, Integer, ForeignKey, Boolean, String, JSON
|
2022-04-04 16:50:17 +02:00
|
|
|
|
2023-10-04 09:50:10 +02:00
|
|
|
from platypush.common.db import is_defined
|
2022-04-04 16:50:17 +02:00
|
|
|
|
2022-12-04 16:27:28 +01:00
|
|
|
from .devices import Device
|
2022-04-04 16:50:17 +02:00
|
|
|
|
2022-12-04 16:27:28 +01:00
|
|
|
|
2023-10-04 09:50:10 +02:00
|
|
|
if not is_defined('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)
|
|
|
|
|
2023-10-04 09:50:10 +02:00
|
|
|
__table_args__ = {'extend_existing': True}
|
2022-10-10 01:38:15 +02:00
|
|
|
__mapper_args__ = {
|
|
|
|
'polymorphic_identity': __tablename__,
|
|
|
|
}
|
|
|
|
|
2022-11-11 01:46:38 +01:00
|
|
|
|
2023-10-04 09:50:10 +02:00
|
|
|
if not is_defined('enum_switch'):
|
2022-11-11 01:46:38 +01:00
|
|
|
|
|
|
|
class EnumSwitch(Device):
|
|
|
|
__tablename__ = 'enum_switch'
|
|
|
|
|
|
|
|
id = Column(
|
|
|
|
Integer, ForeignKey(Device.id, ondelete='CASCADE'), primary_key=True
|
|
|
|
)
|
|
|
|
value = Column(String)
|
|
|
|
values = Column(JSON)
|
|
|
|
|
2023-10-04 09:50:10 +02:00
|
|
|
__table_args__ = {'extend_existing': True}
|
2022-11-11 01:46:38 +01:00
|
|
|
__mapper_args__ = {
|
|
|
|
'polymorphic_identity': __tablename__,
|
|
|
|
}
|