From e1b3d5270698c4d1596a630fcb82aeaaa61f8a81 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 23 Feb 2023 00:45:58 +0100 Subject: [PATCH] Added `StepsSensor` entity. --- .../panels/Entities/StepsSensor.vue | 1 + .../src/components/panels/Entities/meta.json | 8 +++++++ platypush/entities/steps.py | 23 +++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 120000 platypush/backend/http/webapp/src/components/panels/Entities/StepsSensor.vue create mode 100644 platypush/entities/steps.py diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/StepsSensor.vue b/platypush/backend/http/webapp/src/components/panels/Entities/StepsSensor.vue new file mode 120000 index 0000000000..70b944608e --- /dev/null +++ b/platypush/backend/http/webapp/src/components/panels/Entities/StepsSensor.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 d5685ac85d..6dd1046000 100644 --- a/platypush/backend/http/webapp/src/components/panels/Entities/meta.json +++ b/platypush/backend/http/webapp/src/components/panels/Entities/meta.json @@ -127,6 +127,14 @@ } }, + "steps_sensor": { + "name": "Sensor", + "name_plural": "Sensors", + "icon": { + "class": "fas fa-shoe-prints" + } + }, + "muted": { "name": "Switch", "name_plural": "Switches", diff --git a/platypush/entities/steps.py b/platypush/entities/steps.py new file mode 100644 index 0000000000..ff536e3367 --- /dev/null +++ b/platypush/entities/steps.py @@ -0,0 +1,23 @@ +from sqlalchemy import Column, Integer, ForeignKey + +from platypush.common.db import Base + +from .sensors import NumericSensor + + +if 'steps_sensor' not in Base.metadata: + + class StepsSensor(NumericSensor): + """ + A sensor that measures the number of steps taken. + """ + + __tablename__ = 'steps_sensor' + + id = Column( + Integer, ForeignKey(NumericSensor.id, ondelete='CASCADE'), primary_key=True + ) + + __mapper_args__ = { + 'polymorphic_identity': __tablename__, + }