Ambient Weather: Check for key existence before checking value (#115776)

This commit is contained in:
William Easton 2024-04-18 06:38:52 -05:00 committed by GitHub
parent a47c76fc40
commit aee620be9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -49,7 +49,7 @@ class AmbientWeatherEntity(Entity):
last_data = self._ambient.stations[self._mac_address][ATTR_LAST_DATA]
key = self.entity_description.key
available_key = TYPE_SOLARRADIATION if key == TYPE_SOLARRADIATION_LX else key
self._attr_available = last_data[available_key] is not None
self._attr_available = last_data.get(available_key) is not None
self.update_from_latest_data()
self.async_write_ha_state()