Skip to content

Commit

Permalink
Fix potential street_ref error
Browse files Browse the repository at this point in the history
  • Loading branch information
Snuffy2 committed Oct 13, 2022
1 parent 8bf38b9 commit bc02728
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions custom_components/places/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,18 @@ def build_formatted_place(self):
formatted_place_array.append(
self.get_attr(ATTR_PLACE_CATEGORY).title().strip()
)
if not self.is_attr_blank(ATTR_STREET):
street = None
if self.is_attr_blank(ATTR_STREET) and not self.is_attr_blank(
ATTR_STREET_REF
):
street = self.get_attr(ATTR_STREET_REF).strip()
_LOGGER.debug(
"("
+ self.get_attr(CONF_NAME)
+ ") Using street_ref: "
+ str(street)
)
elif not self.is_attr_blank(ATTR_STREET):
if (
not self.is_attr_blank(ATTR_PLACE_CATEGORY)
and self.get_attr(ATTR_PLACE_CATEGORY).lower() == "highway"
Expand All @@ -1477,14 +1488,14 @@ def build_formatted_place(self):
+ ") Using street: "
+ str(street)
)
if self.is_attr_blank(ATTR_STREET_NUMBER):
formatted_place_array.append(street)
else:
formatted_place_array.append(
str(self.get_attr(ATTR_STREET_NUMBER)).strip()
+ " "
+ str(street)
)
if street and self.is_attr_blank(ATTR_STREET_NUMBER):
formatted_place_array.append(street)
elif street and not self.is_attr_blank(ATTR_STREET_NUMBER):
formatted_place_array.append(
str(self.get_attr(ATTR_STREET_NUMBER)).strip()
+ " "
+ str(street)
)
if (
not self.is_attr_blank(ATTR_PLACE_TYPE)
and self.get_attr(ATTR_PLACE_TYPE).lower() == "house"
Expand Down

0 comments on commit bc02728

Please sign in to comment.