From 00fffd4e0424bc5d61caaaf40460c051e8b3cede Mon Sep 17 00:00:00 2001 From: Thierry DUVERNOY Date: Sun, 26 Jan 2025 01:32:09 +0100 Subject: [PATCH] Validate crc for DS2408 --- esphome/components/dallas_pio/dallas_pio.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/esphome/components/dallas_pio/dallas_pio.py b/esphome/components/dallas_pio/dallas_pio.py index 5952fbea1a..44f1dd0fda 100644 --- a/esphome/components/dallas_pio/dallas_pio.py +++ b/esphome/components/dallas_pio/dallas_pio.py @@ -19,9 +19,11 @@ def validate_crc_option(config_list): reference = conf.get("reference", "").upper() if not reference or reference == "DS2413": continue - if reference == "DS2406" and "crc" not in conf: - raise cv.Invalid("Option 'crc' is required when 'reference' is DS2406.") - if reference != "DS2406" and "crc" in conf: + if reference in {"DS2406", "DS2408"} and "crc" not in conf: + raise cv.Invalid( + "Option 'crc' is required when 'reference' is DS2406 or DS2408." + ) + if reference not in {"DS2406", "DS2408"} and "crc" in conf: raise cv.Invalid("Option 'crc' is not supported for this reference.") return config_list