Fix some configs after #5181 (#5209)

This commit is contained in:
Jesse Hills 2023-08-07 11:48:23 +12:00 committed by GitHub
parent 0ae3fcb0b7
commit 00f9af70a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 27 additions and 22 deletions

View file

@ -89,8 +89,7 @@ async def to_code(config):
pin = await cg.gpio_pin_expression(config[CONF_PIN]) pin = await cg.gpio_pin_expression(config[CONF_PIN])
cg.add(var.set_pin(pin)) cg.add(var.set_pin(pin))
if raw := config.get(CONF_RAW): cg.add(var.set_output_raw(config[CONF_RAW]))
cg.add(var.set_output_raw(raw))
if attenuation := config.get(CONF_ATTENUATION): if attenuation := config.get(CONF_ATTENUATION):
if attenuation == "auto": if attenuation == "auto":

View file

@ -115,7 +115,7 @@ async def animation_action_to_code(config, action_id, template_arg, args):
paren = await cg.get_variable(config[CONF_ID]) paren = await cg.get_variable(config[CONF_ID])
var = cg.new_Pvariable(action_id, template_arg, paren) var = cg.new_Pvariable(action_id, template_arg, paren)
if frame := config.get(CONF_FRAME): if (frame := config.get(CONF_FRAME)) is not None:
template_ = await cg.templatable(frame, args, cg.uint16) template_ = await cg.templatable(frame, args, cg.uint16)
cg.add(var.set_frame(template_)) cg.add(var.set_frame(template_))
return var return var

View file

@ -48,5 +48,5 @@ async def to_code(config):
if time_id := config.get(CONF_TIME_ID): if time_id := config.get(CONF_TIME_ID):
time_ = await cg.get_variable(time_id) time_ = await cg.get_variable(time_id)
cg.add(var.set_time_id(time_)) cg.add(var.set_time_id(time_))
if receive_timeout := config.get(CONF_RECEIVE_TIMEOUT): if (receive_timeout := config.get(CONF_RECEIVE_TIMEOUT)) is not None:
cg.add(var.set_status_timeout(receive_timeout)) cg.add(var.set_status_timeout(receive_timeout))

View file

@ -467,7 +467,7 @@ def binary_sensor_schema(
async def setup_binary_sensor_core_(var, config): async def setup_binary_sensor_core_(var, config):
await setup_entity(var, config) await setup_entity(var, config)
if device_class := config.get(CONF_DEVICE_CLASS): if (device_class := config.get(CONF_DEVICE_CLASS)) is not None:
cg.add(var.set_device_class(device_class)) cg.add(var.set_device_class(device_class))
if publish_initial_state := config.get(CONF_PUBLISH_INITIAL_STATE): if publish_initial_state := config.get(CONF_PUBLISH_INITIAL_STATE):
cg.add(var.set_publish_initial_state(publish_initial_state)) cg.add(var.set_publish_initial_state(publish_initial_state))

View file

@ -74,8 +74,8 @@ async def to_code(config):
ibeacon_uuid = esp32_ble_tracker.as_hex_array(str(ibeacon_uuid)) ibeacon_uuid = esp32_ble_tracker.as_hex_array(str(ibeacon_uuid))
cg.add(var.set_ibeacon_uuid(ibeacon_uuid)) cg.add(var.set_ibeacon_uuid(ibeacon_uuid))
if ibeacon_major := config.get(CONF_IBEACON_MAJOR): if (ibeacon_major := config.get(CONF_IBEACON_MAJOR)) is not None:
cg.add(var.set_ibeacon_major(ibeacon_major)) cg.add(var.set_ibeacon_major(ibeacon_major))
if ibeacon_minor := config.get(CONF_IBEACON_MINOR): if (ibeacon_minor := config.get(CONF_IBEACON_MINOR)) is not None:
cg.add(var.set_ibeacon_minor(ibeacon_minor)) cg.add(var.set_ibeacon_minor(ibeacon_minor))

View file

@ -73,8 +73,8 @@ async def to_code(config):
ibeacon_uuid = esp32_ble_tracker.as_hex_array(str(ibeacon_uuid)) ibeacon_uuid = esp32_ble_tracker.as_hex_array(str(ibeacon_uuid))
cg.add(var.set_ibeacon_uuid(ibeacon_uuid)) cg.add(var.set_ibeacon_uuid(ibeacon_uuid))
if ibeacon_major := config.get(CONF_IBEACON_MAJOR): if (ibeacon_major := config.get(CONF_IBEACON_MAJOR)) is not None:
cg.add(var.set_ibeacon_major(ibeacon_major)) cg.add(var.set_ibeacon_major(ibeacon_major))
if ibeacon_minor := config.get(CONF_IBEACON_MINOR): if (ibeacon_minor := config.get(CONF_IBEACON_MINOR)) is not None:
cg.add(var.set_ibeacon_minor(ibeacon_minor)) cg.add(var.set_ibeacon_minor(ibeacon_minor))

View file

@ -17,11 +17,11 @@ CONF_ON_FRAME = "on_frame"
def validate_id(config): def validate_id(config):
if can_id := config.get(CONF_CAN_ID): can_id = config[CONF_CAN_ID]
id_ext = config[CONF_USE_EXTENDED_ID] id_ext = config[CONF_USE_EXTENDED_ID]
if not id_ext: if not id_ext:
if can_id > 0x7FF: if can_id > 0x7FF:
raise cv.Invalid("Standard IDs must be 11 Bit (0x000-0x7ff / 0-2047)") raise cv.Invalid("Standard IDs must be 11 Bit (0x000-0x7ff / 0-2047)")
return config return config

View file

@ -73,7 +73,7 @@ async def to_code(config):
sens = await text_sensor.new_text_sensor(version_config) sens = await text_sensor.new_text_sensor(version_config)
cg.add(var.set_version(sens)) cg.add(var.set_version(sens))
if baseline := config.get(CONF_BASELINE): if (baseline := config.get(CONF_BASELINE)) is not None:
cg.add(var.set_baseline(baseline)) cg.add(var.set_baseline(baseline))
if temperature_id := config.get(CONF_TEMPERATURE): if temperature_id := config.get(CONF_TEMPERATURE):

View file

@ -83,10 +83,13 @@ async def to_code(config):
config[CONF_OPEN_MOVING_CURRENT_THRESHOLD] config[CONF_OPEN_MOVING_CURRENT_THRESHOLD]
) )
) )
if open_obsticle_current_threshold := config.get( if (
CONF_OPEN_OBSTACLE_CURRENT_THRESHOLD open_obsticle_current_threshold := config.get(
): CONF_OPEN_OBSTACLE_CURRENT_THRESHOLD
)
) is not None:
cg.add(var.set_open_obstacle_current_threshold(open_obsticle_current_threshold)) cg.add(var.set_open_obstacle_current_threshold(open_obsticle_current_threshold))
cg.add(var.set_open_duration(config[CONF_OPEN_DURATION])) cg.add(var.set_open_duration(config[CONF_OPEN_DURATION]))
await automation.build_automation( await automation.build_automation(
var.get_open_trigger(), [], config[CONF_OPEN_ACTION] var.get_open_trigger(), [], config[CONF_OPEN_ACTION]
@ -100,19 +103,22 @@ async def to_code(config):
config[CONF_CLOSE_MOVING_CURRENT_THRESHOLD] config[CONF_CLOSE_MOVING_CURRENT_THRESHOLD]
) )
) )
if close_obsticle_current_threshold := config.get( if (
CONF_CLOSE_OBSTACLE_CURRENT_THRESHOLD close_obsticle_current_threshold := config.get(
): CONF_CLOSE_OBSTACLE_CURRENT_THRESHOLD
)
) is not None:
cg.add( cg.add(
var.set_close_obstacle_current_threshold(close_obsticle_current_threshold) var.set_close_obstacle_current_threshold(close_obsticle_current_threshold)
) )
cg.add(var.set_close_duration(config[CONF_CLOSE_DURATION])) cg.add(var.set_close_duration(config[CONF_CLOSE_DURATION]))
await automation.build_automation( await automation.build_automation(
var.get_close_trigger(), [], config[CONF_CLOSE_ACTION] var.get_close_trigger(), [], config[CONF_CLOSE_ACTION]
) )
cg.add(var.set_obstacle_rollback(config[CONF_OBSTACLE_ROLLBACK])) cg.add(var.set_obstacle_rollback(config[CONF_OBSTACLE_ROLLBACK]))
if max_duration := config.get(CONF_MAX_DURATION): if (max_duration := config.get(CONF_MAX_DURATION)) is not None:
cg.add(var.set_max_duration(max_duration)) cg.add(var.set_max_duration(max_duration))
cg.add(var.set_malfunction_detection(config[CONF_MALFUNCTION_DETECTION])) cg.add(var.set_malfunction_detection(config[CONF_MALFUNCTION_DETECTION]))
if malfunction_action := config.get(CONF_MALFUNCTION_ACTION): if malfunction_action := config.get(CONF_MALFUNCTION_ACTION):