From c2df7a9d5517b8d83f09e2db130359f835d46184 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Fri, 16 Sep 2022 12:04:30 +1200 Subject: [PATCH] Optional section at start of obis code --- esphome/components/sml/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/sml/__init__.py b/esphome/components/sml/__init__.py index f3b6dd95ef..789732dfd6 100644 --- a/esphome/components/sml/__init__.py +++ b/esphome/components/sml/__init__.py @@ -32,7 +32,7 @@ async def to_code(config): def obis_code(value): value = cv.string(value) - match = re.match(r"^\d{1,3}-\d{1,3}:\d{1,3}\.\d{1,3}\.\d{1,3}$", value) + match = re.match(r"^(?:\d{1,3}-\d{1,3}:)?\d{1,3}\.\d{1,3}\.\d{1,3}$", value) if match is None: raise cv.Invalid(f"{value} is not a valid OBIS code") return value