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

Cannot remove powerboard with child lock #1974

Closed
illuzn opened this issue Jun 4, 2024 · 0 comments
Closed

Cannot remove powerboard with child lock #1974

illuzn opened this issue Jun 4, 2024 · 0 comments

Comments

@illuzn
Copy link
Contributor

illuzn commented Jun 4, 2024

Describe the bug
I cannot remove my Arlec PB88UHA Series 2 Powerboard (which has failed).

Attempting to remove the device results in:

Error while removing entity lock.arlec_pb88uha_series_2_powerboard_child_lock
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1378, in async_remove
    await self.__async_remove_impl(force_remove)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1394, in __async_remove_impl
    await self.async_will_remove_from_hass()
  File "/config/custom_components/tuya_local/helpers/mixin.py", line 111, in async_will_remove_from_hass
    await self._device.async_unregister_entity(self)
  File "/config/custom_components/tuya_local/device.py", line 194, in async_unregister_entity
    await self.async_stop()
  File "/config/custom_components/tuya_local/device.py", line 169, in async_stop
    await self._refresh_task
  File "/config/custom_components/tuya_local/device.py", line 199, in receive_loop
    async for poll in self.async_receive():
  File "/config/custom_components/tuya_local/device.py", line 321, in async_receive
    await asyncio.sleep(0.1 if self.has_returned_state else 5)
  File "/usr/local/lib/python3.12/asyncio/tasks.py", line 665, in sleep
    return await future
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 910, in async_reset
    await entity.async_remove()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1383, in async_remove
    self.__remove_future.set_result(None)
asyncio.exceptions.InvalidStateError: invalid state

To Reproduce

  1. Add a device which has a lock component.
  2. Take the device offline (e.g. unplugging it).
  3. Lock will enter the unavailable state in HA.
  4. Attempt to remove device from tuya-local. It will fail with the above result.

Expected behavior
The device should remove itself gracefully.

Additional context
I did not remove the device from tuya-local for 1 month. I'm not sure if this has any bearing on the matter.

Device Diagnostics from HA below

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2024.5.5",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.12.2",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Australia/Adelaide",
    "os_name": "Linux",
    "os_version": "6.6.29-haos",
    "supervisor": "2024.05.1",
    "host_os": "Home Assistant OS 12.3",
    "docker_version": "25.0.5",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {
    "localtuya": {
      "documentation": "https://github.com/rospogrigio/localtuya/",
      "version": "5.2.1",
      "requirements": []
    },
    "rheem_eziset": {
      "documentation": "https://github.com/illuzn/rheem-eziset",
      "version": "2023.12.0",
      "requirements": []
    },
    "tuya_local": {
      "documentation": "https://github.com/make-all/tuya-local",
      "version": "2024.5.3",
      "requirements": [
        "tinytuya==1.13.2",
        "tuya-device-sharing-sdk==0.1.9"
      ]
    }
  },
  "integration_manifest": {
    "domain": "tuya_local",
    "name": "Tuya Local",
    "codeowners": [
      "@make-all"
    ],
    "config_flow": true,
    "dependencies": [],
    "documentation": "https://github.com/make-all/tuya-local",
    "integration_type": "device",
    "iot_class": "local_push",
    "issue_tracker": "https://github.com/make-all/tuya-local/issues",
    "requirements": [
      "tinytuya==1.13.2",
      "tuya-device-sharing-sdk==0.1.9"
    ],
    "version": "2024.5.3",
    "is_built_in": false
  },
  "data": {
    "name": "Arlec PB88UHA Series 2 Powerboard",
    "type": "arlec_pb88uha_s2_switch",
    "device_id": "**REDACTED**",
    "device_cid": "",
    "local_key": "**REDACTED**",
    "host": "**REDACTED**",
    "protocol_version": "auto",
    "tinytuya_version": "1.13.2",
    "api_version_set": 3.2,
    "api_version_used": 3.2,
    "api_working": false,
    "status": {},
    "cached_state": {
      "updated_at": 0
    },
    "pending_state": {},
    "connected": false,
    "force_dps": [],
    "home_assistant": {
      "name": "Arlec PB88UHA Series 2 Powerboard",
      "name_by_user": null,
      "disabled": false,
      "disabled_by": null,
      "entities": [
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "lock.arlec_pb88uha_series_2_powerboard_child_lock",
            "state": "unavailable",
            "attributes": {
              "friendly_name": "Arlec PB88UHA Series 2 Powerboard Child lock",
              "supported_features": 0
            },
            "last_changed": "2024-06-04T02:34:00.015946+00:00",
            "last_reported": "2024-06-04T05:01:14.715734+00:00",
            "last_updated": "2024-06-04T02:34:00.015946+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "select.arlec_pb88uha_series_2_powerboard_restore_power_state",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "options": [
                "Remember Last Status",
                "On",
                "Off"
              ],
              "friendly_name": "Restore power state",
              "supported_features": 0
            },
            "last_changed": "2024-06-04T02:34:00.020627+00:00",
            "last_reported": "2024-06-04T05:01:22.265315+00:00",
            "last_updated": "2024-06-04T05:01:22.265315+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "unit_of_measurement": "min",
          "state": {
            "entity_id": "number.arlec_pb88uha_series_2_powerboard_timer_switch_1",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "min": 0.0,
              "max": 1440.0,
              "step": 1.0,
              "mode": "auto",
              "friendly_name": "Timer switch 1",
              "supported_features": 0,
              "unit_of_measurement": "min"
            },
            "last_changed": "2024-06-04T02:34:00.009794+00:00",
            "last_reported": "2024-06-04T05:01:22.262152+00:00",
            "last_updated": "2024-06-04T05:01:22.262152+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "unit_of_measurement": "min",
          "state": {
            "entity_id": "number.arlec_pb88uha_series_2_powerboard_timer_switch_2",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "min": 0.0,
              "max": 1440.0,
              "step": 1.0,
              "mode": "auto",
              "friendly_name": "Timer switch 2",
              "supported_features": 0,
              "unit_of_measurement": "min"
            },
            "last_changed": "2024-06-04T02:34:00.010295+00:00",
            "last_reported": "2024-06-04T05:01:22.263308+00:00",
            "last_updated": "2024-06-04T05:01:22.263308+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "unit_of_measurement": "min",
          "state": {
            "entity_id": "number.arlec_pb88uha_series_2_powerboard_timer_switch_3",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "min": 0.0,
              "max": 1440.0,
              "step": 1.0,
              "mode": "auto",
              "friendly_name": "Timer switch 3",
              "supported_features": 0,
              "unit_of_measurement": "min"
            },
            "last_changed": "2024-06-04T02:34:00.010748+00:00",
            "last_reported": "2024-06-04T05:01:22.263978+00:00",
            "last_updated": "2024-06-04T05:01:22.263978+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "unit_of_measurement": "min",
          "state": {
            "entity_id": "number.arlec_pb88uha_series_2_powerboard_timer_switch_4",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "min": 0.0,
              "max": 1440.0,
              "step": 1.0,
              "mode": "auto",
              "friendly_name": "Timer switch 4",
              "supported_features": 0,
              "unit_of_measurement": "min"
            },
            "last_changed": "2024-06-04T02:34:00.011196+00:00",
            "last_reported": "2024-06-04T05:01:22.264585+00:00",
            "last_updated": "2024-06-04T05:01:22.264585+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "outlet",
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "switch.arlec_pb88uha_series_2_powerboard_outlet_1",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "device_class": "outlet",
              "friendly_name": "Outlet 1",
              "supported_features": 0
            },
            "last_changed": "2024-06-04T02:34:00.025143+00:00",
            "last_reported": "2024-06-04T05:01:22.254558+00:00",
            "last_updated": "2024-06-04T05:01:22.254558+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "outlet",
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "switch.arlec_pb88uha_series_2_powerboard_outlet_2",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "device_class": "outlet",
              "friendly_name": "Outlet 2",
              "supported_features": 0
            },
            "last_changed": "2024-06-04T02:34:00.025479+00:00",
            "last_reported": "2024-06-04T05:01:22.255847+00:00",
            "last_updated": "2024-06-04T05:01:22.255847+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "outlet",
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "switch.arlec_pb88uha_series_2_powerboard_outlet_3",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "device_class": "outlet",
              "friendly_name": "Outlet 3",
              "supported_features": 0
            },
            "last_changed": "2024-06-04T02:34:00.025786+00:00",
            "last_reported": "2024-06-04T05:01:22.257340+00:00",
            "last_updated": "2024-06-04T05:01:22.257340+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "outlet",
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "switch.arlec_pb88uha_series_2_powerboard_outlet_4",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "device_class": "outlet",
              "friendly_name": "Outlet 4",
              "supported_features": 0
            },
            "last_changed": "2024-06-04T02:34:00.026091+00:00",
            "last_reported": "2024-06-04T05:01:22.260964+00:00",
            "last_updated": "2024-06-04T05:01:22.260964+00:00"
          }
        }
      ]
    }
  }
}
@illuzn illuzn added the bug Something isn't working label Jun 4, 2024
make-all added a commit that referenced this issue Jun 4, 2024
When stopping the integration, we expect that a CancelledError will
be thrown, so catch it and continue as normal.

Issue #1974
@make-all make-all added awaiting confirmation Wating for confirmation the issue is solved unreleased Will be in next release and removed bug Something isn't working awaiting confirmation Wating for confirmation the issue is solved unreleased Will be in next release labels Jun 9, 2024
@make-all make-all closed this as completed Jun 9, 2024
timlaing pushed a commit to timlaing/tuya-local that referenced this issue Aug 8, 2024
When stopping the integration, we expect that a CancelledError will
be thrown, so catch it and continue as normal.

Issue make-all#1974
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants