diff --git a/homeassistant/components/sensor/luftdaten.py b/homeassistant/components/sensor/luftdaten.py index 8c5fcc15ec22c0..ac977e52fce6d2 100644 --- a/homeassistant/components/sensor/luftdaten.py +++ b/homeassistant/components/sensor/luftdaten.py @@ -18,7 +18,7 @@ from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle -REQUIREMENTS = ['luftdaten==0.1.1'] +REQUIREMENTS = ['luftdaten==0.1.3'] _LOGGER = logging.getLogger(__name__) @@ -114,17 +114,17 @@ def unit_of_measurement(self): @property def device_state_attributes(self): """Return the state attributes.""" - if self.luftdaten.data.meta is None: + try: + attr = { + ATTR_ATTRIBUTION: CONF_ATTRIBUTION, + ATTR_SENSOR_ID: self._sensor_id, + 'lat': self.luftdaten.data.meta['latitude'], + 'long': self.luftdaten.data.meta['longitude'], + } + return attr + except KeyError: return - attr = { - ATTR_ATTRIBUTION: CONF_ATTRIBUTION, - ATTR_SENSOR_ID: self._sensor_id, - 'lat': self.luftdaten.data.meta['latitude'], - 'long': self.luftdaten.data.meta['longitude'], - } - return attr - @asyncio.coroutine def async_update(self): """Get the latest data from luftdaten.info and update the state.""" diff --git a/requirements_all.txt b/requirements_all.txt index 5eb4361a436cd9..6c96a78c95df0d 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -451,7 +451,7 @@ liveboxplaytv==2.0.2 lmnotify==0.0.4 # homeassistant.components.sensor.luftdaten -luftdaten==0.1.1 +luftdaten==0.1.3 # homeassistant.components.sensor.lyft lyft_rides==0.2