make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.39k stars 535 forks source link

devices getting inaccessible status all the time #477

Closed heidricha closed 1 year ago

heidricha commented 1 year ago

The problem

all connected devices get inaccessible during the day, even if they are in the very same room with the wifi router. never get a warning from the cloud.

Expected behavior Inaccessible status should be shown in logs only if some device is really inaccessible for a time

Additional context I have got 2 Blitzwolf devices connected to directly the tuya cloud, without the BW branded interface, and two Gosund2 devices. All devices are smart sockets with measurement.

{
  "home_assistant": {
    "installation_type": "Home Assistant Container",
    "version": "2023.2.5",
    "dev": false,
    "hassio": false,
    "virtualenv": false,
    "python_version": "3.10.7",
    "docker": true,
    "arch": "aarch64",
    "timezone": "Europe/Budapest",
    "os_name": "Linux",
    "os_version": "5.10.78-7-osmc",
    "run_as_root": true
  },
  "custom_components": {
    "awesome_thermostat": {
      "version": "1.0.0",
      "requirements": []
    },
    "gismeteo": {
      "version": "2.5.1",
      "requirements": []
    },
    "average": {
      "version": "2.3.0",
      "requirements": []
    },
    "localtuya": {
      "version": "5.0.0",
      "requirements": []
    },
    "abalin_nameday": {
      "version": "0.0.4",
      "requirements": [
        "abalin_nameday==0.0.4"
      ]
    },
    "scheduler": {
      "version": "v0.0.0",
      "requirements": []
    },
    "hacs": {
      "version": "1.31.0",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    },
    "radioactivity_hu": {
      "version": "0.3.2",
      "requirements": []
    },
    "simple_thermostat": {
      "version": "1.0.2",
      "requirements": []
    },
    "tuya_local": {
      "version": "2022.2.4",
      "requirements": [
        "pycryptodome~=3.17",
        "tinytuya==1.10.3"
      ]
    },
    "pollen_hu": {
      "version": "0.0.6",
      "requirements": []
    },
    "thermal_comfort": {
      "version": "2.1.0",
      "requirements": []
    },
    "remote_homeassistant": {
      "version": "3.6",
      "requirements": []
    },
    "sonoff": {
      "version": "3.3.0",
      "requirements": [
        "pycryptodome>=3.6.6"
      ]
    }
  },
  "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": [
      "pycryptodome~=3.17",
      "tinytuya==1.10.3"
    ],
    "version": "2022.2.4",
    "is_built_in": false
  },
  "data": {
    "name": "dolgoz\u00f3 f\u0171t\u00e9s",
    "type": "smartplugv1",
    "device_id": "**REDACTED**",
    "local_key": "**REDACTED**",
    "host": "**REDACTED**",
    "protocol_version": "auto",
    "api_version_set": 3.3,
    "api_version_used": 3.3,
    "api_working": true,
    "status": {
      "6": 2364
    },
    "cached_state": {
      "updated_at": 1677520469.4466872,
      "1": true,
      "2": 0,
      "4": 0,
      "5": 0,
      "6": 2332,
      "7": false
    },
    "pending_state": {},
    "connected": true,
    "force_dps": [
      6,
      4,
      5
    ],
    "home_assistant": {
      "name": "dolgoz\u00f3 f\u0171t\u00e9s",
      "name_by_user": null,
      "disabled": false,
      "disabled_by": null,
      "entities": [
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "diagnostic",
          "device_class": null,
          "original_device_class": "voltage",
          "icon": null,
          "unit_of_measurement": "V",
          "state": {
            "entity_id": "sensor.dolgozo_futes_voltage",
            "state": "233.2",
            "attributes": {
              "state_class": "measurement",
              "unit_of_measurement": "V",
              "device_class": "voltage",
              "friendly_name": "dolgoz\u00f3 f\u0171t\u00e9s Voltage"
            },
            "last_changed": "2023-02-27T17:54:29.448867+00:00",
            "last_updated": "2023-02-27T17:54:29.448867+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "diagnostic",
          "device_class": null,
          "original_device_class": "current",
          "icon": null,
          "unit_of_measurement": "mA",
          "state": {
            "entity_id": "sensor.dolgozo_futes_current",
            "state": "0",
            "attributes": {
              "state_class": "measurement",
              "unit_of_measurement": "mA",
              "device_class": "current",
              "friendly_name": "dolgoz\u00f3 f\u0171t\u00e9s Current"
            },
            "last_changed": "2023-02-27T17:54:29.449451+00:00",
            "last_updated": "2023-02-27T17:54:29.449451+00:00"
          }
        },
        {
          "disabled": false,
          "disabled_by": null,
          "entity_category": "diagnostic",
          "device_class": null,
          "original_device_class": "power",
          "icon": null,
          "unit_of_measurement": "W",
          "state": {
            "entity_id": "sensor.dolgozo_futes_power",
            "state": "0.0",
            "attributes": {
              "state_class": "measurement",
              "unit_of_measurement": "W",
              "device_class": "power",
              "friendly_name": "dolgoz\u00f3 f\u0171t\u00e9s Power"
            },
            "last_changed": "2023-02-27T17:54:29.450044+00:00",
            "last_updated": "2023-02-27T17:54:29.450044+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.dolgozo_futes_timer",
            "state": "0.0",
            "attributes": {
              "min": 0.0,
              "max": 1440.0,
              "step": 1.0,
              "mode": "auto",
              "unit_of_measurement": "min",
              "icon": "mdi:timer",
              "friendly_name": "dolgoz\u00f3 f\u0171t\u00e9s Timer"
            },
            "last_changed": "2023-02-27T17:54:29.447384+00:00",
            "last_updated": "2023-02-27T17:54:29.447384+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.dolgozo_futes",
            "state": "on",
            "attributes": {
              "device_class": "outlet",
              "friendly_name": "dolgoz\u00f3 f\u0171t\u00e9s"
            },
            "last_changed": "2023-02-27T17:54:29.448099+00:00",
            "last_updated": "2023-02-27T17:54:29.448099+00:00"
          }
        }
      ]
    }
  }
}

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

Ez a hiba egy egyéni integrációból lett származtatva.

Logger: custom_components.tuya_local.device
Source: custom_components/tuya_local/device.py:174
Integration: Tuya Local (documentation, issues)
First occurred: 2023. február 26. 20:46:57 (978 occurrences)
Last logged: 18:57:09

Failed to refresh device state for dolgozó fűtés
Failed to refresh device state for erosito
Failed to refresh device state for zuhany fűtés
Failed to refresh device state for Hűtő
Logger: homeassistant.util.async_
Source: util/async_.py:182
First occurred: 2023. február 26. 20:46:00 (3 occurrences)
Last logged: 2023. február 26. 20:46:10

Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue to the custom integration author for tuya_local doing blocking calls at custom_components/tuya_local/device.py, line 65: self._api = tinytuya.Device(dev_id, address, local_key)

If applicable, add screenshots to help explain your problem.

make-all commented 1 year ago

If they are all going offline at the same time, I would suspect your router or HA device. Or possibly something like using the microwave oven.

ngbl-clv19 commented 1 year ago

Im getting it to. The devices works fine in "smart life"

make-all commented 1 year ago

Other things to check:

Did someone open the mobile app at the time they went offline? Does selecting polling in the config resolve the issue? Does downgrading tuya-local to 2022.4.3 resolve the issue?

heidricha commented 1 year ago

No mobile app activity I will try polling, thanks for the advice! I just noticed the issue with the latest version of tuya-local, may have existed before, but I didn't notice

Only Gosund2 devices goes offline all the time. Sorry for writing "all".

heidricha commented 1 year ago

just tried to set polling, but got a message, "Unable to connect to your device with those details. It could be an intermittent issue, or they may be incorrect."

przemyslaw-latoch commented 1 year ago

obraz This is how my smart plugs' status looks after updating to 2023.2.4. The first and second ones are Gosund ep2, and the last one is the Neo Smart Plug. The status of the devices keeps changing to "Unavailable" (every minute in Gosund). In the end, I downgraded to 2023.2.3, and the status is now stable (shown at the end of the chart on the right).

make-all commented 1 year ago

Every minute is a clear sign that the updatedps command is probably causing this. Since they are the smartplugv1 type, this can be easily differentiated from the smartplugv2 plugs, many of which seem to need the updatedps command.

heidricha commented 1 year ago

not every minute here... sorry for the language settings, I hope the images make it clear

kép

heidricha commented 1 year ago

Downgraded one version (to 2023.2.3), and the issue has completely gone. Also a final clarification: the issue affects ALL my devices, the Blitzworlfs, and the Gosunds too. All of them are smartplugv1 type

(Off: Tuya SHP-6 can be added with this version too, just needs a fixed protocol version.)

make-all commented 1 year ago

The 2023.2.4 change has been undone for smartplugv1 config. I have smartplugv2 plugs which do not require the change in 2023.2.4, but also do not seem to be affected by the change, so hopefully it is only the v1 plugs that are affected.