Skip to content

Commit

Permalink
fix: parsing config files broke with HA 2024.2.0 release. Closes #320
Browse files Browse the repository at this point in the history
fix: parsing config files broke with HA 2024.2.0 release
  • Loading branch information
danobot authored Feb 14, 2024
2 parents ef75fc3 + f32cab8 commit 06cfe55
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions custom_components/entity_controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from datetime import date, datetime, time, timedelta
from threading import Timer
import pprint
from typing import Optional
from typing import Optional, List

import homeassistant.helpers.config_validation as cv
import voluptuous as vol
Expand Down 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 @@ -1650,12 +1650,12 @@ def add(self, list, config, key=None):
else:
v = config

if type(v) is YamlObjects.NodeStrClass:
self.log.debug("Found string value %s for key %s, now adding to exiting list %s. (Type: %s)", v, key, list, type(v))
if isinstance(v,str):
self.log.debug("Found string value %s for key %s, now adding to existing list %s. (Type: %s)", v, key, list, type(v))
list.append(v)
return len(v) > 0
elif type(v) is YamlObjects.NodeListClass:
self.log.debug("Found list value %s for key %s, now adding to exiting list %s. (Type: %s)", v, key, list, type(v))
elif isinstance(v, List):
self.log.debug("Found list value %s for key %s, now adding to existing list %s. (Type: %s)", v, key, list, type(v))
list.extend(v)
return len(v) > 0
elif v == None:
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 06cfe55

Please sign in to comment.