mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 09:18:00 +01:00
Formatting
auto load to dependencies remove unneeded comments
This commit is contained in:
parent
5db3078199
commit
306fa914c5
6 changed files with 18 additions and 30 deletions
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "esphome/core/log.h"
|
||||
#include "seeed_mr60fda2.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue