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

Removing Devices/Scenes from Tuya/Smart Life app only removes entities and not devices #36876

Closed
gadgetchnnel opened this issue Jun 17, 2020 · 15 comments

Comments

@gadgetchnnel
Copy link
Contributor

gadgetchnnel commented Jun 17, 2020

The problem

When a device or a scene is removed from the Tuya or Smart Life app, the Tuya integration removes the entity for that device, but doesn't remove the device (which cannot be manually deleted as far as I can tell).

This can be demonstrated by:

  • Add a Scene to the Smart Life app
  • Wait for this to be picked up by the Tuya integration or call tuya.pull_devices
  • Remove the Scene
  • Wait for this to be picked up or call tuya.pull_devices

There will now be an empty device for that scene containing no entities.

Environment

  • Home Assistant Core release with the issue: 0.111.3
  • Last working Home Assistant Core release (if known):
  • Operating environment (Home Assistant/Supervised/Docker/venv): venv
  • Integration causing this issue: Tuya
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/tuya/

Problem-relevant configuration.yaml

Traceback/Error logs

Additional information

@probot-home-assistant
Copy link

Hey there @ollo69, mind taking a look at this issue as its been labeled with a integration (tuya) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

@ollo69
Copy link
Contributor

ollo69 commented Jun 17, 2020

This is strange because device should be automatically removed by PR #35106
Do you know if this was happening also with previous HA release?

@gadgetchnnel
Copy link
Contributor Author

This may have been a problem in 0.110 (I hadn't deleted any of my devices in 0.110) as before that Tuya was only configured via YAML and didn't have devices (only entities).

@gadgetchnnel
Copy link
Contributor Author

I even tried deleting and recreated the Tuya integration (which removed the phantom devices) in case this was to do with my setup having been migrated from YAML, but I can still reproduce this. After adding and deleting a scene, I get this:

image

image

I wonder if the earlier startup in 0.111 is somehow preventing the logic added in that PR from working as expected (e.g. cleanup trying to run before the device registry has loaded).

@ollo69
Copy link
Contributor

ollo69 commented Jun 18, 2020

May be another issue should be opened referencing the PR. I remember that when I implemented the Config Flow I initially put the piece of code requested to clean-up device registry and during PR revision was asked to me to remove this piece of code. I removed and tested and device was automatically deleted when no entity available, this was 0.110.
Did you try also removing other entity or only with scene?

@gadgetchnnel
Copy link
Contributor Author

I also tried removing a bulb, and that did the same (entities removed but device was still there).

@gadgetchnnel
Copy link
Contributor Author

gadgetchnnel commented Jun 23, 2020

@ollo69 It seems that a later PR #35977 changed this, so that devices are not deleted if they are not referenced by an entity but are still referenced by a config entity (the fact that devices which didn't have any entities but did have a config entry were being removed was apparently a bug). This would mean that the devices would only be removed if the whole Tuya config entity is removed. That PR was included in 0.110.2.

I don't know if this means that the logic to remove devices will need to be added into the Tuya integration.

@ollo69
Copy link
Contributor

ollo69 commented Jun 23, 2020

I'm trying to solve the issue with Tuya API (see issue #36744).
I will add again device removal with next PR, hoping also to be able to solve Tuya API issue.

@gadgetchnnel
Copy link
Contributor Author

I was thinking more about this, and dealing with the devices would probably be easier if every scene didn't create a new device as, at least for me, I'm more likely to be removing scenes than physical devices.
It makes sense for a bulb, switch, etc. to be a device but could scenes be potentially grouped under a single device?
(It doesn't seem that the scene devices work with device automations anyway, since they have no available triggers or actions.)

@ollo69
Copy link
Contributor

ollo69 commented Jul 6, 2020

I start to apply fix for this here, I will PR the fix to HA integration when we will found a solution for Tuya API issues.

@stale
Copy link

stale bot commented Oct 12, 2020

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 12, 2020
@tacus80
Copy link

tacus80 commented Oct 25, 2020

Sorry I have the same issue I can't delete some old device from Tuya. I tried to delete the Tuya integration but I can't too, any error just it doesn't delete. Finally I just disable it.

@stale stale bot removed the stale label Oct 25, 2020
@ollo69
Copy link
Contributor

ollo69 commented Oct 31, 2020

Sorry I have the same issue I can't delete some old device from Tuya. I tried to delete the Tuya integration but I can't too, any error just it doesn't delete. Finally I just disable it.

This specific issue will be fixed by PR #41375.
But if you have problem deleting the integration, may be you open a new issue providing log details so that the cause can be better analyzed.

@github-actions
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@danielo515
Copy link

So it is not possible to delete individual devices?
I am migrating to local tuya and I want to do it one device at a time, and then delete them from the normal tuya integration. Is that not possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants