[rd03d][sim800l][tas58xx][bedjet][hoermann_hcp] Use the sub_* helpers for optional child entities (#20049)

This commit is contained in:
J. Nick Koston
2026-10-02 14:32:26 -04:00
committed by GitHub
parent 8a49ba7e98
commit 3cc4df4b3a
7 changed files with 22 additions and 34 deletions
+3 -7
View File
@@ -44,10 +44,6 @@ async def to_code(config: ConfigType) -> None:
await cg.register_component(var, config)
await register_bedjet_child(var, config)
if outlet_temperature_sensor := config.get(CONF_OUTLET_TEMPERATURE):
sensor_var = await sensor.new_sensor(outlet_temperature_sensor)
cg.add(var.set_outlet_temperature_sensor(sensor_var))
if ambient_temperature_sensor := config.get(CONF_AMBIENT_TEMPERATURE):
sensor_var = await sensor.new_sensor(ambient_temperature_sensor)
cg.add(var.set_ambient_temperature_sensor(sensor_var))
sensors = sensor.sub_sensors(config)
await sensors(CONF_OUTLET_TEMPERATURE, var.set_outlet_temperature_sensor)
await sensors(CONF_AMBIENT_TEMPERATURE, var.set_ambient_temperature_sensor)
@@ -35,16 +35,13 @@ CONFIG_SCHEMA = cv.All(
async def to_code(config: ConfigType) -> None:
parent = await cg.get_variable(config[CONF_HOERMANN_HCP_ID])
hub = await cg.get_variable(config[CONF_HOERMANN_HCP_ID])
if (conf := config.get(CONF_DOOR_STATE)) is not None:
var = await text_sensor.new_text_sensor(conf, parent)
var = await text_sensor.new_text_sensor(conf, hub)
await cg.register_component(var, conf)
# Only the identity sensors need the exchange with the motor compiled in.
if CONF_SERIAL_NUMBER in config or CONF_VERSION in config:
cg.add_define("USE_HOERMANN_HCP_IDENTITY")
if (conf := config.get(CONF_SERIAL_NUMBER)) is not None:
sens = await text_sensor.new_text_sensor(conf)
cg.add(parent.set_serial_number_text_sensor(sens))
if (conf := config.get(CONF_VERSION)) is not None:
sens = await text_sensor.new_text_sensor(conf)
cg.add(parent.set_version_text_sensor(sens))
text_sensors = text_sensor.sub_text_sensors(config)
await text_sensors(CONF_SERIAL_NUMBER, hub.set_serial_number_text_sensor)
await text_sensors(CONF_VERSION, hub.set_version_text_sensor)
+2 -3
View File
@@ -30,9 +30,8 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config: ConfigType) -> None:
hub = await cg.get_variable(config[CONF_RD03D_ID])
if target_config := config.get(CONF_TARGET):
sens = await binary_sensor.new_binary_sensor(target_config)
cg.add(hub.set_target_binary_sensor(sens))
binary_sensors = binary_sensor.sub_binary_sensors(config)
await binary_sensors(CONF_TARGET, hub.set_target_binary_sensor)
for i in range(MAX_TARGETS):
if target_config := config.get(f"target_{i + 1}"):
+2 -3
View File
@@ -79,9 +79,8 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config: ConfigType) -> None:
hub = await cg.get_variable(config[CONF_RD03D_ID])
if target_count_config := config.get(CONF_TARGET_COUNT):
sens = await sensor.new_sensor(target_count_config)
cg.add(hub.set_target_count_sensor(sens))
sensors = sensor.sub_sensors(config)
await sensors(CONF_TARGET_COUNT, hub.set_target_count_sensor)
for i in range(MAX_TARGETS):
if target_config := config.get(f"target_{i + 1}"):
+3 -4
View File
@@ -19,8 +19,7 @@ CONFIG_SCHEMA = {
async def to_code(config):
sim800l_component = await cg.get_variable(config[CONF_SIM800L_ID])
hub = await cg.get_variable(config[CONF_SIM800L_ID])
if CONF_REGISTERED in config:
sens = await binary_sensor.new_binary_sensor(config[CONF_REGISTERED])
cg.add(sim800l_component.set_registered_binary_sensor(sens))
binary_sensors = binary_sensor.sub_binary_sensors(config)
await binary_sensors(CONF_REGISTERED, hub.set_registered_binary_sensor)
+3 -4
View File
@@ -27,8 +27,7 @@ CONFIG_SCHEMA = {
async def to_code(config):
sim800l_component = await cg.get_variable(config[CONF_SIM800L_ID])
hub = await cg.get_variable(config[CONF_SIM800L_ID])
if CONF_RSSI in config:
sens = await sensor.new_sensor(config[CONF_RSSI])
cg.add(sim800l_component.set_rssi_sensor(sens))
sensors = sensor.sub_sensors(config)
await sensors(CONF_RSSI, hub.set_rssi_sensor)
+4 -5
View File
@@ -40,12 +40,11 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config: ConfigType) -> None:
parent = await cg.get_variable(config[CONF_TAS58XX_ID])
if sensor_config := config.get(CONF_HAVE_FAULT):
sens = await binary_sensor.new_binary_sensor(sensor_config)
cg.add(parent.set_have_fault_binary_sensor(sens))
hub = await cg.get_variable(config[CONF_TAS58XX_ID])
binary_sensors = binary_sensor.sub_binary_sensors(config)
await binary_sensors(CONF_HAVE_FAULT, hub.set_have_fault_binary_sensor)
for key in FAULT_SENSORS:
if sensor_config := config.get(key):
sens = await binary_sensor.new_binary_sensor(sensor_config)
fault = getattr(FaultSensor, f"FAULT_SENSOR_{key.upper()}")
cg.add(parent.set_fault_binary_sensor(fault, sens))
cg.add(hub.set_fault_binary_sensor(fault, sens))