make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.35k stars 522 forks source link

Unable to remove device #2308

Closed bkbartk closed 1 month ago

bkbartk commented 1 month ago

This form is for reporting bugs. If you have encountered a bug, you should generally have some log messages or device diagnostics to show something is going wrong. If your problem is more of a question or a request for help, then Discussions is probably a more suitable venue.

Describe the bug My device is reset, and now I cannot add it anymore, for some reason there is any issue with the local key. So I try to remove the device but this gives me an error.

Logger: homeassistant.config_entries
Source: config_entries.py:819
First occurred: 21:49:41 (8 occurrences)
Last logged: 21:49:41

Error unloading entry medion_robot_s20_sw for vacuum
Error unloading entry medion_robot_s20_sw for sensor
Error unloading entry medion_robot_s20_sw for button
Error unloading entry medion_robot_s20_sw for select
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 819, in async_unload
    result = await component.async_unload_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/vacuum/__init__.py", line 181, in async_unload_entry
    return await component.async_unload_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 201, in async_unload_entry
    raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!

To Reproduce try to remove a not connected device

Expected behavior device will be removed Additional context also I have issues changing the local key.

If the bug involves a device, then please include device diagnostics from Settings / Devices & Services / Tuya Local (your device) / "1 device"

"data": {
    "name": "medion_robot_s20_sw",
    "type": "medion_s20_vacuum",
    "device_id": "**REDACTED**",
    "device_cid": "",
    "local_key": "**REDACTED**",
    "host": "**REDACTED**",
    "protocol_version": 3.3,
    "tinytuya_version": "1.15.1",
    "api_version_set": 3.3,
    "api_version_used": 3.3,
    "api_working": false,
    "status": {},
    "cached_state": {
      "updated_at": 0
    },
    "pending_state": {},
    "connected": false,
    "force_dps": [],
    "home_assistant": {
      "name": "medion_robot_s20_sw",
      "name_by_user": null,
      "disabled": false,
      "disabled_by": null,
      "entities": [
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": "battery",
          "icon": null,
          "unit_of_measurement": "%",
          "state": {
            "entity_id": "sensor.medion_robot_s20_sw_battery",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "state_class": "measurement",
              "device_class": "battery",
              "friendly_name": "Battery",
              "supported_features": 0,
              "unit_of_measurement": "%"
            },
            "last_changed": "2024-09-12T17:32:12.184489+00:00",
            "last_reported": "2024-09-16T19:46:35.901145+00:00",
            "last_updated": "2024-09-16T19:46:35.901145+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "diagnostic",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "unit_of_measurement": "%",
          "state": {
            "entity_id": "sensor.medion_robot_s20_sw_edge_brush",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "state_class": "measurement",
              "friendly_name": "Edge brush",
              "supported_features": 0,
              "unit_of_measurement": "%"
            },
            "last_changed": "2024-09-12T17:32:12.186167+00:00",
            "last_reported": "2024-09-16T19:46:35.901443+00:00",
            "last_updated": "2024-09-16T19:46:35.901443+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "diagnostic",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "unit_of_measurement": "%",
          "state": {
            "entity_id": "sensor.medion_robot_s20_sw_filter",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "state_class": "measurement",
              "friendly_name": "Filter",
              "supported_features": 0,
              "unit_of_measurement": "%"
            },
            "last_changed": "2024-09-12T17:32:12.187330+00:00",
            "last_reported": "2024-09-16T19:46:35.901678+00:00",
            "last_updated": "2024-09-16T19:46:35.901678+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "diagnostic",
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "unit_of_measurement": "m\u00b2",
          "state": {
            "entity_id": "sensor.medion_robot_s20_sw_clean_area",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "state_class": "measurement",
              "friendly_name": "Clean area",
              "supported_features": 0,
              "unit_of_measurement": "m\u00b2"
            },
            "last_changed": "2024-09-12T17:32:12.188566+00:00",
            "last_reported": "2024-09-16T19:46:35.901898+00:00",
            "last_updated": "2024-09-16T19:46:35.901898+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "diagnostic",
          "device_class": null,
          "original_device_class": "duration",
          "icon": null,
          "unit_of_measurement": "min",
          "state": {
            "entity_id": "sensor.medion_robot_s20_sw_clean_time",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "state_class": "measurement",
              "device_class": "duration",
              "friendly_name": "Clean time",
              "supported_features": 0,
              "unit_of_measurement": "min"
            },
            "last_changed": "2024-09-12T17:32:12.190193+00:00",
            "last_reported": "2024-09-16T19:46:35.902120+00:00",
            "last_updated": "2024-09-16T19:46:35.902120+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": "restart",
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "button.medion_robot_s20_sw_reset_edge_brush",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "device_class": "restart",
              "friendly_name": "Reset edge brush",
              "supported_features": 0
            },
            "last_changed": "2024-09-12T17:32:12.194595+00:00",
            "last_reported": "2024-09-16T19:46:35.902550+00:00",
            "last_updated": "2024-09-16T19:46:35.902550+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "config",
          "device_class": null,
          "original_device_class": "restart",
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "button.medion_robot_s20_sw_reset_filter",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "device_class": "restart",
              "friendly_name": "Reset filter",
              "supported_features": 0
            },
            "last_changed": "2024-09-12T17:32:12.195636+00:00",
            "last_reported": "2024-09-16T19:46:35.902893+00:00",
            "last_updated": "2024-09-16T19:46:35.902893+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": "button.medion_robot_s20_sw_factory_reset",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "friendly_name": "Factory reset",
              "supported_features": 0
            },
            "last_changed": "2024-09-12T17:32:12.197070+00:00",
            "last_reported": "2024-09-16T19:46:35.903208+00:00",
            "last_updated": "2024-09-16T19:46:35.903208+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": null,
          "icon": null,
          "unit_of_measurement": null,
          "state": {
            "entity_id": "vacuum.medion_robot_s20_sw",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "fan_speed_list": [
                "normal",
                "strong"
              ],
              "supported_features": 14271
            },
            "last_changed": "2024-09-12T17:32:12.200879+00:00",
            "last_reported": "2024-09-16T19:46:35.900445+00:00",
            "last_updated": "2024-09-16T19:46:35.900445+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.medion_robot_s20_sw_mop_control",
            "state": "unavailable",
            "attributes": {
              "restored": true,
              "options": [
                "Low",
                "Medium",
                "High"
              ],
              "icon": "mdi:format-color-fill",
              "friendly_name": "Mop control",
              "supported_features": 0
            },
            "last_changed": "2024-09-12T17:32:12.192567+00:00",
            "last_reported": "2024-09-16T19:46:44.040916+00:00",
            "last_updated": "2024-09-16T19:46:44.040916+00:00"
          }
        }
      ]
    }
  }
}

Please check if there are messages from Tuya Local in the Home Assistant log (Settings / System / Logs), and include those too.

Logger: homeassistant.config_entries
Source: config_entries.py:819
First occurred: 21:49:41 (8 occurrences)
Last logged: 21:49:41

Error unloading entry medion_robot_s20_sw for vacuum
Error unloading entry medion_robot_s20_sw for sensor
Error unloading entry medion_robot_s20_sw for button
Error unloading entry medion_robot_s20_sw for select
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 819, in async_unload
    result = await component.async_unload_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/vacuum/__init__.py", line 181, in async_unload_entry
    return await component.async_unload_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 201, in async_unload_entry
    raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!

If applicable, add screenshots to help explain your problem.

make-all commented 1 month ago

If the cause was this integration, I would expect a stack trace in the log mentioning an unhandled failure in this integration. With the current info, it seems like Home Assistant itself has gotten into an inconsistent state, but there might have been a message implicating this integration earlier in the log, when the device failed to load.

bkbartk commented 1 month ago

I have also those 2

This error originated from a custom integration.

Logger: custom_components.tuya_local.device
Source: custom_components/tuya_local/device.py:575
integration: Tuya Local (documentation, issues)
First occurred: September 12, 2024 at 19:32:56 (24254 occurrences)
Last logged: September 16, 2024 at 21:46:41

Failed to fetch device status for medion_robot_s20_sw
This error originated from a custom integration.

Logger: custom_components.tuya_local.device
Source: custom_components/tuya_local/device.py:451
integration: Tuya Local (documentation, issues)
First occurred: September 12, 2024 at 19:32:15 (11 occurrences)
Last logged: September 16, 2024 at 21:49:05

medion_robot_s20_sw protocol error 901: Network Error: Unable to Connect
Test protocol error 901: Network Error: Unable to Connect

But that doesn't tell me much.

I think I will try to reinstall the integration later.

make-all commented 1 month ago

901 is a connection failure, either due to a networking issue, or some other app or integration blocking the local connection to the device.

bkbartk commented 1 month ago

this might makes sence, a factory reset was applied, this means also a new id, but reconfigure does not allow to change the ID.

next to that, there were some special characters in my local key

Ei`/B.`DvM}p=B[H

(backquotes are hard to escape in github)

anyway, after a factory reset again I got a more normal key and now delete and add work without any issues.

So my assumption here is that backquotes are not allowed by the integration

make-all commented 1 month ago

It seems that the issue is resolved for you, and since there isn't enough info to followup, I will close this for now, though I expect there was something happening during the setup to leave it in an incomplete state.