From 4c7ca41ba04781c82fe6f5e5493cd76c8a0a84a4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 22:32:47 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- components/ratgdo/output/__init__.py | 16 ++++++++-------- components/ratgdo/sensor/__init__.py | 10 ++++------ components/ratgdo/sensor/ratgdo_sensor.cpp | 11 ++++++----- components/ratgdo/switch/__init__.py | 7 ++----- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/components/ratgdo/output/__init__.py b/components/ratgdo/output/__init__.py index 957ac214..92a16163 100644 --- a/components/ratgdo/output/__init__.py +++ b/components/ratgdo/output/__init__.py @@ -2,31 +2,31 @@ import esphome.config_validation as cv from esphome.components import rtttl from esphome.const import CONF_ID + CONF_RTTTL = "rtttl" CONF_SONG = "song" from .. import RATGDO_CLIENT_SCHMEA, ratgdo_ns, register_ratgdo_child -DEPENDENCIES = ["esp32","ratgdo","rtttl"] +DEPENDENCIES = ["esp32", "ratgdo", "rtttl"] RATGDOOutput = ratgdo_ns.class_("RATGDOOutput", cg.Component) OutputType = ratgdo_ns.enum("OutputType") CONF_TYPE = "type" -TYPES = { - "beeper": OutputType.RATGDO_BEEPER -} +TYPES = {"beeper": OutputType.RATGDO_BEEPER} CONFIG_SCHEMA = cv.Schema( { - cv.Required(CONF_ID): cv.declare_id(RATGDOOutput), - cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True), - cv.Required(CONF_RTTTL): cv.use_id(rtttl), - cv.Required(CONF_SONG): cv.string + cv.Required(CONF_ID): cv.declare_id(RATGDOOutput), + cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True), + cv.Required(CONF_RTTTL): cv.use_id(rtttl), + cv.Required(CONF_SONG): cv.string, } ).extend(RATGDO_CLIENT_SCHMEA) + async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) await cg.register_component(var, config) diff --git a/components/ratgdo/sensor/__init__.py b/components/ratgdo/sensor/__init__.py index d87d3208..42b52b5d 100644 --- a/components/ratgdo/sensor/__init__.py +++ b/components/ratgdo/sensor/__init__.py @@ -2,6 +2,7 @@ import esphome.config_validation as cv from esphome.components import sensor from esphome.const import CONF_ID + CONF_DISTANCE = "distance" from .. import RATGDO_CLIENT_SCHMEA, ratgdo_ns, register_ratgdo_child @@ -19,7 +20,7 @@ "paired_devices_keypads": RATGDOSensorType.RATGDO_PAIRED_KEYPADS, "paired_devices_wall_controls": RATGDOSensorType.RATGDO_PAIRED_WALL_CONTROLS, "paired_devices_accessories": RATGDOSensorType.RATGDO_PAIRED_ACCESSORIES, - "distance": RATGDOSensorType.RATGDO_DISTANCE + "distance": RATGDOSensorType.RATGDO_DISTANCE, } @@ -41,11 +42,8 @@ async def to_code(config): cg.add(var.set_ratgdo_sensor_type(config[CONF_TYPE])) await register_ratgdo_child(var, config) - if config['type'] == 'distance': - cg.add_library( - name="Wire", - version=None - ) + if config["type"] == "distance": + cg.add_library(name="Wire", version=None) cg.add_library( name="vl53l4cx", repository="https://github.com/stm32duino/VL53L4CX", diff --git a/components/ratgdo/sensor/ratgdo_sensor.cpp b/components/ratgdo/sensor/ratgdo_sensor.cpp index 4a0d831d..8dc1f2df 100644 --- a/components/ratgdo/sensor/ratgdo_sensor.cpp +++ b/components/ratgdo/sensor/ratgdo_sensor.cpp @@ -90,20 +90,21 @@ namespace ratgdo { objCount = pDistanceData->NumberOfObjectsFound; for (int i = 0; i < distanceData.NumberOfObjectsFound; i++) { - VL53L4CX_TargetRangeData_t *d = &pDistanceData->RangeData[i]; + VL53L4CX_TargetRangeData_t* d = &pDistanceData->RangeData[i]; if (d->RangeStatus == 0) { maxDistance = std::max(maxDistance, d->RangeMilliMeter); maxDistance = maxDistance <= MIN_DISTANCE ? -1 : maxDistance; } } - if(maxDistance < 0) maxDistance = MAX_DISTANCE; + if (maxDistance < 0) + maxDistance = MAX_DISTANCE; - //maxDistance = objCount == 0 ? -1 : pDistanceData->RangeData[objCount - 1].RangeMilliMeter; - /* + // maxDistance = objCount == 0 ? -1 : pDistanceData->RangeData[objCount - 1].RangeMilliMeter; + /* * if the sensor is pointed at glass, there are many error -1 readings which will fill the * vector with out of range data. The sensor should be sensitive enough to detect the floor - * in most situations, but daylight and/or really high ceilings can cause long distance + * in most situations, but daylight and/or really high ceilings can cause long distance * measurements to be out of range. */ this->parent_->set_distance_measurement(maxDistance); diff --git a/components/ratgdo/switch/__init__.py b/components/ratgdo/switch/__init__.py index c13265b9..3d4c5756 100644 --- a/components/ratgdo/switch/__init__.py +++ b/components/ratgdo/switch/__init__.py @@ -1,7 +1,7 @@ import esphome.codegen as cg import esphome.config_validation as cv -from esphome.components import switch from esphome import pins +from esphome.components import switch from esphome.const import CONF_ID, CONF_PIN from .. import RATGDO_CLIENT_SCHMEA, ratgdo_ns, register_ratgdo_child @@ -12,10 +12,7 @@ SwitchType = ratgdo_ns.enum("SwitchType") CONF_TYPE = "type" -TYPES = { - "learn": SwitchType.RATGDO_LEARN, - "led": SwitchType.RATGDO_LED -} +TYPES = {"learn": SwitchType.RATGDO_LEARN, "led": SwitchType.RATGDO_LED} CONFIG_SCHEMA = (