Fix missing position attribute for MeteoFranceAlertSensor (#39938)

pull/39947/head
Quentame 2020-09-11 16:50:17 +02:00 committed by GitHub
parent c2a9a39ee0
commit 062ac5f27d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -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):