1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-23 12:13:49 +01:00
Files
esphome/esphome/components/seeed_mr60fda2/binary_sensor.py
Citric Lee c0dcecc465 Add: Seeed Studio mr60fda2 mmwave sensor (#7576)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
Co-authored-by: Spencer Yan <spencer@spenyan.com>
2024-11-26 13:53:21 +13:00

34 lines
1.2 KiB
Python

import esphome.codegen as cg
from esphome.components import binary_sensor
import esphome.config_validation as cv
from esphome.const import DEVICE_CLASS_OCCUPANCY, DEVICE_CLASS_SAFETY
from . import CONF_MR60FDA2_ID, MR60FDA2Component
DEPENDENCIES = ["seeed_mr60fda2"]
CONF_PEOPLE_EXIST = "people_exist"
CONF_FALL_DETECTED = "fall_detected"
CONFIG_SCHEMA = {
cv.GenerateID(CONF_MR60FDA2_ID): cv.use_id(MR60FDA2Component),
cv.Optional(CONF_PEOPLE_EXIST): binary_sensor.binary_sensor_schema(
device_class=DEVICE_CLASS_OCCUPANCY, icon="mdi:motion-sensor"
),
cv.Optional(CONF_FALL_DETECTED): binary_sensor.binary_sensor_schema(
device_class=DEVICE_CLASS_SAFETY, icon="mdi:emergency"
),
}
async def to_code(config):
mr60fda2_component = await cg.get_variable(config[CONF_MR60FDA2_ID])
if people_exist_config := config.get(CONF_PEOPLE_EXIST):
sens = await binary_sensor.new_binary_sensor(people_exist_config)
cg.add(mr60fda2_component.set_people_exist_binary_sensor(sens))
if is_fall_config := config.get(CONF_FALL_DETECTED):
sens = await binary_sensor.new_binary_sensor(is_fall_config)
cg.add(mr60fda2_component.set_fall_detected_binary_sensor(sens))