2023-01-09 01:01:05 +01:00
|
|
|
from sqlalchemy import Column, Integer, ForeignKey, Float, String
|
2022-10-23 00:30:32 +02:00
|
|
|
|
2023-10-04 09:50:10 +02:00
|
|
|
from platypush.common.db import is_defined
|
2022-10-23 00:30:32 +02:00
|
|
|
|
2022-12-04 16:27:28 +01:00
|
|
|
from .devices import Device
|
2022-10-23 00:30:32 +02:00
|
|
|
|
2022-12-04 16:27:28 +01:00
|
|
|
|
2023-10-04 09:50:10 +02:00
|
|
|
if not is_defined('dimmer'):
|
2022-10-23 00:30:32 +02:00
|
|
|
|
|
|
|
class Dimmer(Device):
|
2023-02-22 01:02:26 +01:00
|
|
|
"""
|
|
|
|
This class models dimmer entities. A dimmer is any actionable entity
|
|
|
|
with numeric values and an optional min/max range.
|
|
|
|
"""
|
|
|
|
|
2022-10-23 00:30:32 +02:00
|
|
|
__tablename__ = 'dimmer'
|
|
|
|
|
|
|
|
id = Column(
|
|
|
|
Integer, ForeignKey(Device.id, ondelete='CASCADE'), primary_key=True
|
|
|
|
)
|
|
|
|
min = Column(Float)
|
|
|
|
max = Column(Float)
|
|
|
|
step = Column(Float, default=1.0)
|
|
|
|
value = Column(Float)
|
2023-01-09 01:01:05 +01:00
|
|
|
unit = Column(String)
|
2022-10-23 00:30:32 +02:00
|
|
|
|
2023-10-04 09:50:10 +02:00
|
|
|
__table_args__ = {'extend_existing': True}
|
2022-10-23 00:30:32 +02:00
|
|
|
__mapper_args__ = {
|
|
|
|
'polymorphic_identity': __tablename__,
|
|
|
|
}
|