make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.32k stars 518 forks source link

Failed to fetch device status for PJ-1103 clamp power meter #1969

Closed parellades closed 4 months ago

parellades commented 4 months ago

Describe the bug It has been working perfectly for months, and two days ago suddenly stops to work, and I can do nothing to restore it.

To Reproduce I have reload HA, and tried to reinstall the integration, but Tuya Local doesn't detect it in any configuration. The device works without problem on Tuya Smart and is detected by the iot platform.

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.5", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.12.2", "docker": true, "arch": "armv7l", "timezone": "Europe/Andorra", "os_name": "Linux", "os_version": "6.6.28-haos-raspi", "supervisor": "2024.05.1", "host_os": "Home Assistant OS 12.3", "docker_version": "25.0.5", "chassis": "embedded", "run_as_root": true }, "custom_components": { "alexa_media": { "documentation": "https://github.com/alandtse/alexa_media_player/wiki", "version": "4.10.1", "requirements": [ "alexapy==1.27.10", "packaging>=20.3", "wrapt>=1.14.0" ] }, "rpi_gpio": { "documentation": "https://github.com/thecode/ha-rpi_gpio", "version": "2022.7.0", "requirements": [ "RPi.GPIO==0.7.1" ] }, "nintendo_parental": { "documentation": "https://github.com/pantherale0/ha-nintendoparentalcontrols", "version": "2024.4.0", "requirements": [ "pynintendoparental==0.5.0" ] }, "localtuya": { "documentation": "https://github.com/rospogrigio/localtuya/", "version": "5.2.1", "requirements": [] }, "powercalc": { "documentation": "https://github.com/bramstroker/homeassistant-powercalc", "version": "v1.12.4", "requirements": [ "numpy>=1.21.1" ] }, "hacs": { "documentation": "https://hacs.xyz/docs/configuration/start", "version": "1.34.0", "requirements": [ "aiogithubapi>=22.10.1" ] }, "ha_strava": { "documentation": "https://github.com/craibo/ha_strava", "version": "3.2.34", "requirements": [ "aiohttp>=3.6.1", "voluptuous>=0.11.7" ] }, "shopping_list_with_grocy": { "documentation": "https://github.com/Anrolosia/Shopping-List-with-Grocy", "version": "0.10.3", "requirements": [] }, "alarmo": { "documentation": "https://github.com/nielsfaber/alarmo", "version": "v1.10.1", "requirements": [] }, "scheduler": { "documentation": "https://github.com/nielsfaber/scheduler-component", "version": "v0.0.0", "requirements": [] }, "aquarea": { "documentation": "https://github.com/cjaliaga/home-assistant-aquarea", "version": "0.7.0", "requirements": [ "aioaquarea==0.7.2" ] }, "openai_response": { "documentation": "https://github.com/Hassassistant/openai_response", "version": "0.1.0", "requirements": [ "openai==0.27.0" ] }, "meross_cloud": { "documentation": "https://www.home-assistant.io/components/meross_cloud", "version": "1.3.2", "requirements": [ "meross_iot==0.4.7.2b3" ] }, "dht": { "documentation": "https://www.home-assistant.io/integrations/dht", "version": "2022.3.8", "requirements": [ "adafruit-circuitpython-dht==3.7.0", "RPi.GPIO==0.7.1a4" ] }, "nodered": { "documentation": "https://zachowj.github.io/node-red-contrib-home-assistant-websocket/guide/custom_integration/", "version": "4.0.0", "requirements": [] }, "input_stats": { "documentation": "https://github.com/MiguelAngelLV/ha-input-stats", "version": "1.0", "requirements": [] }, "multiscrape": { "documentation": "https://github.com/danieldotnl/ha-multiscrape", "version": "7.0.0", "requirements": [ "lxml>=4.9.1", "beautifulsoup4>=4.12.2" ] }, "garmin_connect": { "documentation": "https://github.com/cyberjunky/home-assistant-garmin_connect", "version": "0.2.19", "requirements": [ "garminconnect==0.2.12", "tzlocal" ] }, "weatherlink": { "documentation": "https://github.com/astrandb/weatherlink", "version": "2024.1.1", "requirements": [] }, "edata": { "documentation": "https://github.com/uvejota/homeassistant-edata/", "version": "2023.06.6", "requirements": [ "e-data==1.1.8", "python-dateutil>=2.8.2" ] }, "tuya_local": { "documentation": "https://github.com/make-all/tuya-local", "version": "2024.5.4", "requirements": [ "tinytuya==1.14.0", "tuya-device-sharing-sdk==0.1.9" ] }, "solcast_solar": { "documentation": "https://github.com/oziee/ha-solcast-solar", "version": "v4.0.22", "requirements": [ "aiohttp>=3.8.5", "datetime>=4.3", "isodate>=0.6.1" ] }, "gas_station_spain": { "documentation": "https://github.com/MiguelAngelLV/gas_station_spain", "version": "0.8.0", "requirements": [] }, "aigues_barcelona": { "documentation": "https://github.com/duhow/hass-aigues-barcelona/tree/master", "version": "0.4.1", "requirements": [] } }, "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.14.0", "tuya-device-sharing-sdk==0.1.9" ], "version": "2024.5.4", "is_built_in": false }, "data": { "name": "PJ-1103 clamp power meter", "type": "pj1103_clamp_meter", "device_id": "REDACTED", "device_cid": "", "local_key": "REDACTED", "host": "REDACTED", "protocol_version": 3.4, "tinytuya_version": "1.14.0", "api_version_set": 3.4, "api_version_used": 3.4, "api_working": false, "status": {}, "cached_state": { "updated_at": 0 }, "pending_state": {}, "connected": true, "force_dps": [ 19, 18, 20 ], "home_assistant": { "name": "PJ-1103 clamp power meter", "name_by_user": null, "disabled": false, "disabled_by": null, "entities": [ { "disabled": false, "disabled_by": null, "entity_category": "config", "device_class": null, "original_device_class": "power_factor", "icon": null, "unit_of_measurement": "%", "state": { "entity_id": "number.pj_1103_clamp_power_meter_maximum_reactive_power", "state": "unavailable", "attributes": { "min": 10.0, "max": 100.0, "step": 1.0, "mode": "auto", "unit_of_measurement": "%", "device_class": "power_factor", "friendly_name": "PJ-1103 clamp power meter Maximum reactive power" }, "last_changed": "2024-05-31T07:08:50.437385+00:00", "last_reported": "2024-05-31T07:17:09.748683+00:00", "last_updated": "2024-05-31T07:17:09.748683+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": "config", "device_class": null, "original_device_class": "power", "icon": null, "unit_of_measurement": "W", "state": { "entity_id": "number.pj_1103_clamp_power_meter_maximum_effective_power", "state": "unavailable", "attributes": { "min": 0.0, "max": 150000.0, "step": 1.0, "mode": "auto", "unit_of_measurement": "W", "device_class": "power", "friendly_name": "PJ-1103 clamp power meter Maximum effective power" }, "last_changed": "2024-05-31T07:08:50.440194+00:00", "last_reported": "2024-05-31T07:17:09.751722+00:00", "last_updated": "2024-05-31T07:17:09.751722+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": "diagnostic", "device_class": null, "original_device_class": null, "icon": null, "unit_of_measurement": "kWh", "state": { "entity_id": "sensor.pj_1103_clamp_power_meter_energy", "state": "unavailable", "attributes": { "unit_of_measurement": "kWh", "friendly_name": "PJ-1103 clamp power meter Energy" }, "last_changed": "2024-05-31T07:08:50.411808+00:00", "last_reported": "2024-05-31T07:17:09.723528+00:00", "last_updated": "2024-05-31T07:17:09.723528+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": null, "device_class": null, "original_device_class": "energy", "icon": null, "unit_of_measurement": null, "state": { "entity_id": "sensor.grid_potencia_consumida_energy", "state": "unavailable", "attributes": { "state_class": "total_increasing", "unit_of_measurement": "kWh", "device_class": "energy", "icon": "mdi:lightning-bolt", "friendly_name": "grid potencia consumida energy" }, "last_changed": "2024-05-31T07:17:07.192564+00:00", "last_reported": "2024-05-31T07:17:07.192564+00:00", "last_updated": "2024-05-31T07:17:07.192564+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": null, "device_class": null, "original_device_class": "energy", "icon": null, "unit_of_measurement": null, "state": { "entity_id": "sensor.grid_potencia_consumida_energy_daily", "state": "unavailable", "attributes": { "state_class": "total_increasing", "unit_of_measurement": "kWh", "device_class": "energy", "friendly_name": "grid potencia consumida energy daily" }, "last_changed": "2024-05-31T07:17:07.213498+00:00", "last_reported": "2024-05-31T07:17:07.213498+00:00", "last_updated": "2024-05-31T07:17:07.213498+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": null, "device_class": null, "original_device_class": "energy", "icon": null, "unit_of_measurement": null, "state": { "entity_id": "sensor.grid_potencia_consumida_energy_weekly", "state": "unavailable", "attributes": { "state_class": "total_increasing", "unit_of_measurement": "kWh", "device_class": "energy", "friendly_name": "grid potencia consumida energy weekly" }, "last_changed": "2024-05-31T07:17:07.218233+00:00", "last_reported": "2024-05-31T07:17:07.218233+00:00", "last_updated": "2024-05-31T07:17:07.218233+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": null, "device_class": null, "original_device_class": "energy", "icon": null, "unit_of_measurement": null, "state": { "entity_id": "sensor.grid_potencia_consumida_energy_monthly", "state": "unavailable", "attributes": { "state_class": "total_increasing", "unit_of_measurement": "kWh", "device_class": "energy", "friendly_name": "grid potencia consumida energy monthly" }, "last_changed": "2024-05-31T07:17:07.219097+00:00", "last_reported": "2024-05-31T07:17:07.219097+00:00", "last_updated": "2024-05-31T07:17:07.219097+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.pj_1103_clamp_power_meter_fault", "state": "unavailable", "attributes": { "device_class": "problem", "friendly_name": "PJ-1103 clamp power meter" }, "last_changed": "2024-05-31T07:08:49.450309+00:00", "last_reported": "2024-05-31T07:17:09.681009+00:00", "last_updated": "2024-05-31T07:17:09.681009+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": null, "device_class": null, "original_device_class": "power", "icon": null, "unit_of_measurement": "W", "state": { "entity_id": "sensor.pj_1103_clamp_power_meter_potencia", "state": "unavailable", "attributes": { "state_class": "measurement", "unit_of_measurement": "W", "device_class": "power", "friendly_name": "PJ-1103 clamp power meter" }, "last_changed": "2024-05-31T07:08:50.401447+00:00", "last_reported": "2024-05-31T07:17:09.712155+00:00", "last_updated": "2024-05-31T07:17:09.712155+00:00" } }, { "disabled": false, "disabled_by": null, "entity_category": "diagnostic", "device_class": null, "original_device_class": "current", "icon": null, "unit_of_measurement": "A", "state": { "entity_id": "sensor.pj_1103_clamp_power_meter_intensitat", "state": "unavailable", "attributes": { "state_class": "measurement", "unit_of_measurement": "A", "device_class": "current", "friendly_name": "PJ-1103 clamp power meter" }, "last_changed": "2024-05-31T07:08:50.405386+00:00", "last_reported": "2024-05-31T07:17:09.717122+00:00", "last_updated": "2024-05-31T07:17:09.717122+00:00" } }, { "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.pj_1103_clamp_power_meter_voltatge", "state": "unavailable", "attributes": { "state_class": "measurement", "unit_of_measurement": "V", "device_class": "voltage", "friendly_name": "PJ-1103 clamp power meter" }, "last_changed": "2024-05-31T07:08:50.408046+00:00", "last_reported": "2024-05-31T07:17:09.720938+00:00", "last_updated": "2024-05-31T07:17:09.720938+00:00" } } ] } } }

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

Aquest error té origen en una integració personalitzada.

Diari de registre: custom_components.tuya_local.device Font: custom_components/tuya_local/device.py:556 integració: Tuya Local (documentació, problemes) Produït per primer cop: 31 de maig de 2024, a les 09:09:23 (13694 ocurrències) Últim registre: 06:53:24

Failed to update device dps for PJ-1103 clamp power meter Failed to fetch device status for PJ-1103 clamp power meter

If applicable, add screenshots to help explain your problem.

make-all commented 4 months ago

I think a debug log will give a better idea of what is happening here. The normal log level is only showing that something is failing in the communication with the device, but not the full details. The diagnostics too are only showing that there is no communication with the device.

parellades commented 4 months ago

Ok, I think that is you need: 2024-06-01 21:21:04.403 ERROR (MainThread) [custom_components.tuya_local.device] Failed to fetch device status for PJ-1103 clamp power meter 2024-06-01 21:21:04.404 INFO (MainThread) [custom_components.tuya_local.device] Setting protocol version for PJ-1103 clamp power meter to 3.4 2024-06-01 21:21:09.617 DEBUG (MainThread) [custom_components.tuya_local.device] Retrying after exception <class 'AttributeError'> Check device key or version (0/3) 2024-06-01 21:21:09.617 INFO (MainThread) [custom_components.tuya_local.device] Setting protocol version for PJ-1103 clamp power meter to 3.4 2024-06-01 21:21:09.722 DEBUG (MainThread) [custom_components.tuya_local.device] Retrying after exception <class 'AttributeError'> Check device key or version (1/3) 2024-06-01 21:21:09.723 INFO (MainThread) [custom_components.tuya_local.device] Setting protocol version for PJ-1103 clamp power meter to 3.4 2024-06-01 21:21:09.926 DEBUG (MainThread) [custom_components.tuya_local.device] Retrying after exception <class 'AttributeError'> Check device key or version (2/3) 2024-06-01 21:21:09.927 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] sensor values: [] 2024-06-01 21:21:09.928 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Considering mapping for range of value 2024-06-01 21:21:09.928 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Considering mapping for range of value 2024-06-01 21:21:09.929 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Considering mapping for step of value 2024-06-01 21:21:09.929 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Considering mapping for range of value 2024-06-01 21:21:09.929 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Considering mapping for range of value 2024-06-01 21:21:09.930 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Considering mapping for step of value 2024-06-01 21:21:09.930 ERROR (MainThread) [custom_components.tuya_local.device] Failed to fetch device status for PJ-1103 clamp power meter 2024-06-01 21:21:09.930 INFO (MainThread) [custom_components.tuya_local.device] Setting protocol version for PJ-1103 clamp power meter to 3.4 2024-06-01 21:21:15.146 DEBUG (MainThread) [custom_components.tuya_local.device] Retrying after exception <class 'AttributeError'> Check device key or version (0/3) 2024-06-01 21:21:15.146 INFO (MainThread) [custom_components.tuya_local.device] Setting protocol version for PJ-1103 clamp power meter to 3.4 2024-06-01 21:21:15.350 DEBUG (MainThread) [custom_components.tuya_local.device] Retrying after exception <class 'AttributeError'> Check device key or version (1/3) 2024-06-01 21:21:15.351 INFO (MainThread) [custom_components.tuya_local.device] Setting protocol version for PJ-1103 clamp power meter to 3.4 2024-06-01 21:21:15.554 DEBUG (MainThread) [custom_components.tuya_local.device] Retrying after exception <class 'AttributeError'> Check device key or version (2/3) 2024-06-01 21:21:15.557 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] sensor values: [] 2024-06-01 21:21:15.558 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Considering mapping for range of value 2024-06-01 21:21:15.559 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Considering mapping for range of value 2024-06-01 21:21:15.559 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Considering mapping for step of value 2024-06-01 21:21:15.560 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Considering mapping for range of value 2024-06-01 21:21:15.561 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Considering mapping for range of value 2024-06-01 21:21:15.561 DEBUG (MainThread) [custom_components.tuya_local.helpers.device_config] Considering mapping for step of value

make-all commented 4 months ago

These messages appear to suggest that either your protocol version or local key is incorrect.

2024-06-01 21:21:09.926 DEBUG (MainThread) [custom_components.tuya_local.device] Retrying after exception <class 'AttributeError'> Check device key or version (2/3)

Did you re-pair the device with your phone? This will reset the local key. Or maybe it got a software update and the protocol version got changed?

parellades commented 4 months ago

Thanks! Re-pairing the device, with a new local key, and with the same protocol version (3.4), has reconnect it with HA.