Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Tile location accuracy bug #37233

Merged
merged 4 commits into from Jun 30, 2020
Merged

Fix Tile location accuracy bug #37233

merged 4 commits into from Jun 30, 2020

Conversation

bachya
Copy link
Contributor

@bachya bachya commented Jun 29, 2020

Proposed change

This PR fixes a bug where a missing Tile H or V accuracy parameter could throw an unhandled exception.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 馃 Silver
  • 馃 Gold
  • 馃弳 Platinum

@bachya bachya self-assigned this Jun 29, 2020
@project-bot project-bot bot added this to Needs review in Dev Jun 29, 2020
@bachya bachya added this to the 0.112.0 milestone Jun 29, 2020
@project-bot project-bot bot moved this from Needs review to By Code Owner in Dev Jun 29, 2020
@bdraco
Copy link
Member

bdraco commented Jun 29, 2020

Confirmed error

2020-06-29 22:15:33 ERROR (MainThread) [homeassistant.components.device_tracker] Error while setting up tile platform for device_tracker
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 186, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 451, in _async_add_entity
    entity.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 290, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 314, in _async_write_ha_state
    sstate = self.state
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/config_entry.py", line 105, in state
    self.hass, self.latitude, self.longitude, self.location_accuracy
  File "/usr/src/homeassistant/homeassistant/components/tile/device_tracker.py", line 90, in location_accuracy
    + self._tile["last_tile_state"]["v_accuracy"]
TypeError: unsupported operand type(s) for +: 'float' and 'NoneType'

@@ -84,6 +84,16 @@ def location_accuracy(self):

Value in meters.
"""
if self._tile["last_tile_state"].get("h_accuracy") and not self._tile[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you extract the variables first before checking. This is pretty unreadable.

@bdraco
Copy link
Member

bdraco commented Jun 29, 2020

Retested with this code as a custom_components, and the error persists

2020-06-29 22:55:38 ERROR (MainThread) [homeassistant.components.device_tracker] Error while setting up tile platform for device_tracker
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 186, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 451, in _async_add_entity
    entity.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 290, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 314, in _async_write_ha_state
    sstate = self.state
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/config_entry.py", line 105, in state
    self.hass, self.latitude, self.longitude, self.location_accuracy
  File "/config/custom_components/tile/device_tracker.py", line 98, in location_accuracy
    + self._tile["last_tile_state"]["v_accuracy"]
TypeError: unsupported operand type(s) for +: 'float' and 'NoneType'

@balloob
Copy link
Member

balloob commented Jun 29, 2020

That's my cleanup 馃檮 It looks like key exists but it has none values. Will fix.

@bachya
Copy link
Contributor Author

bachya commented Jun 29, 2020

Thanks for the help, @balloob. 馃憤

@bdraco
Copy link
Member

bdraco commented Jun 29, 2020

Error is gone after pulling latest sha

@balloob balloob merged commit 0f43476 into home-assistant:dev Jun 30, 2020
Dev automation moved this from By Code Owner to Done Jun 30, 2020
balloob added a commit that referenced this pull request Jun 30, 2020
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
@bachya bachya deleted the tile-bug branch June 30, 2020 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

tile errors on setup with new integration method
4 participants