From 1ec3446c560f3bda9f8a58ec0be6c0a0611c5458 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Mon, 7 Sep 2020 00:36:01 +0200 Subject: [PATCH] State condition can also accept an input_* Entity ID as state value (#39691) --- homeassistant/helpers/condition.py | 25 +++++++-- tests/helpers/test_condition.py | 82 ++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 4 deletions(-) diff --git a/homeassistant/helpers/condition.py b/homeassistant/helpers/condition.py index 473641b10a4..1b09348415c 100644 --- a/homeassistant/helpers/condition.py +++ b/homeassistant/helpers/condition.py @@ -4,6 +4,7 @@ from collections import deque from datetime import datetime, timedelta import functools as ft import logging +import re import sys from typing import Any, Callable, Container, List, Optional, Set, Union, cast @@ -48,6 +49,10 @@ ASYNC_FROM_CONFIG_FORMAT = "async_{}_from_config" _LOGGER = logging.getLogger(__name__) +INPUT_ENTITY_ID = re.compile( + r"^input_(?:select|text|number|boolean|datetime)\.(?!.+__)(?!_)[\da-z_]+(?