forked from platypush/platypush
Added PresenceSensor
entities.
This commit is contained in:
parent
886b930e2f
commit
a0556d3a42
4 changed files with 35 additions and 0 deletions
|
@ -0,0 +1 @@
|
||||||
|
Sensor.vue
|
|
@ -111,6 +111,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"presence_sensor": {
|
||||||
|
"name": "Sensor",
|
||||||
|
"name_plural": "Sensors",
|
||||||
|
"icon": {
|
||||||
|
"class": "fas fa-person"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
"link_quality": {
|
"link_quality": {
|
||||||
"name": "Link Quality",
|
"name": "Link Quality",
|
||||||
"name_plural": "Link Qualities",
|
"name_plural": "Link Qualities",
|
||||||
|
|
23
platypush/entities/presence.py
Normal file
23
platypush/entities/presence.py
Normal 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__,
|
||||||
|
}
|
|
@ -24,6 +24,7 @@ from platypush.entities.heart import HeartRateSensor
|
||||||
from platypush.entities.humidity import DewPointSensor, HumiditySensor
|
from platypush.entities.humidity import DewPointSensor, 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.presence import PresenceSensor
|
||||||
from platypush.entities.pressure import PressureSensor
|
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
|
||||||
|
@ -84,6 +85,7 @@ _property_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = {
|
||||||
value=value,
|
value=value,
|
||||||
unit=conf.get('unit', 'kWh'),
|
unit=conf.get('unit', 'kWh'),
|
||||||
),
|
),
|
||||||
|
'heart rate': lambda value, _: HeartRateSensor(value=value),
|
||||||
'humidity': lambda value, conf: HumiditySensor(
|
'humidity': lambda value, conf: HumiditySensor(
|
||||||
value=value,
|
value=value,
|
||||||
unit=conf.get('unit', '%'),
|
unit=conf.get('unit', '%'),
|
||||||
|
@ -103,6 +105,7 @@ _property_to_entity: Dict[str, Callable[[Any, Dict[str, Any]], Entity]] = {
|
||||||
value=value,
|
value=value,
|
||||||
unit=conf.get('unit', 'W'),
|
unit=conf.get('unit', 'W'),
|
||||||
),
|
),
|
||||||
|
'presence': lambda value, _: PresenceSensor(value=value),
|
||||||
'pressure': lambda value, conf: PressureSensor(
|
'pressure': lambda value, conf: PressureSensor(
|
||||||
value=value,
|
value=value,
|
||||||
unit=conf.get('unit'),
|
unit=conf.get('unit'),
|
||||||
|
|
Loading…
Reference in a new issue