Skip to content

Commit

Permalink
fix: fix handling of lack of bluetooth_state
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed Dec 31, 2020
1 parent b81966a commit 980b530
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/alexa_media/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ async def refresh(self, device=None, skip_api: bool = False):
self._capabilities = device["capabilities"]
self._cluster_members = device["clusterMembers"]
self._parent_clusters = device["parentClusters"]
self._bluetooth_state = device["bluetooth_state"]
self._bluetooth_state = device.get("bluetooth_state", {})
self._locale = device["locale"] if "locale" in device else "en-US"
self._timezone = device["timeZoneId"] if "timeZoneId" in device else "UTC"
self._dnd = device["dnd"] if "dnd" in device else None
Expand Down Expand Up @@ -654,7 +654,7 @@ async def async_select_source(self, source):
if source == "Local Speaker":
await self.alexa_api.disconnect_bluetooth()
self._source = "Local Speaker"
elif self._bluetooth_state["pairedDeviceList"] is not None:
elif self._bluetooth_state.get("pairedDeviceList"):
for devices in self._bluetooth_state["pairedDeviceList"]:
if devices["friendlyName"] == source:
await self.alexa_api.set_bluetooth(devices["address"])
Expand Down

0 comments on commit 980b530

Please sign in to comment.