From 9de67feccd4b4c3ec9f5db40573c07ecca4bcf32 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 21 May 2024 10:53:16 +1200 Subject: [PATCH] [remote_receiver] Add better error message for tolerance breaking change (#6784) --- esphome/components/remote_receiver/__init__.py | 8 +++++++- tests/components/remote_receiver/esp32-common.yaml | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/esphome/components/remote_receiver/__init__.py b/esphome/components/remote_receiver/__init__.py index 6fe20153f4..e5085bb33c 100644 --- a/esphome/components/remote_receiver/__init__.py +++ b/esphome/components/remote_receiver/__init__.py @@ -63,7 +63,13 @@ def validate_tolerance(value): if "%" in str(value): type_ = TYPE_PERCENTAGE else: - type_ = TYPE_TIME + try: + cv.positive_time_period_microseconds(value) + type_ = TYPE_TIME + except cv.Invalid as exc: + raise cv.Invalid( + "Tolerance must be a percentage or time. Configurations made before 2024.5.0 treated the value as a percentage." + ) from exc return TOLERANCE_SCHEMA( { diff --git a/tests/components/remote_receiver/esp32-common.yaml b/tests/components/remote_receiver/esp32-common.yaml index c2b5a2cf19..c3987f8cd9 100644 --- a/tests/components/remote_receiver/esp32-common.yaml +++ b/tests/components/remote_receiver/esp32-common.yaml @@ -3,6 +3,7 @@ remote_receiver: pin: ${pin} rmt_channel: ${rmt_channel} dump: all + tolerance: 25% on_abbwelcome: then: - logger.log: