From f32cab8fb3b1125708d4d0ac39f4b15f9d1df483 Mon Sep 17 00:00:00 2001 From: Rob Chandhok Date: Thu, 8 Feb 2024 15:36:35 -0800 Subject: [PATCH] Update __init__.py Minor syntax fix to regular expressions, to stop warnings that started appearing in 2024.2.0 HA release. --- custom_components/entity_controller/__init__.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/custom_components/entity_controller/__init__.py b/custom_components/entity_controller/__init__.py index 5313ff0..42f68cf 100644 --- a/custom_components/entity_controller/__init__.py +++ b/custom_components/entity_controller/__init__.py @@ -1117,10 +1117,10 @@ def config_times(self, config): # parsed_start = datetime.now() + timedelta(seconds=5) # parsed_end = datetime.now() + timedelta(seconds=10) # FOR OPTIONAL DEBUGGING: subsequently use normal delay - sparts = re.search("^(now\s*[+-]\s*\d+)", config.get(CONF_START_TIME)) + sparts = re.search(r"^(now\s*[+-]\s*\d+)", config.get(CONF_START_TIME)) if sparts is not None: self._start_time_private = sparts.group(1) - eparts = re.search("^(now\s*[+-]\s*\d+)", config.get(CONF_END_TIME)) + eparts = re.search(r"^(now\s*[+-]\s*\d+)", config.get(CONF_END_TIME)) if eparts is not None: self._end_time_private = eparts.group(1) @@ -1364,7 +1364,7 @@ def _parse_time(self, time_str, name=None): parsed_time = None sun = None offset = 0 - parts = re.search("^(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)$", str(time_str)) + parts = re.search(r"^(\d+)-(\d+)-(\d+)\s+(\d+):(\d+):(\d+)$", str(time_str)) if parts: this_time = datetime( int(parts.group(1)), @@ -1377,7 +1377,7 @@ def _parse_time(self, time_str, name=None): ) parsed_time = dt.as_local(this_time) else: - parts = re.search("^(\d+):(\d+):(\d+)$", str(time_str)) + parts = re.search(r"^(\d+):(\d+):(\d+)$", str(time_str)) if parts: today = dt.as_local(dt.now()) time_temp = time( @@ -1401,7 +1401,7 @@ def _parse_time(self, time_str, name=None): offset = 0 else: parts = re.search( - "^sunrise\s*([+-])\s*(\d+):(\d+):(\d+)$", str(time_str) + r"^sunrise\s*([+-])\s*(\d+):(\d+):(\d+)$", str(time_str) ) if parts: @@ -1424,7 +1424,7 @@ def _parse_time(self, time_str, name=None): parsed_time = self.sunrise(True) - td else: parts = re.search( - "^sunset\s*([+-])\s*(\d+):(\d+):(\d+)$", str(time_str) + r"^sunset\s*([+-])\s*(\d+):(\d+):(\d+)$", str(time_str) ) if parts: sun = "sunset" @@ -1714,7 +1714,7 @@ def debug_time_wrapper(self, timet): See config_times. """ s = timet - parts = re.search("^now\s*([+-])\s*(\d+)\s*\(?(\d+)?\)?$", timet) + parts = re.search(r"^now\s*([+-])\s*(\d+)\s*\(?(\d+)?\)?$", timet) if parts: sign = parts.group(1) first_delay = parts.group(3)