From 062ac5f27d311c4935ef371ad31d07e6fc7ff249 Mon Sep 17 00:00:00 2001 From: Quentame Date: Fri, 11 Sep 2020 16:50:17 +0200 Subject: [PATCH] Fix missing position attribute for MeteoFranceAlertSensor (#39938) --- homeassistant/components/meteo_france/sensor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/meteo_france/sensor.py b/homeassistant/components/meteo_france/sensor.py index 1e4c9b1215f..3c88914aafd 100644 --- a/homeassistant/components/meteo_france/sensor.py +++ b/homeassistant/components/meteo_france/sensor.py @@ -79,9 +79,10 @@ class MeteoFranceSensor(CoordinatorEntity): """Initialize the Meteo-France sensor.""" super().__init__(coordinator) self._type = sensor_type - city_name = self.coordinator.data.position["name"] - self._name = f"{city_name} {SENSOR_TYPES[self._type][ENTITY_NAME]}" - self._unique_id = f"{self.coordinator.data.position['lat']},{self.coordinator.data.position['lon']}_{self._type}" + if hasattr(self.coordinator.data, "position"): + city_name = self.coordinator.data.position["name"] + self._name = f"{city_name} {SENSOR_TYPES[self._type][ENTITY_NAME]}" + self._unique_id = f"{self.coordinator.data.position['lat']},{self.coordinator.data.position['lon']}_{self._type}" @property def unique_id(self):