diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue b/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue index 3befe9872..219d0f3d4 100644 --- a/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue +++ b/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue @@ -8,7 +8,7 @@
-
@@ -16,7 +16,7 @@
diff --git a/platypush/entities/batteries.py b/platypush/entities/batteries.py index 4c806f32d..828796933 100644 --- a/platypush/entities/batteries.py +++ b/platypush/entities/batteries.py @@ -1,10 +1,11 @@ from sqlalchemy import Column, Integer, ForeignKey -from .devices import entity_types_registry +from platypush.common.db import Base + from .sensors import NumericSensor -if not entity_types_registry.get('Battery'): +if 'battery' not in Base.metadata: class Battery(NumericSensor): __tablename__ = 'battery' @@ -21,7 +22,3 @@ if not entity_types_registry.get('Battery'): __mapper_args__ = { 'polymorphic_identity': __tablename__, } - - entity_types_registry['Battery'] = Battery -else: - Battery = entity_types_registry['Battery'] diff --git a/platypush/entities/devices.py b/platypush/entities/devices.py index a88073dfd..3db19dd9e 100644 --- a/platypush/entities/devices.py +++ b/platypush/entities/devices.py @@ -1,9 +1,11 @@ from sqlalchemy import Column, Integer, Boolean, ForeignKey -from ._base import Entity, entity_types_registry +from platypush.common.db import Base + +from ._base import Entity -if not entity_types_registry.get('Device'): +if 'device' not in Base.metadata: class Device(Entity): __tablename__ = 'device' @@ -16,7 +18,3 @@ if not entity_types_registry.get('Device'): __mapper_args__ = { 'polymorphic_identity': __tablename__, } - - entity_types_registry['Device'] = Device -else: - Device = entity_types_registry['Device'] diff --git a/platypush/entities/dimmers.py b/platypush/entities/dimmers.py index f88d74fe3..16e137f37 100644 --- a/platypush/entities/dimmers.py +++ b/platypush/entities/dimmers.py @@ -1,9 +1,11 @@ from sqlalchemy import Column, Integer, ForeignKey, Float -from .devices import Device, entity_types_registry +from platypush.common.db import Base + +from .devices import Device -if not entity_types_registry.get('Dimmer'): +if 'dimmer' not in Base.metadata: class Dimmer(Device): __tablename__ = 'dimmer' @@ -19,7 +21,3 @@ if not entity_types_registry.get('Dimmer'): __mapper_args__ = { 'polymorphic_identity': __tablename__, } - - entity_types_registry['Dimmer'] = Dimmer -else: - Dimmer = entity_types_registry['Dimmer'] diff --git a/platypush/entities/electricity.py b/platypush/entities/electricity.py index 7c6a466cc..faa3d81c8 100644 --- a/platypush/entities/electricity.py +++ b/platypush/entities/electricity.py @@ -1,10 +1,11 @@ from sqlalchemy import Column, Integer, ForeignKey -from .devices import entity_types_registry +from platypush.common.db import Base + from .sensors import NumericSensor -if not entity_types_registry.get('PowerSensor'): +if 'power_sensor' not in Base.metadata: class PowerSensor(NumericSensor): __tablename__ = 'power_sensor' @@ -17,12 +18,8 @@ if not entity_types_registry.get('PowerSensor'): 'polymorphic_identity': __tablename__, } - entity_types_registry['PowerSensor'] = PowerSensor -else: - PowerSensor = entity_types_registry['PowerSensor'] - -if not entity_types_registry.get('CurrentSensor'): +if 'current_sensor' not in Base.metadata: class CurrentSensor(NumericSensor): __tablename__ = 'current_sensor' @@ -35,12 +32,8 @@ if not entity_types_registry.get('CurrentSensor'): 'polymorphic_identity': __tablename__, } - entity_types_registry['CurrentSensor'] = CurrentSensor -else: - CurrentSensor = entity_types_registry['CurrentSensor'] - -if not entity_types_registry.get('VoltageSensor'): +if 'voltage_sensor' not in Base.metadata: class VoltageSensor(NumericSensor): __tablename__ = 'voltage_sensor' @@ -53,12 +46,8 @@ if not entity_types_registry.get('VoltageSensor'): 'polymorphic_identity': __tablename__, } - entity_types_registry['VoltageSensor'] = VoltageSensor -else: - VoltageSensor = entity_types_registry['VoltageSensor'] - -if not entity_types_registry.get('EnergySensor'): +if 'energy_sensor' not in Base.metadata: class EnergySensor(NumericSensor): __tablename__ = 'energy_sensor' @@ -70,7 +59,3 @@ if not entity_types_registry.get('EnergySensor'): __mapper_args__ = { 'polymorphic_identity': __tablename__, } - - entity_types_registry['EnergySensor'] = EnergySensor -else: - EnergySensor = entity_types_registry['EnergySensor'] diff --git a/platypush/entities/humidity.py b/platypush/entities/humidity.py index a78218ea1..ecafe351e 100644 --- a/platypush/entities/humidity.py +++ b/platypush/entities/humidity.py @@ -1,10 +1,11 @@ from sqlalchemy import Column, Integer, ForeignKey -from .devices import entity_types_registry +from platypush.common.db import Base + from .sensors import NumericSensor -if not entity_types_registry.get('HumiditySensor'): +if 'humidity_sensor' not in Base.metadata: class HumiditySensor(NumericSensor): __tablename__ = 'humidity_sensor' @@ -16,7 +17,3 @@ if not entity_types_registry.get('HumiditySensor'): __mapper_args__ = { 'polymorphic_identity': __tablename__, } - - entity_types_registry['HumiditySensor'] = HumiditySensor -else: - HumiditySensor = entity_types_registry['HumiditySensor'] diff --git a/platypush/entities/illuminance.py b/platypush/entities/illuminance.py index c9a11e3d6..7d37575e8 100644 --- a/platypush/entities/illuminance.py +++ b/platypush/entities/illuminance.py @@ -1,10 +1,11 @@ from sqlalchemy import Column, Integer, ForeignKey -from .devices import entity_types_registry +from platypush.common.db import Base + from .sensors import NumericSensor -if not entity_types_registry.get('IlluminanceSensor'): +if 'illuminance_sensor' not in Base.metadata: class IlluminanceSensor(NumericSensor): __tablename__ = 'illuminance_sensor' @@ -16,7 +17,3 @@ if not entity_types_registry.get('IlluminanceSensor'): __mapper_args__ = { 'polymorphic_identity': __tablename__, } - - entity_types_registry['IlluminanceSensor'] = IlluminanceSensor -else: - IlluminanceSensor = entity_types_registry['IlluminanceSensor'] diff --git a/platypush/entities/lights.py b/platypush/entities/lights.py index b2179a330..4ccb122cb 100644 --- a/platypush/entities/lights.py +++ b/platypush/entities/lights.py @@ -1,9 +1,11 @@ from sqlalchemy import Column, Integer, String, ForeignKey, Boolean, Float -from .devices import Device, entity_types_registry +from platypush.common.db import Base + +from .devices import Device -if not entity_types_registry.get('Light'): +if 'light' not in Base.metadata: class Light(Device): __tablename__ = 'light' @@ -18,6 +20,9 @@ if not entity_types_registry.get('Light'): temperature = Column(Float) x = Column(Float) y = Column(Float) + red = Column(Float) + green = Column(Float) + blue = Column(Float) colormode = Column(String) effect = Column(String) hue_min = Column(Float) @@ -32,7 +37,3 @@ if not entity_types_registry.get('Light'): __mapper_args__ = { 'polymorphic_identity': __tablename__, } - - entity_types_registry['Light'] = Light -else: - Light = entity_types_registry['Light'] diff --git a/platypush/entities/linkquality.py b/platypush/entities/linkquality.py index c314940a5..6dc4169d8 100644 --- a/platypush/entities/linkquality.py +++ b/platypush/entities/linkquality.py @@ -1,10 +1,11 @@ from sqlalchemy import Column, Integer, ForeignKey -from .devices import entity_types_registry +from platypush.common.db import Base + from .sensors import NumericSensor -if not entity_types_registry.get('LinkQuality'): +if 'link_quality' not in Base.metadata: class LinkQuality(NumericSensor): __tablename__ = 'link_quality' @@ -21,7 +22,3 @@ if not entity_types_registry.get('LinkQuality'): __mapper_args__ = { 'polymorphic_identity': __tablename__, } - - entity_types_registry['LinkQuality'] = LinkQuality -else: - LinkQuality = entity_types_registry['LinkQuality'] diff --git a/platypush/entities/sensors.py b/platypush/entities/sensors.py index 0af0553e8..91ee70242 100644 --- a/platypush/entities/sensors.py +++ b/platypush/entities/sensors.py @@ -10,7 +10,9 @@ from sqlalchemy import ( String, ) -from .devices import Device, entity_types_registry +from platypush.common.db import Base + +from .devices import Device logger = logging.getLogger(__name__) @@ -19,7 +21,7 @@ class Sensor(Device): __abstract__ = True -if not entity_types_registry.get('RawSensor'): +if 'raw_sensor' not in Base.metadata: class RawSensor(Sensor): __tablename__ = 'raw_sensor' @@ -33,12 +35,8 @@ if not entity_types_registry.get('RawSensor'): 'polymorphic_identity': __tablename__, } - entity_types_registry['RawSensor'] = RawSensor -else: - RawSensor = entity_types_registry['RawSensor'] - -if not entity_types_registry.get('NumericSensor'): +if 'numeric_sensor' not in Base.metadata: class NumericSensor(Sensor): __tablename__ = 'numeric_sensor' @@ -55,12 +53,8 @@ if not entity_types_registry.get('NumericSensor'): 'polymorphic_identity': __tablename__, } - entity_types_registry['NumericSensor'] = NumericSensor -else: - NumericSensor = entity_types_registry['NumericSensor'] - -if not entity_types_registry.get('BinarySensor'): +if 'binary_sensor' not in Base.metadata: class BinarySensor(Sensor): __tablename__ = 'binary_sensor' @@ -88,12 +82,8 @@ if not entity_types_registry.get('BinarySensor'): 'polymorphic_identity': __tablename__, } - entity_types_registry['BinarySensor'] = BinarySensor -else: - BinarySensor = entity_types_registry['BinarySensor'] - -if not entity_types_registry.get('EnumSensor'): +if 'enum_sensor' not in Base.metadata: class EnumSensor(Sensor): __tablename__ = 'enum_sensor' @@ -107,7 +97,3 @@ if not entity_types_registry.get('EnumSensor'): __mapper_args__ = { 'polymorphic_identity': __tablename__, } - - entity_types_registry['EnumSensor'] = EnumSensor -else: - EnumSensor = entity_types_registry['EnumSensor'] diff --git a/platypush/entities/switches.py b/platypush/entities/switches.py index 6adc9d51f..316e4cadc 100644 --- a/platypush/entities/switches.py +++ b/platypush/entities/switches.py @@ -1,9 +1,11 @@ from sqlalchemy import Column, Integer, ForeignKey, Boolean, String, JSON -from .devices import Device, entity_types_registry +from platypush.common.db import Base + +from .devices import Device -if not entity_types_registry.get('Switch'): +if 'switch' not in Base.metadata: class Switch(Device): __tablename__ = 'switch' @@ -17,12 +19,8 @@ if not entity_types_registry.get('Switch'): 'polymorphic_identity': __tablename__, } - entity_types_registry['Switch'] = Switch -else: - Switch = entity_types_registry['Switch'] - -if not entity_types_registry.get('EnumSwitch'): +if 'enum_switch' not in Base.metadata: class EnumSwitch(Device): __tablename__ = 'enum_switch' @@ -36,7 +34,3 @@ if not entity_types_registry.get('EnumSwitch'): __mapper_args__ = { 'polymorphic_identity': __tablename__, } - - entity_types_registry['EnumSwitch'] = EnumSwitch -else: - EnumSwitch = entity_types_registry['EnumSwitch'] diff --git a/platypush/entities/temperature.py b/platypush/entities/temperature.py index e9b2d12ab..2b378d47d 100644 --- a/platypush/entities/temperature.py +++ b/platypush/entities/temperature.py @@ -1,10 +1,11 @@ from sqlalchemy import Column, Integer, ForeignKey -from .devices import entity_types_registry +from platypush.common.db import Base + from .sensors import NumericSensor -if not entity_types_registry.get('TemperatureSensor'): +if 'temperature_sensor' not in Base.metadata: class TemperatureSensor(NumericSensor): __tablename__ = 'temperature_sensor' @@ -16,7 +17,3 @@ if not entity_types_registry.get('TemperatureSensor'): __mapper_args__ = { 'polymorphic_identity': __tablename__, } - - entity_types_registry['TemperatureSensor'] = TemperatureSensor -else: - TemperatureSensor = entity_types_registry['TemperatureSensor']