1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-15 23:28:13 +00:00

Validate crc for DS2408

This commit is contained in:
Thierry DUVERNOY 2025-01-26 01:32:09 +01:00
parent da5cd11732
commit 00fffd4e04

View File

@ -19,9 +19,11 @@ def validate_crc_option(config_list):
reference = conf.get("reference", "").upper() reference = conf.get("reference", "").upper()
if not reference or reference == "DS2413": if not reference or reference == "DS2413":
continue continue
if reference == "DS2406" and "crc" not in conf: if reference in {"DS2406", "DS2408"} and "crc" not in conf:
raise cv.Invalid("Option 'crc' is required when 'reference' is DS2406.") raise cv.Invalid(
if reference != "DS2406" and "crc" in conf: "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.") raise cv.Invalid("Option 'crc' is not supported for this reference.")
return config_list return config_list