Skip to content

Commit 640b072

Browse files
committed
Merge branch 'ratgdo32' of https://github.com/ratgdo/esphome-ratgdo into ratgdo32
2 parents 148cc18 + ace7fcd commit 640b072

19 files changed

+184
-80
lines changed

.github/dependabot.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "monthly"
12+
commit-message:
13+
prefix: "chore(ci): "
14+
groups:
15+
github-actions:
16+
patterns:
17+
- "*"

.github/workflows/build.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
fail-fast: false
7777
steps:
7878
- name: Checkout source code
79-
uses: actions/checkout@v3.3.0
79+
uses: actions/checkout@v4
8080
- name: Build firmware
8181
uses: ratgdo/esphome-build-action@main
8282
id: esphome-build
@@ -90,7 +90,7 @@ jobs:
9090
jq -s '{"name": "${{ matrix.firmware.name }}", "new_install_improv_wait_time": 15, "new_install_prompt_erase": true, "version": "${{ steps.esphome-build.outputs.esphome-version }}", "home_assistant_domain": "esphome", "new_install_skip_erase": false, "builds":.}' output/${{ steps.esphome-build.outputs.name }}/manifest.json > output/${{ matrix.firmware.manifest_filename }}
9191
9292
- name: Upload artifact
93-
uses: actions/upload-artifact@v3.1.2
93+
uses: actions/upload-artifact@v4.6.0
9494
with:
9595
name: ${{ matrix.firmware.name }}
9696
path: output
@@ -103,9 +103,9 @@ jobs:
103103
needs: build
104104
steps:
105105
- name: Checkout source code
106-
uses: actions/checkout@v3
106+
uses: actions/checkout@v4
107107
- name: Download built firmwares
108-
uses: actions/download-artifact@v3
108+
uses: actions/download-artifact@v4
109109
with:
110110
path: firmwares
111111
- name: Copy files
@@ -114,7 +114,7 @@ jobs:
114114
cp -R static/* output/
115115
cp -R firmwares/*/* output/
116116
- name: Upload GitHub Pages artifact
117-
uses: actions/upload-pages-artifact@v2.0.0
117+
uses: actions/upload-pages-artifact@v3.0.1
118118
with:
119119
path: output
120120

@@ -131,7 +131,7 @@ jobs:
131131
url: ${{ steps.deployment.outputs.page_url }}
132132
steps:
133133
- name: Setup Pages
134-
uses: actions/configure-pages@v2
134+
uses: actions/configure-pages@v5
135135
- name: Deploy to GitHub Pages
136136
id: deployment
137-
uses: actions/deploy-pages@v1.2.9
137+
uses: actions/deploy-pages@v4.0.5

.pre-commit-config.yaml

+9-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ repos:
88
- id: end-of-file-fixer
99
- id: check-added-large-files
1010
- repo: https://github.com/pre-commit/mirrors-clang-format
11-
rev: v19.1.2
11+
rev: v19.1.7
1212
hooks:
1313
- id: clang-format
1414
types_or:
1515
- "c++"
1616
- "c"
1717
- "cuda"
1818
args: [-style=Webkit, -i]
19+
- repo: https://github.com/PyCQA/isort
20+
rev: 6.0.0
21+
hooks:
22+
- id: isort
23+
- repo: https://github.com/psf/black
24+
rev: 25.1.0
25+
hooks:
26+
- id: black

base.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ external_components:
33
- source:
44
type: git
55
url: https://github.com/ratgdo/esphome-ratgdo
6-
ref: ratgdo32
6+
ref: main
77
refresh: 1s
88
# - source:
99
# type: local

base_drycontact.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ external_components:
44
- source:
55
type: git
66
url: https://github.com/ratgdo/esphome-ratgdo
7-
ref: ratgdo32
7+
ref: main
88
refresh: 1s
99
# - source:
1010
# type: local

base_secplusv1.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ external_components:
44
- source:
55
type: git
66
url: https://github.com/ratgdo/esphome-ratgdo
7-
ref: ratgdo32
7+
ref: main
88
refresh: 1s
99
# - source:
1010
# type: local

components/ratgdo/__init__.py

+59-36
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import esphome.config_validation as cv
33
import voluptuous as vol
44
from esphome import automation, pins
5-
from esphome.const import CONF_ID, CONF_TRIGGER_ID
65
from esphome.components import binary_sensor
6+
from esphome.const import CONF_ID, CONF_TRIGGER_ID
77

88
DEPENDENCIES = ["preferences"]
99
MULTI_CONF = True
@@ -44,43 +44,59 @@
4444
CONF_DRY_CONTACT_CLOSE_SENSOR = "dry_contact_close_sensor"
4545
CONF_DRY_CONTACT_SENSOR_GROUP = "dry_contact_sensor_group"
4646

47+
4748
def validate_protocol(config):
48-
if config.get(CONF_PROTOCOL, None) == PROTOCOL_DRYCONTACT and (CONF_DRY_CONTACT_CLOSE_SENSOR not in config or CONF_DRY_CONTACT_OPEN_SENSOR not in config):
49-
raise cv.Invalid("dry_contact_close_sensor and dry_contact_open_sensor are required when using protocol drycontact")
50-
if config.get(CONF_PROTOCOL, None) != PROTOCOL_DRYCONTACT and (CONF_DRY_CONTACT_CLOSE_SENSOR in config or CONF_DRY_CONTACT_OPEN_SENSOR in config):
51-
raise cv.Invalid("dry_contact_close_sensor and dry_contact_open_sensor are only valid when using protocol drycontact")
52-
# if config.get(CONF_PROTOCOL, None) == PROTOCOL_DRYCONTACT and CONF_DRY_CONTACT_OPEN_SENSOR not in config:
53-
# raise cv.Invalid("dry_contact_open_sensor is required when using protocol drycontact")
49+
if config.get(CONF_PROTOCOL, None) == PROTOCOL_DRYCONTACT and (
50+
CONF_DRY_CONTACT_CLOSE_SENSOR not in config
51+
or CONF_DRY_CONTACT_OPEN_SENSOR not in config
52+
):
53+
raise cv.Invalid(
54+
"dry_contact_close_sensor and dry_contact_open_sensor are required when using protocol drycontact"
55+
)
56+
if config.get(CONF_PROTOCOL, None) != PROTOCOL_DRYCONTACT and (
57+
CONF_DRY_CONTACT_CLOSE_SENSOR in config
58+
or CONF_DRY_CONTACT_OPEN_SENSOR in config
59+
):
60+
raise cv.Invalid(
61+
"dry_contact_close_sensor and dry_contact_open_sensor are only valid when using protocol drycontact"
62+
)
63+
# if config.get(CONF_PROTOCOL, None) == PROTOCOL_DRYCONTACT and CONF_DRY_CONTACT_OPEN_SENSOR not in config:
64+
# raise cv.Invalid("dry_contact_open_sensor is required when using protocol drycontact")
5465
return config
5566

67+
5668
CONFIG_SCHEMA = cv.All(
5769
cv.Schema(
58-
{
59-
cv.GenerateID(): cv.declare_id(RATGDO),
60-
cv.Optional(
61-
CONF_OUTPUT_GDO, default=DEFAULT_OUTPUT_GDO
62-
): pins.gpio_output_pin_schema,
63-
cv.Optional(
64-
CONF_INPUT_GDO, default=DEFAULT_INPUT_GDO
65-
): pins.gpio_input_pin_schema,
66-
cv.Optional(CONF_INPUT_OBST, default=DEFAULT_INPUT_OBST): cv.Any(
67-
cv.none, pins.gpio_input_pin_schema
68-
),
69-
cv.Optional(CONF_DISCRETE_OPEN_PIN): pins.gpio_output_pin_schema,
70-
cv.Optional(CONF_DISCRETE_CLOSE_PIN): pins.gpio_output_pin_schema,
71-
cv.Optional(CONF_ON_SYNC_FAILED): automation.validate_automation(
72-
{
73-
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(SyncFailed),
74-
}
75-
),
76-
cv.Optional(CONF_PROTOCOL, default=PROTOCOL_SECPLUSV2): cv.All(vol.In(
77-
SUPPORTED_PROTOCOLS
78-
)),
79-
# cv.Inclusive(CONF_DRY_CONTACT_OPEN_SENSOR,CONF_DRY_CONTACT_SENSOR_GROUP): cv.use_id(binary_sensor.BinarySensor),
80-
# cv.Inclusive(CONF_DRY_CONTACT_CLOSE_SENSOR,CONF_DRY_CONTACT_SENSOR_GROUP): cv.use_id(binary_sensor.BinarySensor),
81-
cv.Optional(CONF_DRY_CONTACT_OPEN_SENSOR): cv.use_id(binary_sensor.BinarySensor),
82-
cv.Optional(CONF_DRY_CONTACT_CLOSE_SENSOR): cv.use_id(binary_sensor.BinarySensor),
83-
}
70+
{
71+
cv.GenerateID(): cv.declare_id(RATGDO),
72+
cv.Optional(
73+
CONF_OUTPUT_GDO, default=DEFAULT_OUTPUT_GDO
74+
): pins.gpio_output_pin_schema,
75+
cv.Optional(
76+
CONF_INPUT_GDO, default=DEFAULT_INPUT_GDO
77+
): pins.gpio_input_pin_schema,
78+
cv.Optional(CONF_INPUT_OBST, default=DEFAULT_INPUT_OBST): cv.Any(
79+
cv.none, pins.gpio_input_pin_schema
80+
),
81+
cv.Optional(CONF_DISCRETE_OPEN_PIN): pins.gpio_output_pin_schema,
82+
cv.Optional(CONF_DISCRETE_CLOSE_PIN): pins.gpio_output_pin_schema,
83+
cv.Optional(CONF_ON_SYNC_FAILED): automation.validate_automation(
84+
{
85+
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(SyncFailed),
86+
}
87+
),
88+
cv.Optional(CONF_PROTOCOL, default=PROTOCOL_SECPLUSV2): cv.All(
89+
vol.In(SUPPORTED_PROTOCOLS)
90+
),
91+
# cv.Inclusive(CONF_DRY_CONTACT_OPEN_SENSOR,CONF_DRY_CONTACT_SENSOR_GROUP): cv.use_id(binary_sensor.BinarySensor),
92+
# cv.Inclusive(CONF_DRY_CONTACT_CLOSE_SENSOR,CONF_DRY_CONTACT_SENSOR_GROUP): cv.use_id(binary_sensor.BinarySensor),
93+
cv.Optional(CONF_DRY_CONTACT_OPEN_SENSOR): cv.use_id(
94+
binary_sensor.BinarySensor
95+
),
96+
cv.Optional(CONF_DRY_CONTACT_CLOSE_SENSOR): cv.use_id(
97+
binary_sensor.BinarySensor
98+
),
99+
}
84100
).extend(cv.COMPONENT_SCHEMA),
85101
validate_protocol,
86102
)
@@ -109,11 +125,18 @@ async def to_code(config):
109125
cg.add(var.set_input_obst_pin(pin))
110126

111127
if CONF_DRY_CONTACT_OPEN_SENSOR in config and config[CONF_DRY_CONTACT_OPEN_SENSOR]:
112-
dry_contact_open_sensor = await cg.get_variable(config[CONF_DRY_CONTACT_OPEN_SENSOR])
128+
dry_contact_open_sensor = await cg.get_variable(
129+
config[CONF_DRY_CONTACT_OPEN_SENSOR]
130+
)
113131
cg.add(var.set_dry_contact_open_sensor(dry_contact_open_sensor))
114132

115-
if CONF_DRY_CONTACT_CLOSE_SENSOR in config and config[CONF_DRY_CONTACT_CLOSE_SENSOR]:
116-
dry_contact_close_sensor = await cg.get_variable(config[CONF_DRY_CONTACT_CLOSE_SENSOR])
133+
if (
134+
CONF_DRY_CONTACT_CLOSE_SENSOR in config
135+
and config[CONF_DRY_CONTACT_CLOSE_SENSOR]
136+
):
137+
dry_contact_close_sensor = await cg.get_variable(
138+
config[CONF_DRY_CONTACT_CLOSE_SENSOR]
139+
)
117140
cg.add(var.set_dry_contact_close_sensor(dry_contact_close_sensor))
118141

119142
for conf in config.get(CONF_ON_SYNC_FAILED, []):

components/ratgdo/cover/__init__.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
CoverClosingTrigger = ratgdo_ns.class_(
1919
"CoverClosingTrigger", automation.Trigger.template()
2020
)
21-
CoverStateTrigger = ratgdo_ns.class_(
22-
"CoverStateTrigger", automation.Trigger.template()
23-
)
21+
CoverStateTrigger = ratgdo_ns.class_("CoverStateTrigger", automation.Trigger.template())
2422

2523
CONF_ON_OPENING = "on_opening"
2624
CONF_ON_CLOSING = "on_closing"

components/ratgdo/output/__init__.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,24 @@
88

99
from .. import RATGDO_CLIENT_SCHMEA, ratgdo_ns, register_ratgdo_child
1010

11-
DEPENDENCIES = ["esp32","ratgdo","rtttl"]
11+
DEPENDENCIES = ["esp32", "ratgdo", "rtttl"]
1212

1313
RATGDOOutput = ratgdo_ns.class_("RATGDOOutput", cg.Component)
1414
OutputType = ratgdo_ns.enum("OutputType")
1515

1616
CONF_TYPE = "type"
17-
TYPES = {
18-
"beeper": OutputType.RATGDO_BEEPER
19-
}
17+
TYPES = {"beeper": OutputType.RATGDO_BEEPER}
2018

2119
CONFIG_SCHEMA = cv.Schema(
2220
{
23-
cv.Required(CONF_ID): cv.declare_id(RATGDOOutput),
24-
cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True),
25-
cv.Required(CONF_RTTTL): cv.use_id(rtttl),
26-
cv.Required(CONF_SONG): cv.string
21+
cv.Required(CONF_ID): cv.declare_id(RATGDOOutput),
22+
cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True),
23+
cv.Required(CONF_RTTTL): cv.use_id(rtttl),
24+
cv.Required(CONF_SONG): cv.string,
2725
}
2826
).extend(RATGDO_CLIENT_SCHMEA)
2927

28+
3029
async def to_code(config):
3130
var = cg.new_Pvariable(config[CONF_ID])
3231
await cg.register_component(var, config)

components/ratgdo/sensor/__init__.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from esphome.const import CONF_ID
55
CONF_DISTANCE = "distance"
66

7+
CONF_DISTANCE = "distance"
8+
79
from .. import RATGDO_CLIENT_SCHMEA, ratgdo_ns, register_ratgdo_child
810

911
DEPENDENCIES = ["ratgdo"]
@@ -19,7 +21,7 @@
1921
"paired_devices_keypads": RATGDOSensorType.RATGDO_PAIRED_KEYPADS,
2022
"paired_devices_wall_controls": RATGDOSensorType.RATGDO_PAIRED_WALL_CONTROLS,
2123
"paired_devices_accessories": RATGDOSensorType.RATGDO_PAIRED_ACCESSORIES,
22-
"distance": RATGDOSensorType.RATGDO_DISTANCE
24+
"distance": RATGDOSensorType.RATGDO_DISTANCE,
2325
}
2426

2527

@@ -41,11 +43,8 @@ async def to_code(config):
4143
cg.add(var.set_ratgdo_sensor_type(config[CONF_TYPE]))
4244
await register_ratgdo_child(var, config)
4345

44-
if config['type'] == 'distance':
45-
cg.add_library(
46-
name="Wire",
47-
version=None
48-
)
46+
if config["type"] == "distance":
47+
cg.add_library(name="Wire", version=None)
4948
cg.add_library(
5049
name="vl53l4cx",
5150
repository="https://github.com/stm32duino/VL53L4CX",

components/ratgdo/sensor/ratgdo_sensor.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,21 @@ namespace ratgdo {
9090
objCount = pDistanceData->NumberOfObjectsFound;
9191

9292
for (int i = 0; i < distanceData.NumberOfObjectsFound; i++) {
93-
VL53L4CX_TargetRangeData_t *d = &pDistanceData->RangeData[i];
93+
VL53L4CX_TargetRangeData_t* d = &pDistanceData->RangeData[i];
9494
if (d->RangeStatus == 0) {
9595
maxDistance = std::max(maxDistance, d->RangeMilliMeter);
9696
maxDistance = maxDistance <= MIN_DISTANCE ? -1 : maxDistance;
9797
}
9898
}
9999

100-
if(maxDistance < 0) maxDistance = MAX_DISTANCE;
100+
if (maxDistance < 0)
101+
maxDistance = MAX_DISTANCE;
101102

102-
//maxDistance = objCount == 0 ? -1 : pDistanceData->RangeData[objCount - 1].RangeMilliMeter;
103-
/*
103+
// maxDistance = objCount == 0 ? -1 : pDistanceData->RangeData[objCount - 1].RangeMilliMeter;
104+
/*
104105
* if the sensor is pointed at glass, there are many error -1 readings which will fill the
105106
* vector with out of range data. The sensor should be sensitive enough to detect the floor
106-
* in most situations, but daylight and/or really high ceilings can cause long distance
107+
* in most situations, but daylight and/or really high ceilings can cause long distance
107108
* measurements to be out of range.
108109
*/
109110
this->parent_->set_distance_measurement(maxDistance);

components/ratgdo/switch/__init__.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import esphome.codegen as cg
22
import esphome.config_validation as cv
3-
from esphome.components import switch
43
from esphome import pins
4+
from esphome.components import switch
55
from esphome.const import CONF_ID, CONF_PIN
66

77
from .. import RATGDO_CLIENT_SCHMEA, ratgdo_ns, register_ratgdo_child
@@ -12,10 +12,7 @@
1212
SwitchType = ratgdo_ns.enum("SwitchType")
1313

1414
CONF_TYPE = "type"
15-
TYPES = {
16-
"learn": SwitchType.RATGDO_LEARN,
17-
"led": SwitchType.RATGDO_LED
18-
}
15+
TYPES = {"learn": SwitchType.RATGDO_LEARN, "led": SwitchType.RATGDO_LED}
1916

2017

2118
CONFIG_SCHEMA = (

0 commit comments

Comments
 (0)