diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/HeartRateSensor.vue b/platypush/backend/http/webapp/src/components/panels/Entities/HeartRateSensor.vue new file mode 120000 index 000000000..70b944608 --- /dev/null +++ b/platypush/backend/http/webapp/src/components/panels/Entities/HeartRateSensor.vue @@ -0,0 +1 @@ +Sensor.vue \ No newline at end of file diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/meta.json b/platypush/backend/http/webapp/src/components/panels/Entities/meta.json index 6dd104600..8d20a9305 100644 --- a/platypush/backend/http/webapp/src/components/panels/Entities/meta.json +++ b/platypush/backend/http/webapp/src/components/panels/Entities/meta.json @@ -135,6 +135,14 @@ } }, + "heart_rate_sensor": { + "name": "Sensor", + "name_plural": "Sensors", + "icon": { + "class": "fas fa-heart-pulse" + } + }, + "muted": { "name": "Switch", "name_plural": "Switches", diff --git a/platypush/entities/heart.py b/platypush/entities/heart.py new file mode 100644 index 000000000..3c9e3067c --- /dev/null +++ b/platypush/entities/heart.py @@ -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__, + } diff --git a/platypush/plugins/bluetooth/ble/_mappers.py b/platypush/plugins/bluetooth/ble/_mappers.py index bad2504ec..2ebf3809e 100644 --- a/platypush/plugins/bluetooth/ble/_mappers.py +++ b/platypush/plugins/bluetooth/ble/_mappers.py @@ -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', '%'),