Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 3, 2025
1 parent 1fb6064 commit 4c7ca41
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 24 deletions.
16 changes: 8 additions & 8 deletions components/ratgdo/output/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 4 additions & 6 deletions components/ratgdo/sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
}


Expand All @@ -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",
Expand Down
11 changes: 6 additions & 5 deletions components/ratgdo/sensor/ratgdo_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions components/ratgdo/switch/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 = (
Expand Down

0 comments on commit 4c7ca41

Please sign in to comment.