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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zha: Add remove service #11683

Merged
merged 2 commits into from
Feb 12, 2018
Merged

zha: Add remove service #11683

merged 2 commits into from
Feb 12, 2018

Conversation

rcloran
Copy link
Contributor

@rcloran rcloran commented Jan 16, 2018

Description:

Related issue (if applicable): fixes #

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>

Example entry for configuration.yaml (if applicable):

Checklist:

  • The code change is tested and works locally.

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

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

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@@ -125,7 +145,8 @@ def device_left(self, device):

def device_removed(self, device):
"""Handle device being removed from the network."""
pass
for entity in self._device_registry[device.ieee]:

Choose a reason for hiding this comment

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

import 'entity' from line 15 shadowed by loop variable

@@ -13,6 +14,7 @@
from homeassistant import const as ha_const
from homeassistant.helpers import discovery, entity
from homeassistant.util import slugify
from homeassistant.util.async import run_coroutine_threadsafe

Choose a reason for hiding this comment

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

'homeassistant.util.async.run_coroutine_threadsafe' imported but unused

@rcloran
Copy link
Contributor Author

rcloran commented Jan 16, 2018

This seems to successfully remove a device, however, if I try to re-add the device without restarting home assistant, it complains that the entity already exists:

INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=548301917264-73>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: entity_id=light.sengled_e11g13_03064cb3_1, old_state=<state light.sengled_e11g13_03064cb3_1=off; supported_features=33, friendly_name=Sengled @ 2018-01-15T15:54:19.771414-08:00>, new_state=None>

...

INFO:homeassistant.components.zha:Permitting joins for 60s
...
ERROR:homeassistant.core:Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/home/russell/src/home-assistant/homeassistant/helpers/entity_component.py", line 399, in async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/home/russell/src/home-assistant/homeassistant/helpers/entity_component.py", line 237, in async_add_entity
    'Entity id already exists: {}'.format(entity.entity_id))
homeassistant.exceptions.HomeAssistantError: Entity id already exists: light.sengled_e11g13_03064cb3_1

Any tips on what I'm missing?

@dmulcahey
Copy link
Contributor

dmulcahey commented Jan 16, 2018

#10835 (and the forum post it references) seems to indicate that this is a limitation of hass if I'm reading it correctly.

@balloob
Copy link
Member

balloob commented Jan 16, 2018

#11691 should help with the re-adding issue.

@rcloran
Copy link
Contributor Author

rcloran commented Feb 11, 2018

Rebased on dev, and this now appears to work (including re-adding without restart). Thanks for adding a way to remove in core!

@balloob balloob merged commit 3b30504 into home-assistant:dev Feb 12, 2018
@balloob balloob mentioned this pull request Feb 22, 2018
@tylerakraft
Copy link

Sounds good, thank you.

@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants