Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
Minor syntax fix to regular expressions, to stop warnings that started appearing in 2024.2.0 HA release.
  • Loading branch information
robchandhok committed Feb 8, 2024
1 parent 7224ef3 commit f32cab8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions custom_components/entity_controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)),
Expand All @@ -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(
Expand All @@ -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:

Expand All @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f32cab8

Please sign in to comment.