Added PressureSensor entities.

This commit is contained in:
Fabio Manganiello 2023-02-23 01:12:27 +01:00
parent dd3f683006
commit d212276247
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
4 changed files with 43 additions and 2 deletions

View file

@ -0,0 +1 @@
Sensor.vue

View file

@ -151,6 +151,14 @@
}
},
"pressure_sensor": {
"name": "Sensor",
"name_plural": "Sensors",
"icon": {
"class": "fas fa-gauge"
}
},
"muted": {
"name": "Switch",
"name_plural": "Switches",

View 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__,
}

View file

@ -24,6 +24,7 @@ from platypush.entities.heart import HeartRateSensor
from platypush.entities.humidity import HumiditySensor
from platypush.entities.illuminance import IlluminanceSensor
from platypush.entities.motion import MotionSensor
from platypush.entities.pressure import PressureSensor
from platypush.entities.sensors import BinarySensor, NumericSensor, RawSensor
from platypush.entities.steps import StepsSensor
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),
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(
value=value,
unit=conf.get('unit', 'W'),
),
'motion': lambda value, _: MotionSensor(value=value),
'pressure': lambda value, _: PressureSensor(value=value),
'steps': lambda value, _: StepsSensor(value=value),
'temperature': lambda value, conf: TemperatureSensor(
value=value,