Update Tile platform to be async#15073
Conversation
| ATTR_VOIP_STATE: tile['tileState']['voip_state'], | ||
| }, | ||
| icon=DEFAULT_ICON) | ||
| except SessionExpiredError: |
There was a problem hiding this comment.
Only wrap the call that you expect to error with try... except. I think that's await self._client.tiles.all in this case.
|
|
||
| try: | ||
| await self._client.get_session() | ||
| await self._async_update() |
There was a problem hiding this comment.
If there's a TileError inside _async_update it won't bubble up here since it's caught inside the method. Does that matter or are we only expecting _client.get_session to error?
| self._hass, self._async_update, DEFAULT_SCAN_INTERVAL) | ||
|
|
||
| return True | ||
| except TileError as err: |
There was a problem hiding this comment.
Move this up to only wrap the call(s) that we expect to error.
| vol.Required(CONF_PASSWORD): cv.string, | ||
| vol.Optional(CONF_SHOW_INACTIVE, default=False): cv.boolean, | ||
| vol.Optional(CONF_MONITORED_VARIABLES): | ||
| vol.Optional(CONF_MONITORED_VARIABLES, default=list(DEVICE_TYPES)): |
| gps=( | ||
| tile['tileState']['latitude'], | ||
| tile['tileState']['longitude']), | ||
| attributes={ |
There was a problem hiding this comment.
missing whitespace around operator
| for tile in tiles: | ||
| await self._async_see( | ||
| dev_id='tile_{0}'.format(slugify(tile['name'])), | ||
| gps=( |
There was a problem hiding this comment.
missing whitespace around operator
| ) | ||
| for tile in tiles: | ||
| await self._async_see( | ||
| dev_id='tile_{0}'.format(slugify(tile['name'])), |
There was a problem hiding this comment.
unexpected indentation
missing whitespace around operator
| attributes=attrs, | ||
| icon=DEFAULT_ICON | ||
| ) | ||
| for tile in tiles: |
There was a problem hiding this comment.
continuation line under-indented for visual indent
| return | ||
|
|
||
| if not self.devices: | ||
| if not tiles: |
There was a problem hiding this comment.
continuation line under-indented for visual indent
| except SessionExpiredError: | ||
| _LOGGER.info('Session expired; trying again shortly') | ||
| return | ||
| except TileError as err: |
There was a problem hiding this comment.
continuation line under-indented for visual indent
| await self._client.asayn_init() | ||
| tiles = await self._client.tiles.all( | ||
| whitelist=self._types, show_inactive=self._show_inactive)) | ||
| except SessionExpiredError: |
There was a problem hiding this comment.
continuation line under-indented for visual indent
| try: | ||
| await self._client.asayn_init() | ||
| tiles = await self._client.tiles.all( | ||
| whitelist=self._types, show_inactive=self._show_inactive)) |
* Updated * Updated requirements * Added expired session handling * Changes * Member-requested changes * Bump to 2.0.2 * Bumping requirements * Better exception handling and tidying * Move asyncio stuff to HASS built-ins * Revising re-initi * Hound * Hound
* Updated * Updated requirements * Added expired session handling * Changes * Member-requested changes * Bump to 2.0.2 * Bumping requirements * Better exception handling and tidying * Move asyncio stuff to HASS built-ins * Revising re-initi * Hound * Hound
Description:
This PR:
Related issue (if applicable): N/A
Pull request in home-assistant.github.io with documentation (if applicable): N/A
Example entry for
configuration.yaml(if applicable):Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated in home-assistant.github.ioIf the code communicates with devices, web services, or third-party tools:
REQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py.- [ ] New files were added to.coveragerc.If the code does not interact with devices:
- [ ] Tests have been added to verify that the new code works.