Added PresenceSensor entities.

This commit is contained in:
Fabio Manganiello 2023-02-23 01:42:26 +01:00
parent 886b930e2f
commit a0556d3a42
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
4 changed files with 35 additions and 0 deletions

View file

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

View file

@ -111,6 +111,14 @@
}
},
"presence_sensor": {
"name": "Sensor",
"name_plural": "Sensors",
"icon": {
"class": "fas fa-person"
}
},
"link_quality": {
"name": "Link Quality",
"name_plural": "Link Qualities",

View file

@ -0,0 +1,23 @@
from sqlalchemy import Column, Integer, ForeignKey
from platypush.common.db import Base
from .sensors import BinarySensor
if 'presence_sensor' not in Base.metadata:
class PressureSensor(BinarySensor):
"""
A binary sensor that detects presence.
"""
__tablename__ = 'presence_sensor'
id = Column(
Integer, ForeignKey(BinarySensor.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 DewPointSensor, HumiditySensor
from platypush.entities.illuminance import IlluminanceSensor
from platypush.entities.motion import MotionSensor
from platypush.entities.presence import PresenceSensor
from platypush.entities.pressure import PressureSensor
from platypush.entities.sensors import BinarySensor, NumericSensor, RawSensor
from platypush.entities.steps import StepsSensor
@ -84,6 +85,7 @@ _property_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = {
value=value,
unit=conf.get('unit', 'kWh'),
),
'heart rate': lambda value, _: HeartRateSensor(value=value),
'humidity': lambda value, conf: HumiditySensor(
value=value,
unit=conf.get('unit', '%'),
@ -103,6 +105,7 @@ _property_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = {
value=value,
unit=conf.get('unit', 'W'),
),
'presence': lambda value, _: PresenceSensor(value=value),
'pressure': lambda value, conf: PressureSensor(
value=value,
unit=conf.get('unit'),