From 9bfb36f58bcdaff1d5b62a2ea303d45a10af291e Mon Sep 17 00:00:00 2001 From: Alex Boyd Date: Fri, 26 Apr 2024 05:41:43 -0600 Subject: [PATCH] Extract core comments from #6241 (#6643) --- esphome/automation.py | 10 ++++++++++ esphome/config_validation.py | 2 +- esphome/core/component.h | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/esphome/automation.py b/esphome/automation.py index 8475858a9c..b25ffa5abe 100644 --- a/esphome/automation.py +++ b/esphome/automation.py @@ -18,10 +18,20 @@ from esphome.util import Registry def maybe_simple_id(*validators): + """Allow a raw ID to be specified in place of a config block. + If the value that's being validated is a dictionary, it's passed as-is to the specified validators. Otherwise, it's + wrapped in a dict that looks like ``{"id": }``, and that dict is then handed off to the specified validators. + """ return maybe_conf(CONF_ID, *validators) def maybe_conf(conf, *validators): + """Allow a raw value to be specified in place of a config block. + If the value that's being validated is a dictionary, it's passed as-is to the specified validators. Otherwise, it's + wrapped in a dict that looks like ``{: }``, and that dict is then handed off to the specified + validators. + (This is a general case of ``maybe_simple_id`` that allows the wrapping key to be something other than ``id``.) + """ validator = cv.All(*validators) @schema_extractor("maybe") diff --git a/esphome/config_validation.py b/esphome/config_validation.py index bc58979f33..198b44f38d 100644 --- a/esphome/config_validation.py +++ b/esphome/config_validation.py @@ -304,7 +304,7 @@ def string(value): """Validate that a configuration value is a string. If not, automatically converts to a string. Note that this can be lossy, for example the input value 60.00 (float) will be turned into - "60.0" (string). For values where this could be a problem `string_string` has to be used. + "60.0" (string). For values where this could be a problem `string_strict` has to be used. """ check_not_templatable(value) if isinstance(value, (dict, list)): diff --git a/esphome/core/component.h b/esphome/core/component.h index 4f244e5fcb..e6ffe96d1e 100644 --- a/esphome/core/component.h +++ b/esphome/core/component.h @@ -85,7 +85,7 @@ class Component { /** priority of setup(). higher -> executed earlier * - * Defaults to 0. + * Defaults to setup_priority::DATA, i.e. 600. * * @return The setup priority of this component */