forked from platypush/platypush
Added support for heart rate sensor entities.
This commit is contained in:
parent
3dab94c346
commit
c3e16f9f9d
4 changed files with 34 additions and 0 deletions
|
@ -0,0 +1 @@
|
|||
Sensor.vue
|
|
@ -135,6 +135,14 @@
|
|||
}
|
||||
},
|
||||
|
||||
"heart_rate_sensor": {
|
||||
"name": "Sensor",
|
||||
"name_plural": "Sensors",
|
||||
"icon": {
|
||||
"class": "fas fa-heart-pulse"
|
||||
}
|
||||
},
|
||||
|
||||
"muted": {
|
||||
"name": "Switch",
|
||||
"name_plural": "Switches",
|
||||
|
|
23
platypush/entities/heart.py
Normal file
23
platypush/entities/heart.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from sqlalchemy import Column, Integer, ForeignKey
|
||||
|
||||
from platypush.common.db import Base
|
||||
|
||||
from .sensors import NumericSensor
|
||||
|
||||
|
||||
if 'heart_rate_sensor' not in Base.metadata:
|
||||
|
||||
class HeartRateSensor(NumericSensor):
|
||||
"""
|
||||
A sensor that measures the heart rate.
|
||||
"""
|
||||
|
||||
__tablename__ = 'heart_rate_sensor'
|
||||
|
||||
id = Column(
|
||||
Integer, ForeignKey(NumericSensor.id, ondelete='CASCADE'), primary_key=True
|
||||
)
|
||||
|
||||
__mapper_args__ = {
|
||||
'polymorphic_identity': __tablename__,
|
||||
}
|
|
@ -20,6 +20,7 @@ from platypush.entities.electricity import (
|
|||
PowerSensor,
|
||||
VoltageSensor,
|
||||
)
|
||||
from platypush.entities.heart import HeartRateSensor
|
||||
from platypush.entities.humidity import HumiditySensor
|
||||
from platypush.entities.illuminance import IlluminanceSensor
|
||||
from platypush.entities.motion import MotionSensor
|
||||
|
@ -68,6 +69,7 @@ _property_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = {
|
|||
value=value,
|
||||
unit=conf.get('unit', 'kWh'),
|
||||
),
|
||||
'activity heart rate': lambda value, _: HeartRateSensor(value=value),
|
||||
'humidity': lambda value, conf: HumiditySensor(
|
||||
value=value,
|
||||
unit=conf.get('unit', '%'),
|
||||
|
|
Loading…
Reference in a new issue