mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 05:24:53 +01:00
parent
0ae3fcb0b7
commit
00f9af70a9
9 changed files with 27 additions and 22 deletions
|
@ -89,8 +89,7 @@ async def to_code(config):
|
|||
pin = await cg.gpio_pin_expression(config[CONF_PIN])
|
||||
cg.add(var.set_pin(pin))
|
||||
|
||||
if raw := config.get(CONF_RAW):
|
||||
cg.add(var.set_output_raw(raw))
|
||||
cg.add(var.set_output_raw(config[CONF_RAW]))
|
||||
|
||||
if attenuation := config.get(CONF_ATTENUATION):
|
||||
if attenuation == "auto":
|
||||
|
|
|
@ -115,7 +115,7 @@ async def animation_action_to_code(config, action_id, template_arg, args):
|
|||
paren = await cg.get_variable(config[CONF_ID])
|
||||
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)
|
||||
cg.add(var.set_frame(template_))
|
||||
return var
|
||||
|
|
|
@ -48,5 +48,5 @@ async def to_code(config):
|
|||
if time_id := config.get(CONF_TIME_ID):
|
||||
time_ = await cg.get_variable(time_id)
|
||||
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))
|
||||
|
|
|
@ -467,7 +467,7 @@ def binary_sensor_schema(
|
|||
async def setup_binary_sensor_core_(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))
|
||||
if publish_initial_state := config.get(CONF_PUBLISH_INITIAL_STATE):
|
||||
cg.add(var.set_publish_initial_state(publish_initial_state))
|
||||
|
|
|
@ -74,8 +74,8 @@ async def to_code(config):
|
|||
ibeacon_uuid = esp32_ble_tracker.as_hex_array(str(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))
|
||||
|
||||
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))
|
||||
|
|
|
@ -73,8 +73,8 @@ async def to_code(config):
|
|||
ibeacon_uuid = esp32_ble_tracker.as_hex_array(str(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))
|
||||
|
||||
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))
|
||||
|
|
|
@ -17,11 +17,11 @@ CONF_ON_FRAME = "on_frame"
|
|||
|
||||
|
||||
def validate_id(config):
|
||||
if can_id := config.get(CONF_CAN_ID):
|
||||
id_ext = config[CONF_USE_EXTENDED_ID]
|
||||
if not id_ext:
|
||||
if can_id > 0x7FF:
|
||||
raise cv.Invalid("Standard IDs must be 11 Bit (0x000-0x7ff / 0-2047)")
|
||||
can_id = config[CONF_CAN_ID]
|
||||
id_ext = config[CONF_USE_EXTENDED_ID]
|
||||
if not id_ext:
|
||||
if can_id > 0x7FF:
|
||||
raise cv.Invalid("Standard IDs must be 11 Bit (0x000-0x7ff / 0-2047)")
|
||||
return config
|
||||
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ async def to_code(config):
|
|||
sens = await text_sensor.new_text_sensor(version_config)
|
||||
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))
|
||||
|
||||
if temperature_id := config.get(CONF_TEMPERATURE):
|
||||
|
|
|
@ -83,10 +83,13 @@ async def to_code(config):
|
|||
config[CONF_OPEN_MOVING_CURRENT_THRESHOLD]
|
||||
)
|
||||
)
|
||||
if open_obsticle_current_threshold := config.get(
|
||||
CONF_OPEN_OBSTACLE_CURRENT_THRESHOLD
|
||||
):
|
||||
if (
|
||||
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_duration(config[CONF_OPEN_DURATION]))
|
||||
await automation.build_automation(
|
||||
var.get_open_trigger(), [], config[CONF_OPEN_ACTION]
|
||||
|
@ -100,19 +103,22 @@ async def to_code(config):
|
|||
config[CONF_CLOSE_MOVING_CURRENT_THRESHOLD]
|
||||
)
|
||||
)
|
||||
if close_obsticle_current_threshold := config.get(
|
||||
CONF_CLOSE_OBSTACLE_CURRENT_THRESHOLD
|
||||
):
|
||||
if (
|
||||
close_obsticle_current_threshold := config.get(
|
||||
CONF_CLOSE_OBSTACLE_CURRENT_THRESHOLD
|
||||
)
|
||||
) is not None:
|
||||
cg.add(
|
||||
var.set_close_obstacle_current_threshold(close_obsticle_current_threshold)
|
||||
)
|
||||
|
||||
cg.add(var.set_close_duration(config[CONF_CLOSE_DURATION]))
|
||||
await automation.build_automation(
|
||||
var.get_close_trigger(), [], config[CONF_CLOSE_ACTION]
|
||||
)
|
||||
|
||||
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_malfunction_detection(config[CONF_MALFUNCTION_DETECTION]))
|
||||
if malfunction_action := config.get(CONF_MALFUNCTION_ACTION):
|
||||
|
|
Loading…
Reference in a new issue