tuya-local icon indicating copy to clipboard operation
tuya-local copied to clipboard

Reconnection timeout

Open VoyteckPL opened this issue 1 year ago • 11 comments

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 A clear and concise description of what the bug is. I have wifi fairland inverter plus pool heat pump which is far away from wifi router and sometimes it looses connection because of distance. When it looses connection it becomes unavailible in tuya local. When I check status in tuya app I can see it reconnected and I can use it but tuya local stays unavailible until I restart home assistant. After restart it is visible again.

To Reproduce Steps to reproduce the behavior including the device the issue was observed with:

Expected behavior A clear and concise description of what you expected to happen. A periodic check if device is connected and maybe some auto reconnect without reset of HA.

Additional context Add any other context about the problem here.

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

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

If applicable, add screenshots to help explain your problem.

VoyteckPL avatar Aug 20 '23 18:08 VoyteckPL

Is your protocol version set in the config to the actual version used by the device? If you don't know what this is, you should be able to see the detected protocol version in the device diagnostics if you download them while the device is working.

This will help to reestablish the connection more quickly, as the device may be getting stuck trying non-working protocol versions when trying to come back online.

make-all avatar Aug 21 '23 07:08 make-all

{ "home_assistant": { "installation_type": "Home Assistant OS", "version": "2023.8.3", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.11.4", "docker": true, "arch": "aarch64", "timezone": "Europe/Warsaw", "os_name": "Linux", "os_version": "6.1.21-v8", "supervisor": "2023.08.1", "host_os": "Home Assistant OS 10.4", "docker_version": "23.0.6", "chassis": "embedded", "run_as_root": true }, "custom_components": { "attributes": { "version": "1.2.1", "requirements": [] }, "tuya_local": { "version": "2023.8.0", "requirements": [ "pycryptodome~=3.18", "tinytuya==1.12.9" ] }, "sonoff": { "version": "3.5.2", "requirements": [ "pycryptodome>=3.6.6" ] }, "multiscrape": { "version": "6.5.0", "requirements": [ "lxml==4.9.1", "beautifulsoup4==4.11.1" ] }, "ariston": { "version": "0.15.2", "requirements": [ "ariston==0.15.2" ] }, "hacs": { "version": "1.32.1", "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": [ "pycryptodome~=3.18", "tinytuya==1.12.9" ], "version": "2023.8.0", "is_built_in": false }, "data": { "name": "Pompa Ciep\u0142a Basen", "type": "fairland_iphcr15_heatpump", "device_id": "**REDACTED**", "device_cid": "", "local_key": "**REDACTED**", "host": "**REDACTED**", "protocol_version": 3.3, "tinytuya_version": "1.12.9", "api_version_set": 3.3, "api_version_used": 3.3, "api_working": true, "status": {}, "cached_state": { "updated_at": 1692604946.558686, "1": true, "102": 29, "103": true, "104": 75, "105": "warm", "106": 31, "107": 18, "108": 40, "115": 0, "116": 0, "117": true }, "pending_state": {}, "connected": true, "force_dps": [], "home_assistant": { "name": "Pompa Ciep\u0142a Basen", "name_by_user": "Pompa Ciep\u0142a Basen", "disabled": false, "disabled_by": null, "entities": [ { "disabled": false, "disabled_by": null, "entity_category": null, "device_class": null, "original_device_class": null, "icon": null, "unit_of_measurement": null, "state": { "entity_id": "climate.basen", "state": "heat", "attributes": { "hvac_modes": [ "off", "heat", "cool", "heat_cool" ], "min_temp": 18, "max_temp": 40, "target_temp_step": 1.0, "preset_modes": [ "sleep", "boost" ], "current_temperature": 29, "temperature": 31, "preset_mode": "boost", "mode": "warm", "error": "OK", "error_2": 0, "icon": "mdi:hot-tub", "friendly_name": "Basen", "supported_features": 17 }, "last_changed": "2023-08-21T07:56:41.261147+00:00", "last_updated": "2023-08-21T08:00:11.606658+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": "diagnostic", "device_class": null, "original_device_class": "power_factor", "icon": null, "unit_of_measurement": "%", "state": { "entity_id": "sensor.basen_predkosc_wentylatora", "state": "75", "attributes": { "state_class": "measurement", "unit_of_measurement": "%", "device_class": "power_factor", "icon": "mdi:signal", "friendly_name": "Basen Pr\u0119dko\u015b\u0107 Wentylatora" }, "last_changed": "2023-08-21T08:02:26.559719+00:00", "last_updated": "2023-08-21T08:02:26.559719+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": "diagnostic", "device_class": null, "original_device_class": "problem", "icon": null, "unit_of_measurement": null, "state": { "entity_id": "binary_sensor.basen_przeplyw", "state": "off", "attributes": { "device_class": "problem", "friendly_name": "Basen Przep\u0142yw" }, "last_changed": "2023-08-21T07:56:41.252596+00:00", "last_updated": "2023-08-21T07:56:41.252596+00:00" } } ] } } }

It is set to 3.3

image

VoyteckPL avatar Aug 21 '23 08:08 VoyteckPL

However IP address is set to Auto. This may also interfere with reconnection.

make-all avatar Aug 21 '23 08:08 make-all

Ok thanks!

VoyteckPL avatar Aug 21 '23 18:08 VoyteckPL

Is your protocol version set in the config to the actual version used by the device? If you don't know what this is, you should be able to see the detected protocol version in the device diagnostics if you download them while the device is working.

This will help to reestablish the connection more quickly, as the device may be getting stuck trying non-working protocol versions when trying to come back online.

I'm experiencing a similar issue with devices going offline seemingly randomly (while they remain active in the Tuya Smart app). Looking at the protocol version I can see the version on Home Assistant, Tuya Local integration, download diagnostics for a device. But where on the Tuya IoT cloud can I see the protocol version the device actually uses?

meierthomas avatar Oct 03 '23 10:10 meierthomas

I don't think you can see the local protocol version anywhere in the cloud API. If you scan using tinytuya, it is output as part of the scan, though it is known that some 3.2 devices report as 3.3.

make-all avatar Oct 03 '23 12:10 make-all

I have my devices on static IP, IP and protocol versions set in HA from tinytuya wizard. If a device is powered off for some time, the Tuya app reconnects them, but tuya local does not.

susron avatar Nov 13 '23 12:11 susron

I have four avatto thermostat. Sometimes lost for short time connecting. Most times app returns correct. But sometimes in app device is disconnected . For other test i have template sensor for temperature. This works alltime.

  • name: "rb21 wz akt temp" state: "{{ '%+.1f'|format(state_attr('climate.rb21_wz_tempregler', 'current_temperature')) }}" unit_of_measurement: "°C"

JDJuergenD avatar Dec 01 '23 08:12 JDJuergenD

I also have this issue. It may be because the device is configured to DHCP. I would not like to make it static. Is it possible to configure by DNS name ? It would be easy to me if I could use the name and not IP address.

alexantao avatar Jan 11 '24 14:01 alexantao

DNS names work if you include a domain or a trailing dot (without the trailing dot they get resolved within docker's internal domain).

But does your router not allow to configure a static IP for DHCP? Even using domain names, you will still lose the connection if the IP changes, and it may take time for DNS caches to pick up the new IP.

make-all avatar Jan 11 '24 22:01 make-all

I'm having the similar issue with my Tuya lights as well i.e. when the device becomes unavailable in HA, it takes a full HA reboot for it to come back. I tried using the reload function for the specific device but it doesn't seem to work.

bfg100k avatar Feb 23 '24 07:02 bfg100k