platypush/platypush/entities/time.py

24 lines
532 B
Python
Raw Normal View History

2023-02-23 01:02:13 +01:00
from sqlalchemy import Column, Integer, ForeignKey
from platypush.common.db import Base
from .sensors import NumericSensor
2023-04-02 00:57:48 +02:00
if 'time_duration' not in Base.metadata:
2023-02-23 01:02:13 +01:00
2023-04-02 00:57:48 +02:00
class TimeDuration(NumericSensor):
2023-02-23 01:02:13 +01:00
"""
2023-04-02 00:57:48 +02:00
An entity that measures a time duration.
2023-02-23 01:02:13 +01:00
"""
2023-04-02 00:57:48 +02:00
__tablename__ = 'time_duration'
2023-02-23 01:02:13 +01:00
id = Column(
Integer, ForeignKey(NumericSensor.id, ondelete='CASCADE'), primary_key=True
)
__mapper_args__ = {
'polymorphic_identity': __tablename__,
}