From bc02728669645ff10d70e8211bde62c72cca6619 Mon Sep 17 00:00:00 2001 From: Snuffy2 Date: Wed, 12 Oct 2022 21:03:01 -0400 Subject: [PATCH] Fix potential street_ref error --- custom_components/places/sensor.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/custom_components/places/sensor.py b/custom_components/places/sensor.py index 041adc69..279fa4f6 100644 --- a/custom_components/places/sensor.py +++ b/custom_components/places/sensor.py @@ -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" @@ -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"