mirror of
https://github.com/esphome/esphome.git
synced 2025-03-19 09:08:16 +00:00
24 lines
779 B
Python
24 lines
779 B
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,
|
|
CONF_HAS_TARGET,
|
|
)
|
|
from . import CONF_MR24HPC1_ID, MR24HPC1Component
|
|
|
|
|
|
CONFIG_SCHEMA = {
|
|
cv.GenerateID(CONF_MR24HPC1_ID): cv.use_id(MR24HPC1Component),
|
|
cv.Optional(CONF_HAS_TARGET): binary_sensor.binary_sensor_schema(
|
|
device_class=DEVICE_CLASS_OCCUPANCY, icon="mdi:motion-sensor"
|
|
),
|
|
}
|
|
|
|
|
|
async def to_code(config):
|
|
mr24hpc1_component = await cg.get_variable(config[CONF_MR24HPC1_ID])
|
|
if has_target_config := config.get(CONF_HAS_TARGET):
|
|
sens = await binary_sensor.new_binary_sensor(has_target_config)
|
|
cg.add(mr24hpc1_component.set_has_target_binary_sensor(sens))
|