From 306fa914c517dbf9f8274fadc3b8cb77121df238 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:26:32 +1300 Subject: [PATCH] Formatting auto load to dependencies remove unneeded comments --- esphome/components/seeed_mr60fda2/__init__.py | 24 ++++--------------- .../seeed_mr60fda2/binary_sensor.py | 3 ++- .../seeed_mr60fda2/button/__init__.py | 7 ++++-- .../seeed_mr60fda2/seeed_mr60fda2.cpp | 2 +- .../seeed_mr60fda2/select/__init__.py | 8 +++---- .../components/seeed_mr60fda2/text_sensor.py | 4 ++-- 6 files changed, 18 insertions(+), 30 deletions(-) diff --git a/esphome/components/seeed_mr60fda2/__init__.py b/esphome/components/seeed_mr60fda2/__init__.py index a32bc20359..e79134deec 100644 --- a/esphome/components/seeed_mr60fda2/__init__.py +++ b/esphome/components/seeed_mr60fda2/__init__.py @@ -1,18 +1,14 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import uart +import esphome.config_validation as cv from esphome.const import CONF_ID -DEPENDENCIES = ["uart"] -# is the code owner of the relevant code base CODEOWNERS = ["@limengdu"] -# The current component or platform can be configured or defined multiple times in the same configuration file. +DEPENDENCIES = ["uart"] MULTI_CONF = True -# This line of code creates a new namespace called mr60fda2_ns. -# This namespace will be used as a prefix for all classes, functions and variables associated with the mr60fda2_ns component, ensuring that they do not conflict with the names of other components. mr60fda2_ns = cg.esphome_ns.namespace("seeed_mr60fda2") -# This MR24HPC1Component class will be a periodically polled UART device + MR60FDA2Component = mr60fda2_ns.class_( "MR60FDA2Component", cg.Component, uart.UARTDevice ) @@ -29,29 +25,17 @@ CONFIG_SCHEMA = ( .extend(cv.COMPONENT_SCHEMA) ) -# This code extends the current CONFIG_SCHEMA by adding all the configuration parameters for the UART device and components. -# This means that in the YAML configuration file, the user can use these parameters to configure this component. -CONFIG_SCHEMA = cv.All( - CONFIG_SCHEMA.extend(uart.UART_DEVICE_SCHEMA).extend(cv.COMPONENT_SCHEMA) -) - -# A verification mode was created to verify the configuration parameters of a UART device named "seeed_mr60fda2". -# This authentication mode requires that the device must have transmit and receive functionality, a parity mode of "NONE", and a stop bit of one. FINAL_VALIDATE_SCHEMA = uart.final_validate_device_schema( "seeed_mr60fda2", require_tx=True, require_rx=True, + baud_rate=115200, parity="NONE", stop_bits=1, ) -# The async def keyword is used to define a concurrent function. -# Concurrent functions are special functions designed to work with Python's asyncio library to support asynchronous I/O operations. async def to_code(config): - # This line of code creates a new Pvariable (a Python object representing a C++ variable) with the variable's ID taken from the configuration. var = cg.new_Pvariable(config[CONF_ID]) - # This line of code registers the newly created Pvariable as a component so that ESPHome can manage it at runtime. await cg.register_component(var, config) - # This line of code registers the newly created Pvariable as a device. await uart.register_uart_device(var, config) diff --git a/esphome/components/seeed_mr60fda2/binary_sensor.py b/esphome/components/seeed_mr60fda2/binary_sensor.py index d0e456b774..dc11005c11 100644 --- a/esphome/components/seeed_mr60fda2/binary_sensor.py +++ b/esphome/components/seeed_mr60fda2/binary_sensor.py @@ -2,9 +2,10 @@ import esphome.codegen as cg from esphome.components import binary_sensor import esphome.config_validation as cv from esphome.const import DEVICE_CLASS_OCCUPANCY + from . import CONF_MR60FDA2_ID, MR60FDA2Component -AUTO_LOAD = ["seeed_mr60fda2"] +DEPENDENCIES = ["seeed_mr60fda2"] CONF_PEOPLE_EXIST = "people_exist" diff --git a/esphome/components/seeed_mr60fda2/button/__init__.py b/esphome/components/seeed_mr60fda2/button/__init__.py index 32f82813a0..b5a5d14675 100644 --- a/esphome/components/seeed_mr60fda2/button/__init__.py +++ b/esphome/components/seeed_mr60fda2/button/__init__.py @@ -2,13 +2,16 @@ import esphome.codegen as cg from esphome.components import button import esphome.config_validation as cv from esphome.const import ( - DEVICE_CLASS_UPDATE, - ENTITY_CATEGORY_NONE, DEVICE_CLASS_RESTART, + DEVICE_CLASS_UPDATE, ENTITY_CATEGORY_DIAGNOSTIC, + ENTITY_CATEGORY_NONE, ) + from .. import CONF_MR60FDA2_ID, MR60FDA2Component, mr60fda2_ns +DEPENDENCIES = ["seeed_mr60fda2"] + GetRadarParametersButton = mr60fda2_ns.class_("GetRadarParametersButton", button.Button) ResetRadarButton = mr60fda2_ns.class_("ResetRadarButton", button.Button) diff --git a/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp b/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp index a3983b5723..d3e5491437 100644 --- a/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp +++ b/esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp @@ -1,5 +1,5 @@ -#include "esphome/core/log.h" #include "seeed_mr60fda2.h" +#include "esphome/core/log.h" #include diff --git a/esphome/components/seeed_mr60fda2/select/__init__.py b/esphome/components/seeed_mr60fda2/select/__init__.py index 7182d900a8..5a8ff20c0d 100644 --- a/esphome/components/seeed_mr60fda2/select/__init__.py +++ b/esphome/components/seeed_mr60fda2/select/__init__.py @@ -1,12 +1,12 @@ import esphome.codegen as cg from esphome.components import select import esphome.config_validation as cv -from esphome.const import ( - ENTITY_CATEGORY_CONFIG, - CONF_SENSITIVITY, -) +from esphome.const import CONF_SENSITIVITY, ENTITY_CATEGORY_CONFIG + from .. import CONF_MR60FDA2_ID, MR60FDA2Component, mr60fda2_ns +DEPENDENCIES = ["seeed_mr60fda2"] + InstallHeightSelect = mr60fda2_ns.class_("InstallHeightSelect", select.Select) HeightThresholdSelect = mr60fda2_ns.class_("HeightThresholdSelect", select.Select) SensitivitySelect = mr60fda2_ns.class_("SensitivitySelect", select.Select) diff --git a/esphome/components/seeed_mr60fda2/text_sensor.py b/esphome/components/seeed_mr60fda2/text_sensor.py index 519a79c05f..1c1ea6c2d2 100644 --- a/esphome/components/seeed_mr60fda2/text_sensor.py +++ b/esphome/components/seeed_mr60fda2/text_sensor.py @@ -2,13 +2,13 @@ import esphome.codegen as cg from esphome.components import text_sensor import esphome.config_validation as cv from esphome.const import ENTITY_CATEGORY_DIAGNOSTIC + from . import CONF_MR60FDA2_ID, MR60FDA2Component -AUTO_LOAD = ["seeed_mr60fda2"] +DEPENDENCIES = ["seeed_mr60fda2"] CONF_IS_FALL = "is_fall" -# The entity category for read only diagnostic values, for example RSSI, uptime or MAC Address CONFIG_SCHEMA = { cv.GenerateID(CONF_MR60FDA2_ID): cv.use_id(MR60FDA2Component), cv.Optional(CONF_IS_FALL): text_sensor.text_sensor_schema(