mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Update template sensor to use async_track_template_result (#38940)
* Add template entity * Update template tracking to work for template sensors * add test for whitespace * Update homeassistant/helpers/config_validation.py * revert * fix * reduce * fix _refresh missing decorator * defer until start * do not throw errors during startup * defer tracking until start event Co-authored-by: Swamp-Ig <github@ninjateaparty.com>
This commit is contained in:
@@ -156,6 +156,17 @@ def boolean(value: Any) -> bool:
|
||||
raise vol.Invalid(f"invalid boolean value {value}")
|
||||
|
||||
|
||||
_WS = re.compile("\\s*")
|
||||
|
||||
|
||||
def whitespace(value: Any) -> str:
|
||||
"""Validate result contains only whitespace."""
|
||||
if isinstance(value, str) and _WS.fullmatch(value):
|
||||
return value
|
||||
|
||||
raise vol.Invalid(f"contains non-whitespace: {value}")
|
||||
|
||||
|
||||
def isdevice(value: Any) -> str:
|
||||
"""Validate that value is a real device."""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user