forked from platypush/platypush
Added PressureSensor
entities.
This commit is contained in:
parent
dd3f683006
commit
d212276247
4 changed files with 43 additions and 2 deletions
|
@ -0,0 +1 @@
|
||||||
|
Sensor.vue
|
|
@ -151,6 +151,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"pressure_sensor": {
|
||||||
|
"name": "Sensor",
|
||||||
|
"name_plural": "Sensors",
|
||||||
|
"icon": {
|
||||||
|
"class": "fas fa-gauge"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
"muted": {
|
"muted": {
|
||||||
"name": "Switch",
|
"name": "Switch",
|
||||||
"name_plural": "Switches",
|
"name_plural": "Switches",
|
||||||
|
|
23
platypush/entities/pressure.py
Normal file
23
platypush/entities/pressure.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
from sqlalchemy import Column, Integer, ForeignKey
|
||||||
|
|
||||||
|
from platypush.common.db import Base
|
||||||
|
|
||||||
|
from .sensors import NumericSensor
|
||||||
|
|
||||||
|
|
||||||
|
if 'pressure_sensor' not in Base.metadata:
|
||||||
|
|
||||||
|
class PressureSensor(NumericSensor):
|
||||||
|
"""
|
||||||
|
A sensor that measures pressure.
|
||||||
|
"""
|
||||||
|
|
||||||
|
__tablename__ = 'pressure_sensor'
|
||||||
|
|
||||||
|
id = Column(
|
||||||
|
Integer, ForeignKey(NumericSensor.id, ondelete='CASCADE'), primary_key=True
|
||||||
|
)
|
||||||
|
|
||||||
|
__mapper_args__ = {
|
||||||
|
'polymorphic_identity': __tablename__,
|
||||||
|
}
|
|
@ -24,6 +24,7 @@ from platypush.entities.heart import HeartRateSensor
|
||||||
from platypush.entities.humidity import HumiditySensor
|
from platypush.entities.humidity import HumiditySensor
|
||||||
from platypush.entities.illuminance import IlluminanceSensor
|
from platypush.entities.illuminance import IlluminanceSensor
|
||||||
from platypush.entities.motion import MotionSensor
|
from platypush.entities.motion import MotionSensor
|
||||||
|
from platypush.entities.pressure import PressureSensor
|
||||||
from platypush.entities.sensors import BinarySensor, NumericSensor, RawSensor
|
from platypush.entities.sensors import BinarySensor, NumericSensor, RawSensor
|
||||||
from platypush.entities.steps import StepsSensor
|
from platypush.entities.steps import StepsSensor
|
||||||
from platypush.entities.temperature import TemperatureSensor
|
from platypush.entities.temperature import TemperatureSensor
|
||||||
|
@ -81,12 +82,20 @@ _property_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = {
|
||||||
min=conf.get('min', 0),
|
min=conf.get('min', 0),
|
||||||
max=conf.get('min', 100),
|
max=conf.get('min', 100),
|
||||||
),
|
),
|
||||||
'light level': lambda value, _: IlluminanceSensor(value=value),
|
'light level': lambda value, conf: IlluminanceSensor(
|
||||||
|
value=value,
|
||||||
|
unit=conf.get('unit'),
|
||||||
|
),
|
||||||
|
'luminance': lambda value, conf: IlluminanceSensor(
|
||||||
|
value=value,
|
||||||
|
unit=conf.get('unit'),
|
||||||
|
),
|
||||||
|
'motion': lambda value, _: MotionSensor(value=value),
|
||||||
'power': lambda value, conf: PowerSensor(
|
'power': lambda value, conf: PowerSensor(
|
||||||
value=value,
|
value=value,
|
||||||
unit=conf.get('unit', 'W'),
|
unit=conf.get('unit', 'W'),
|
||||||
),
|
),
|
||||||
'motion': lambda value, _: MotionSensor(value=value),
|
'pressure': lambda value, _: PressureSensor(value=value),
|
||||||
'steps': lambda value, _: StepsSensor(value=value),
|
'steps': lambda value, _: StepsSensor(value=value),
|
||||||
'temperature': lambda value, conf: TemperatureSensor(
|
'temperature': lambda value, conf: TemperatureSensor(
|
||||||
value=value,
|
value=value,
|
||||||
|
|
Loading…
Reference in a new issue