From 78c59f437a71ee5d233b43cea6c016da57496e90 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 27 Nov 2022 22:38:58 +0100 Subject: [PATCH] Added support for illuminance sensor entities --- .../panels/Entities/IlluminanceSensor.vue | 1 + .../src/components/panels/Entities/meta.json | 8 +++++++ platypush/entities/illuminance.py | 22 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 120000 platypush/backend/http/webapp/src/components/panels/Entities/IlluminanceSensor.vue create mode 100644 platypush/entities/illuminance.py diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/IlluminanceSensor.vue b/platypush/backend/http/webapp/src/components/panels/Entities/IlluminanceSensor.vue new file mode 120000 index 00000000..70b94460 --- /dev/null +++ b/platypush/backend/http/webapp/src/components/panels/Entities/IlluminanceSensor.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 b80c9df8..070f39d7 100644 --- a/platypush/backend/http/webapp/src/components/panels/Entities/meta.json +++ b/platypush/backend/http/webapp/src/components/panels/Entities/meta.json @@ -55,6 +55,14 @@ } }, + "illuminance_sensor": { + "name": "Sensor", + "name_plural": "Sensors", + "icon": { + "class": "fas fa-sun" + } + }, + "light": { "name": "Light", "name_plural": "Lights", diff --git a/platypush/entities/illuminance.py b/platypush/entities/illuminance.py new file mode 100644 index 00000000..c9a11e3d --- /dev/null +++ b/platypush/entities/illuminance.py @@ -0,0 +1,22 @@ +from sqlalchemy import Column, Integer, ForeignKey + +from .devices import entity_types_registry +from .sensors import NumericSensor + + +if not entity_types_registry.get('IlluminanceSensor'): + + class IlluminanceSensor(NumericSensor): + __tablename__ = 'illuminance_sensor' + + id = Column( + Integer, ForeignKey(NumericSensor.id, ondelete='CASCADE'), primary_key=True + ) + + __mapper_args__ = { + 'polymorphic_identity': __tablename__, + } + + entity_types_registry['IlluminanceSensor'] = IlluminanceSensor +else: + IlluminanceSensor = entity_types_registry['IlluminanceSensor']