mirror of
https://github.com/esphome/esphome.git
synced 2026-09-30 00:10:22 +00:00
[seeed_mr60fda2] Use the sub_* helpers for optional child entities (#19799)
This commit is contained in:
@@ -23,12 +23,8 @@ CONFIG_SCHEMA = {
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
mr60fda2_component = await cg.get_variable(config[CONF_MR60FDA2_ID])
|
||||
hub = 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))
|
||||
binary_sensors = binary_sensor.sub_binary_sensors(config)
|
||||
await binary_sensors(CONF_PEOPLE_EXIST, hub.set_people_exist_binary_sensor)
|
||||
await binary_sensors(CONF_FALL_DETECTED, hub.set_fall_detected_binary_sensor)
|
||||
|
||||
@@ -35,12 +35,7 @@ CONFIG_SCHEMA = {
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
mr60fda2_component = await cg.get_variable(config[CONF_MR60FDA2_ID])
|
||||
if get_radar_parameters_config := config.get(CONF_GET_RADAR_PARAMETERS):
|
||||
b = await button.new_button(get_radar_parameters_config)
|
||||
await cg.register_parented(b, config[CONF_MR60FDA2_ID])
|
||||
cg.add(mr60fda2_component.set_get_radar_parameters_button(b))
|
||||
if factory_reset_config := config.get(CONF_FACTORY_RESET):
|
||||
b = await button.new_button(factory_reset_config)
|
||||
await cg.register_parented(b, config[CONF_MR60FDA2_ID])
|
||||
cg.add(mr60fda2_component.set_factory_reset_button(b))
|
||||
hub = await cg.get_variable(config[CONF_MR60FDA2_ID])
|
||||
buttons = button.sub_buttons(config, parent=hub)
|
||||
await buttons(CONF_GET_RADAR_PARAMETERS, hub.set_get_radar_parameters_button)
|
||||
await buttons(CONF_FACTORY_RESET, hub.set_factory_reset_button)
|
||||
|
||||
@@ -35,25 +35,16 @@ CONFIG_SCHEMA = {
|
||||
|
||||
|
||||
async def to_code(config: ConfigType) -> None:
|
||||
mr60fda2_component = await cg.get_variable(config[CONF_MR60FDA2_ID])
|
||||
if install_height_config := config.get(CONF_INSTALL_HEIGHT):
|
||||
s = await select.new_select(
|
||||
install_height_config,
|
||||
options=["2.4m", "2.5m", "2.6m", "2.7m", "2.8m", "2.9m", "3.0m"],
|
||||
)
|
||||
await cg.register_parented(s, config[CONF_MR60FDA2_ID])
|
||||
cg.add(mr60fda2_component.set_install_height_select(s))
|
||||
if height_threshold_config := config.get(CONF_HEIGHT_THRESHOLD):
|
||||
s = await select.new_select(
|
||||
height_threshold_config,
|
||||
options=["0.0m", "0.1m", "0.2m", "0.3m", "0.4m", "0.5m", "0.6m"],
|
||||
)
|
||||
await cg.register_parented(s, config[CONF_MR60FDA2_ID])
|
||||
cg.add(mr60fda2_component.set_height_threshold_select(s))
|
||||
if sensitivity_config := config.get(CONF_SENSITIVITY):
|
||||
s = await select.new_select(
|
||||
sensitivity_config,
|
||||
options=["1", "2", "3"],
|
||||
)
|
||||
await cg.register_parented(s, config[CONF_MR60FDA2_ID])
|
||||
cg.add(mr60fda2_component.set_sensitivity_select(s))
|
||||
hub = await cg.get_variable(config[CONF_MR60FDA2_ID])
|
||||
selects = select.sub_selects(config, parent=hub)
|
||||
await selects(
|
||||
CONF_INSTALL_HEIGHT,
|
||||
hub.set_install_height_select,
|
||||
options=["2.4m", "2.5m", "2.6m", "2.7m", "2.8m", "2.9m", "3.0m"],
|
||||
)
|
||||
await selects(
|
||||
CONF_HEIGHT_THRESHOLD,
|
||||
hub.set_height_threshold_select,
|
||||
options=["0.0m", "0.1m", "0.2m", "0.3m", "0.4m", "0.5m", "0.6m"],
|
||||
)
|
||||
await selects(CONF_SENSITIVITY, hub.set_sensitivity_select, options=["1", "2", "3"])
|
||||
|
||||
Reference in New Issue
Block a user