platypush/platypush/entities/dimmers.py

31 lines
803 B
Python
Raw Normal View History

2023-01-09 01:01:05 +01:00
from sqlalchemy import Column, Integer, ForeignKey, Float, String
2022-10-23 00:30:32 +02:00
from platypush.common.db import is_defined
2022-10-23 00:30:32 +02:00
from .devices import Device
2022-10-23 00:30:32 +02:00
if not is_defined('dimmer'):
2022-10-23 00:30:32 +02:00
class Dimmer(Device):
"""
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
__table_args__ = {'extend_existing': True}
2022-10-23 00:30:32 +02:00
__mapper_args__ = {
'polymorphic_identity': __tablename__,
}