Allow OpenUV entities to be unavailable (#31018)

* Allow OpenUV entities to be unavailable

* Empty commit to re-trigger build
This commit is contained in:
Aaron Bach 2020-01-20 13:33:58 -07:00 committed by GitHub
parent 1639432463
commit 662c12715e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View file

@ -124,7 +124,14 @@ class OpenUvSensor(OpenUvEntity):
async def async_update(self):
"""Update the state."""
data = self.openuv.data[DATA_UV]["result"]
data = self.openuv.data[DATA_UV].get("result")
if not data:
self._available = False
return
self._available = True
if self._sensor_type == TYPE_CURRENT_OZONE_LEVEL:
self._state = data["ozone"]
elif self._sensor_type == TYPE_CURRENT_UV_INDEX: