Skip to content

Commit

Permalink
Extract core comments from esphome#6241 (esphome#6643)
Browse files Browse the repository at this point in the history
  • Loading branch information
javawizard authored Apr 26, 2024
1 parent cd91c70 commit 9bfb36f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions esphome/automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,20 @@


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": <value>}``, 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 ``{<conf>: <value>}``, 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")
Expand Down
2 changes: 1 addition & 1 deletion esphome/config_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
2 changes: 1 addition & 1 deletion esphome/core/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 9bfb36f

Please sign in to comment.