Skip to content

Commit

Permalink
Fix failing update_info
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Oct 10, 2020
1 parent 476e078 commit 1e49671
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
3 changes: 2 additions & 1 deletion custom_components/googlehome/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ async def update_info(self, host):
_LOGGER.debug(device_info_data)
self._connected = bool(device_info_data)
self.hass.data[DOMAIN][host]["info"] = device_info_data
return
return True
return False

async def update_bluetooth(self, host, entry: config_entries.ConfigEntry):
"""Update bluetooth from Google Home."""
Expand Down
14 changes: 7 additions & 7 deletions custom_components/googlehome/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ async def async_setup_entry(hass, config_entry, async_see):
async def async_cast_discovered(discover: ChromecastInfo):
hass.data[DOMAIN].setdefault(discover.host, {})

await hass.data[CLIENT].update_info(discover.host)
info = hass.data[DOMAIN][discover.host].get("info", { "device_info": {} })
if info["device_info"]["capabilities"].get("bluetooth_supported", False):
scanner = GoogleHomeDeviceScanner(
hass, hass.data[CLIENT], config_entry, discover, async_see
)
return await scanner.async_init()
if await hass.data[CLIENT].update_info(discover.host):
info = hass.data[DOMAIN][discover.host].get("info", { "device_info": {} })
if info["device_info"]["capabilities"].get("bluetooth_supported", False):
scanner = GoogleHomeDeviceScanner(
hass, hass.data[CLIENT], config_entry, discover, async_see
)
return await scanner.async_init()

async_dispatcher_connect(hass, SIGNAL_CAST_DISCOVERED, async_cast_discovered)
for chromecast in hass.data[KNOWN_CHROMECAST_INFO_KEY].values():
Expand Down
28 changes: 14 additions & 14 deletions custom_components/googlehome/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async def async_cast_discovered(discover: ChromecastInfo):
hass.data[DOMAIN].setdefault(discover.host, {})

await hass.data[CLIENT].update_info(discover.host)
info = hass.data[DOMAIN][discover.host].get("info", { "device_info": {} })
if info["device_info"]["capabilities"].get("assistant_supported", False):
devices = []
for condition in SENSOR_TYPES:
device = GoogleHomeAlarm(
hass.data[CLIENT],
config_entry,
condition,
discover,
info.get("name", NAME),
)
devices.append(device)
async_add_entities(devices, True)
if await hass.data[CLIENT].update_info(discover.host):
info = hass.data[DOMAIN][discover.host].get("info", { "device_info": {} })
if info["device_info"]["capabilities"].get("assistant_supported", False):
devices = []
for condition in SENSOR_TYPES:
device = GoogleHomeAlarm(
hass.data[CLIENT],
config_entry,
condition,
discover,
info.get("name", NAME),
)
devices.append(device)
async_add_entities(devices, True)

async_dispatcher_connect(hass, SIGNAL_CAST_DISCOVERED, async_cast_discovered)
for chromecast in hass.data[KNOWN_CHROMECAST_INFO_KEY].values():
Expand Down

0 comments on commit 1e49671

Please sign in to comment.