mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Fix Luftdaten.info data retrieval (#43471)
Fix Luftdaten.info data retrieval
This commit is contained in:
parent
db0dee1ab2
commit
f22f568169
@ -198,6 +198,7 @@ class LuftDatenData:
|
|||||||
try:
|
try:
|
||||||
await self.client.get_data()
|
await self.client.get_data()
|
||||||
|
|
||||||
|
if self.client.values:
|
||||||
self.data[DATA_LUFTDATEN] = self.client.values
|
self.data[DATA_LUFTDATEN] = self.client.values
|
||||||
self.data[DATA_LUFTDATEN].update(self.client.meta)
|
self.data[DATA_LUFTDATEN].update(self.client.meta)
|
||||||
|
|
||||||
|
@ -69,7 +69,10 @@ class LuftdatenSensor(Entity):
|
|||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
if self._data is not None:
|
if self._data is not None:
|
||||||
|
try:
|
||||||
return self._data[self.sensor_type]
|
return self._data[self.sensor_type]
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
@ -85,7 +88,10 @@ class LuftdatenSensor(Entity):
|
|||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return a unique, friendly identifier for this entity."""
|
"""Return a unique, friendly identifier for this entity."""
|
||||||
if self._data is not None:
|
if self._data is not None:
|
||||||
|
try:
|
||||||
return f"{self._data['sensor_id']}_{self.sensor_type}"
|
return f"{self._data['sensor_id']}_{self.sensor_type}"
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
@ -93,7 +99,10 @@ class LuftdatenSensor(Entity):
|
|||||||
self._attrs[ATTR_ATTRIBUTION] = DEFAULT_ATTRIBUTION
|
self._attrs[ATTR_ATTRIBUTION] = DEFAULT_ATTRIBUTION
|
||||||
|
|
||||||
if self._data is not None:
|
if self._data is not None:
|
||||||
|
try:
|
||||||
self._attrs[ATTR_SENSOR_ID] = self._data["sensor_id"]
|
self._attrs[ATTR_SENSOR_ID] = self._data["sensor_id"]
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
|
||||||
on_map = ATTR_LATITUDE, ATTR_LONGITUDE
|
on_map = ATTR_LATITUDE, ATTR_LONGITUDE
|
||||||
no_map = "lat", "long"
|
no_map = "lat", "long"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user