From 226034946f5019f3045fc6d2a84eb608ebd30530 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 31 Mar 2023 14:22:28 +0200 Subject: [PATCH] Added `distance_sensor` entity --- .../panels/Entities/DistanceSensor.vue | 1 + .../src/components/panels/Entities/meta.json | 8 +++++++ platypush/entities/distance.py | 23 +++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 120000 platypush/backend/http/webapp/src/components/panels/Entities/DistanceSensor.vue create mode 100644 platypush/entities/distance.py diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/DistanceSensor.vue b/platypush/backend/http/webapp/src/components/panels/Entities/DistanceSensor.vue new file mode 120000 index 0000000000..70b944608e --- /dev/null +++ b/platypush/backend/http/webapp/src/components/panels/Entities/DistanceSensor.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 3f1fd38585..5a94f9c385 100644 --- a/platypush/backend/http/webapp/src/components/panels/Entities/meta.json +++ b/platypush/backend/http/webapp/src/components/panels/Entities/meta.json @@ -31,6 +31,14 @@ } }, + "distance_sensor": { + "name": "Sensor", + "name_plural": "Sensors", + "icon": { + "class": "fas fa-ruler-horizontal" + } + }, + "bluetooth_device": { "name": "Device", "name_plural": "Devices", diff --git a/platypush/entities/distance.py b/platypush/entities/distance.py new file mode 100644 index 0000000000..1fe0193a49 --- /dev/null +++ b/platypush/entities/distance.py @@ -0,0 +1,23 @@ +from sqlalchemy import Column, Integer, ForeignKey + +from platypush.common.db import Base + +from .sensors import NumericSensor + + +if 'distance_sensor' not in Base.metadata: + + class DistanceSensor(NumericSensor): + """ + This class models distance sensors. + """ + + __tablename__ = 'distance_sensor' + + id = Column( + Integer, ForeignKey(NumericSensor.id, ondelete='CASCADE'), primary_key=True + ) + + __mapper_args__ = { + 'polymorphic_identity': __tablename__, + }