mirror of
https://github.com/esphome/esphome.git
synced 2024-12-25 15:04:54 +01:00
Update sensor.py
This commit is contained in:
parent
bf86cf36a0
commit
d6210a9378
1 changed files with 25 additions and 0 deletions
|
@ -6,8 +6,12 @@ from esphome.const import (
|
||||||
CONF_BATTERY_LEVEL,
|
CONF_BATTERY_LEVEL,
|
||||||
CONF_ID,
|
CONF_ID,
|
||||||
CONF_ILLUMINANCE,
|
CONF_ILLUMINANCE,
|
||||||
|
CONF_HUMIDITY,
|
||||||
|
CONF_TEMPERATURE,
|
||||||
DEVICE_CLASS_BATTERY,
|
DEVICE_CLASS_BATTERY,
|
||||||
DEVICE_CLASS_ILLUMINANCE,
|
DEVICE_CLASS_ILLUMINANCE,
|
||||||
|
DEVICE_CLASS_HUMIDITY,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||||
STATE_CLASS_MEASUREMENT,
|
STATE_CLASS_MEASUREMENT,
|
||||||
UNIT_DEGREES,
|
UNIT_DEGREES,
|
||||||
|
@ -42,6 +46,18 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
device_class=DEVICE_CLASS_ILLUMINANCE,
|
device_class=DEVICE_CLASS_ILLUMINANCE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=STATE_CLASS_MEASUREMENT,
|
||||||
),
|
),
|
||||||
|
cv.Optional(CONF_HUMIDITY): sensor.sensor_schema(
|
||||||
|
unit_of_measurement=UNIT_PERCENT,
|
||||||
|
accuracy_decimals=2,
|
||||||
|
device_class=DEVICE_CLASS_HUMIDITY,
|
||||||
|
state_class=STATE_CLASS_MEASUREMENT,
|
||||||
|
),
|
||||||
|
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
|
||||||
|
unit_of_measurement=UNIT_DEGREES,
|
||||||
|
accuracy_decimals=2,
|
||||||
|
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||||
|
state_class=STATE_CLASS_MEASUREMENT,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -60,3 +76,12 @@ async def to_code(config):
|
||||||
if CONF_ILLUMINANCE in config:
|
if CONF_ILLUMINANCE in config:
|
||||||
sens = await sensor.new_sensor(config[CONF_ILLUMINANCE])
|
sens = await sensor.new_sensor(config[CONF_ILLUMINANCE])
|
||||||
cg.add(parent.set_illuminance(sens))
|
cg.add(parent.set_illuminance(sens))
|
||||||
|
|
||||||
|
if CONF_HUMIDITY in config:
|
||||||
|
sens = await sensor.new_sensor(config[CONF_HUMIDITY])
|
||||||
|
cg.add(parent.set_humidity(sens))
|
||||||
|
|
||||||
|
if CONF_TEMPERATUREE in config:
|
||||||
|
sens = await sensor.new_sensor(config[CONF_TEMPERATURE])
|
||||||
|
cg.add(parent.set_temperature(sens))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue