make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.28k stars 503 forks source link

All devices unavailable after updating HA core to 2024.5.0 #1872

Closed mad-tunes closed 5 months ago

mad-tunes commented 5 months ago

Describe the bug After updating HAs core to 2024.5.0, all devices (x16, of various types) show as unavailable.

To Reproduce Install HA core 2024.5.0 Restart HA All devices in TuyaLocal are unavailable

Expected behavior For TuyaLocal to keep on running as usual

Additional context Rebooting my HA VM leaves them still unavailable. Each comes back as I go down the list of devices and select 3 dots>Reload, but once I restart HA they all show as unavailable again.

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

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2024.5.0",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.12.2",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/London",
    "os_name": "Linux",
    "os_version": "6.6.25-haos",
    "supervisor": "2024.04.4",
    "host_os": "Home Assistant OS 12.2",
    "docker_version": "25.0.5",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {
    "auto_backup": {
      "documentation": "https://github.com/jcwillox/hass-auto-backup",
      "version": "1.4.1",
      "requirements": []
    },
    "extended_openai_conversation": {
      "documentation": "https://github.com/jekalmin/extended_openai_conversation",
      "version": "1.0.3",
      "requirements": [
        "openai~=1.3.8"
      ]
    },
    "spook_inverse": {
      "documentation": "https://spook.boo",
      "version": "3.0.1",
      "requirements": []
    },
    "localtuya": {
      "documentation": "https://github.com/rospogrigio/localtuya/",
      "version": "5.2.1",
      "requirements": []
    },
    "adaptive_lighting": {
      "documentation": "https://github.com/basnijholt/adaptive-lighting#readme",
      "version": "1.21.1",
      "requirements": [
        "ulid-transform"
      ]
    },
    "spook": {
      "documentation": "https://spook.boo",
      "version": "3.0.1",
      "requirements": []
    },
    "tuya_local": {
      "documentation": "https://github.com/make-all/tuya-local",
      "version": "2024.4.0",
      "requirements": [
        "tinytuya==1.13.2"
      ]
    },
    "watchman": {
      "documentation": "https://github.com/dummylabs/thewatchman",
      "version": "0.5.1",
      "requirements": [
        "prettytable==3.0.0"
      ]
    },
    "hacs": {
      "documentation": "https://hacs.xyz/docs/configuration/start",
      "version": "1.34.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    }
  },
  "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"
    ],
    "version": "2024.4.0",
    "is_built_in": false
  },
  "data": {
    "name": "Bedroom light",
    "type": "rgbcw_lightbulb",
    "device_id": "**REDACTED**",
    "device_cid": "",
    "local_key": "**REDACTED**",
    "host": "**REDACTED**",
    "protocol_version": 3.3,
    "tinytuya_version": "1.13.2",
    "api_version_set": 3.3,
    "api_version_used": 3.3,
    "api_working": false,
    "status": {},
    "cached_state": {
      "updated_at": 0
    },
    "pending_state": {},
    "connected": true,
    "force_dps": [],
    "home_assistant": {
      "name": "Bedroom light",
      "name_by_user": null,
      "disabled": false,
      "disabled_by": null,
      "entities": [
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": null,
          "device_class": null,
          "original_device_class": null,
          "icon": "mdi:ceiling-light-outline",
          "unit_of_measurement": null,
          "state": {
            "entity_id": "light.bedroom_light",
            "state": "unavailable",
            "attributes": {
              "min_color_temp_kelvin": 2700,
              "max_color_temp_kelvin": 6500,
              "min_mireds": 153,
              "max_mireds": 370,
              "effect_list": [
                "Scene",
                "Music"
              ],
              "supported_color_modes": [
                "color_temp",
                "hs"
              ],
              "icon": "mdi:ceiling-light-outline",
              "friendly_name": "Bedroom light",
              "supported_features": 4
            },
            "last_changed": "2024-05-02T00:54:30.097056+00:00",
            "last_reported": "2024-05-02T00:54:30.097056+00:00",
            "last_updated": "2024-05-02T00:54:30.097056+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.bedroom_light_scene",
            "state": "unavailable",
            "attributes": {
              "options": [
                "Night",
                "Read",
                "Working",
                "Leisure",
                "Soft",
                "Colorful",
                "Dazzling",
                "Gorgeous"
              ],
              "icon": "mdi:palette",
              "friendly_name": "Bedroom light Scene"
            },
            "last_changed": "2024-05-02T00:54:30.092435+00:00",
            "last_reported": "2024-05-02T00:54:30.092435+00:00",
            "last_updated": "2024-05-02T00:54:30.092435+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.bedroom_light_timer",
            "state": "unavailable",
            "attributes": {
              "min": 0.0,
              "max": 86400.0,
              "step": 1.0,
              "mode": "auto",
              "unit_of_measurement": "min",
              "friendly_name": "Bedroom light Timer"
            },
            "last_changed": "2024-05-02T00:54:29.847094+00:00",
            "last_reported": "2024-05-02T00:54:29.847094+00:00",
            "last_updated": "2024-05-02T00:54:29.847094+00:00"
          }
        }
      ]
    }
  }
}

Please check if there are messages from Tuya Local in the Home

Logger: py.warnings
Source: runner.py:190
First occurred: 01:54:51 (1 occurrences)
Last logged: 01:54:51

/usr/local/lib/python3.12/asyncio/base_events.py:1973: RuntimeWarning: coroutine 'TuyaLocalDevice.receive_loop' was never awaited handle = self._ready.popleft()

then

Logger: homeassistant
Source: helpers/frame.py:203
First occurred: 01:54:51 (16 occurrences)
Last logged: 01:54:51

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tuya_local/device.py", line 147, in actually_start
    self._refresh_task = self._hass.async_create_task(self.receive_loop())
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 816, in async_create_task
    self.verify_event_loop_thread("async_create_task")
  File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread
    frame.report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report
    _report_integration(what, integration_frame, level, error_if_integration)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration
    raise RuntimeError(
RuntimeError: Detected that custom integration 'tuya_local' calls async_create_task from a thread at custom_components/tuya_local/device.py, line 147: self._refresh_task = self._hass.async_create_task(self.receive_loop()). Please report it to the author of the 'tuya_local' custom integration.
boukamp commented 5 months ago

Got the same issue..

bb12489 commented 5 months ago

Same here

make-all commented 5 months ago

Duplicate of #1869 #1871

benzoid commented 5 months ago

Hi, I'm afraid after the 2024.5.2 update and a HA restart I get an

The following integrations and platforms could not be set up: tuya_local Please check your config and logs.

notification. The integration says "Not loaded" so it can't be reloaded to work like before. Sorry about the further hassle!

The logs read:

Logger: homeassistant.setup
Source: setup.py:322
First occurred: 17:03:58 (1 occurrences)
Last logged: 17:03:58

Setup failed for custom integration 'tuya_local': Unable to import component: No module named 'custom_components.tuya_local.helpers.config'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 322, in _async_setup_component
    component = await integration.async_get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1001, in async_get_component
    self._component_future.result()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 981, in async_get_component
    comp = await self.hass.async_add_import_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1041, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 144, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/tuya_local/__init__.py", line 27, in <module>
    from .device import async_delete_device, get_device_id, setup_device
  File "/config/custom_components/tuya_local/device.py", line 28, in <module>
    from .helpers.config import get_device_id
ModuleNotFoundError: No module named 'custom_components.tuya_local.helpers.config'
make-all commented 5 months ago

Your installation is corrupted somehow. Reinstall the new tuya-local version.

benzoid commented 5 months ago

Thanks. Reinstallation did the trick, all good now with 2024.5.2. Don't know what happened other than me trying to reload.

paky888 commented 3 months ago

I have some problem! How to resolve it?