Added support for illuminance sensor entities

This commit is contained in:
Fabio Manganiello 2022-11-27 22:38:58 +01:00
parent 03d1c554ea
commit 78c59f437a
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
3 changed files with 31 additions and 0 deletions

View File

@ -55,6 +55,14 @@
}
},
"illuminance_sensor": {
"name": "Sensor",
"name_plural": "Sensors",
"icon": {
"class": "fas fa-sun"
}
},
"light": {
"name": "Light",
"name_plural": "Lights",

View File

@ -0,0 +1,22 @@
from sqlalchemy import Column, Integer, ForeignKey
from .devices import entity_types_registry
from .sensors import NumericSensor
if not entity_types_registry.get('IlluminanceSensor'):
class IlluminanceSensor(NumericSensor):
__tablename__ = 'illuminance_sensor'
id = Column(
Integer, ForeignKey(NumericSensor.id, ondelete='CASCADE'), primary_key=True
)
__mapper_args__ = {
'polymorphic_identity': __tablename__,
}
entity_types_registry['IlluminanceSensor'] = IlluminanceSensor
else:
IlluminanceSensor = entity_types_registry['IlluminanceSensor']