azerty9971 / xtend_tuya

eXtend Tuya's integration
GNU General Public License v3.0
57 stars 4 forks source link

Error after adding new Integration - TypeError: argument of type 'int' is not iterable #128

Open aefo opened 2 days ago

aefo commented 2 days ago

Just added this component (via HACS), and am getting the error below. Is this a known issue / something I need to correct in my setup? Is there any additional information I can help provide?

Thanks

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/xtend_tuya/__init__.py", line 46, in async_setup_entry
    await hass.async_add_executor_job(multi_manager.update_device_cache)
  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/xtend_tuya/multi_manager/multi_manager.py", line 148, in update_device_cache
    self._merge_devices_from_multiple_sources()
  File "/config/custom_components/xtend_tuya/multi_manager/multi_manager.py", line 180, in _merge_devices_from_multiple_sources
    XTMergingManager.merge_devices(prev_device, current_device)
  File "/config/custom_components/xtend_tuya/multi_manager/shared/merging_manager.py", line 26, in merge_devices
    CloudFixes.apply_fixes(device1)
  File "/config/custom_components/xtend_tuya/multi_manager/shared/cloud_fix.py", line 24, in apply_fixes
    CloudFixes._fix_incorrect_percentage_scale(device)
  File "/config/custom_components/xtend_tuya/multi_manager/shared/cloud_fix.py", line 306, in _fix_incorrect_percentage_scale
    if "unit" in value and "min" in value and "max" in value and "scale" in value:
       ^^^^^^^^^^^^^^^
TypeError: argument of type 'int' is not iterable
azerty9971 commented 2 days ago

Hello, Can you retry with the latest release please?

Thanks in advance, Azerty

azerty9971 commented 2 days ago

And if it now works, can you send me the system logs (there should be a warning that contains something like "Found invalid value descriptor, attempting fix ...")

(to view the logs, go to Settings -> System -> Logs)

aefo commented 1 day ago

Thank you. It seems to now be working with the latest version.

There are some error messages, which I assume are unexciting (but included at the end for reference). Enabling the debug logging for custom_components.xtend_tuya to see the messages in /custom_components/xtend_tuya/multi_manager/shared/merging_manager.py, seems to show two sensors having issues (the errors are repeated multiple times, but included two examples below)

  1. Found invalid value descriptor for device Device TV:
  2. Found invalid value descriptor for device Device Set-top box :

Sensor 1:

2024-10-26 12:16:34.530 DEBUG (SyncWorker_5) [custom_components.xtend_tuya] Found invalid value descriptor for device Device TV:
Functions:
DeviceFunction(code='-/--', type='STRING', values='{"ErrorValue1": "-/--", "ErrorValue2": "-/--"}')
DeviceFunction(code='0', type='STRING', values='0')
DeviceFunction(code='1', type='STRING', values='1')
DeviceFunction(code='2', type='STRING', values='2')
DeviceFunction(code='3', type='STRING', values='3')
DeviceFunction(code='4', type='STRING', values='4')
DeviceFunction(code='5', type='STRING', values='5')
DeviceFunction(code='6', type='STRING', values='6')
DeviceFunction(code='7', type='STRING', values='7')
DeviceFunction(code='8', type='STRING', values='8')
DeviceFunction(code='9', type='STRING', values='9')
DeviceFunction(code='Back', type='STRING', values='Back')
DeviceFunction(code='C', type='ENUM', values='{"min":1,"max":999,"scale":0,"step":1,"type":"Integer"}')
DeviceFunction(code='Channel+', type='STRING', values='Channel+')
DeviceFunction(code='Channel-', type='STRING', values='Channel-')
DeviceFunction(code='Down', type='STRING', values='Down')
DeviceFunction(code='Home', type='STRING', values='Home')
DeviceFunction(code='Left', type='STRING', values='Left')
DeviceFunction(code='Menu', type='STRING', values='Menu')
DeviceFunction(code='OK', type='STRING', values='OK')
DeviceFunction(code='Power', type='STRING', values='Power')
DeviceFunction(code='Right', type='STRING', values='Right')
DeviceFunction(code='Up', type='STRING', values='Up')
DeviceFunction(code='Volume+', type='STRING', values='Volume+')
DeviceFunction(code='Volume-', type='STRING', values='Volume-')
StatusRange:
Status:
LocalStrategy:
, attempting fix: |0|
Stack (most recent call last):
  File "/usr/local/lib/python3.12/threading.py", line 1030, in _bootstrap
    self._bootstrap_inner()
  File "/usr/local/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.12/threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 92, in _worker
    work_item.run()
  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/xtend_tuya/multi_manager/multi_manager.py", line 148, in update_device_cache
    self._merge_devices_from_multiple_sources()
  File "/config/custom_components/xtend_tuya/multi_manager/multi_manager.py", line 180, in _merge_devices_from_multiple_sources
    XTMergingManager.merge_devices(prev_device, current_device)
  File "/config/custom_components/xtend_tuya/multi_manager/shared/merging_manager.py", line 24, in merge_devices
    XTMergingManager._fix_incorrect_valuedescr(device1, device2)
  File "/config/custom_components/xtend_tuya/multi_manager/shared/merging_manager.py", line 69, in _fix_incorrect_valuedescr
    LOGGER.debug(f"Found invalid value descriptor for device {device1}, attempting fix: |{device1.function[code].values}|", stack_info=True)
2024-10-26 12:16:34.530 DEBUG (SyncWorker_5) [custom_components.xtend_tuya] Fix unsuccessful, clearing values

Sensor 2

2024-10-26 12:16:34.877 DEBUG (SyncWorker_4) [custom_components.xtend_tuya] Found invalid value descriptor for device Device Set-top box :
Functions:
DeviceFunction(code='#', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"#\\", \\"ErrorValue2\\": \\"#\\"}", "ErrorValue2": "#"}')
DeviceFunction(code='*', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"*\\", \\"ErrorValue2\\": \\"*\\"}", "ErrorValue2": "*"}')
DeviceFunction(code='0', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"0\\", \\"ErrorValue2\\": \\"0\\"}", "ErrorValue2": "0"}')
DeviceFunction(code='1', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"1\\", \\"ErrorValue2\\": \\"1\\"}", "ErrorValue2": "1"}')
DeviceFunction(code='2', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"2\\", \\"ErrorValue2\\": \\"2\\"}", "ErrorValue2": "2"}')
DeviceFunction(code='3', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"3\\", \\"ErrorValue2\\": \\"3\\"}", "ErrorValue2": "3"}')
DeviceFunction(code='4', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"4\\", \\"ErrorValue2\\": \\"4\\"}", "ErrorValue2": "4"}')
DeviceFunction(code='5', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"5\\", \\"ErrorValue2\\": \\"5\\"}", "ErrorValue2": "5"}')
DeviceFunction(code='6', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"6\\", \\"ErrorValue2\\": \\"6\\"}", "ErrorValue2": "6"}')
DeviceFunction(code='7', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"7\\", \\"ErrorValue2\\": \\"7\\"}", "ErrorValue2": "7"}')
DeviceFunction(code='8', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"8\\", \\"ErrorValue2\\": \\"8\\"}", "ErrorValue2": "8"}')
DeviceFunction(code='9', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"9\\", \\"ErrorValue2\\": \\"9\\"}", "ErrorValue2": "9"}')
DeviceFunction(code='Back', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"Back\\", \\"ErrorValue2\\": \\"Back\\"}", "ErrorValue2": "Back"}')
DeviceFunction(code='C', type='ENUM', values='{"min":1,"max":999,"scale":0,"step":1,"type":"Integer"}')
DeviceFunction(code='Channel+', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"Channel+\\", \\"ErrorValue2\\": \\"Channel+\\"}", "ErrorValue2": "Channel+"}')
DeviceFunction(code='Channel-', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"Channel-\\", \\"ErrorValue2\\": \\"Channel-\\"}", "ErrorValue2": "Channel-"}')
DeviceFunction(code='Down', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"Down\\", \\"ErrorValue2\\": \\"Down\\"}", "ErrorValue2": "Down"}')
DeviceFunction(code='Home', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"Home\\", \\"ErrorValue2\\": \\"Home\\"}", "ErrorValue2": "Home"}')
DeviceFunction(code='Left', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"Left\\", \\"ErrorValue2\\": \\"Left\\"}", "ErrorValue2": "Left"}')
DeviceFunction(code='Menu', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"Menu\\", \\"ErrorValue2\\": \\"Menu\\"}", "ErrorValue2": "Menu"}')
DeviceFunction(code='OK', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"OK\\", \\"ErrorValue2\\": \\"OK\\"}", "ErrorValue2": "OK"}')
DeviceFunction(code='Power', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"Power\\", \\"ErrorValue2\\": \\"Power\\"}", "ErrorValue2": "Power"}')
DeviceFunction(code='Right', type='STRING', values='{"ErrorValue1": "{\\"ErrorValue1\\": \\"Right\\", \\"ErrorValue2\\": \\"Right\\"}", "ErrorValue2": "Right"}')
DeviceFunction(code='Up', type='STRING', values='{"ErrorValue1": "Up", "ErrorValue2": "Up"}')
DeviceFunction(code='Volume+', type='STRING', values='Volume+')
DeviceFunction(code='Volume-', type='STRING', values='Volume-')
StatusRange:
Status:
LocalStrategy:
, attempting fix: |Volume+|
Stack (most recent call last):
  File "/usr/local/lib/python3.12/threading.py", line 1030, in _bootstrap
    self._bootstrap_inner()
  File "/usr/local/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.12/threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 92, in _worker
    work_item.run()
  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/xtend_tuya/multi_manager/multi_manager.py", line 148, in update_device_cache
    self._merge_devices_from_multiple_sources()
  File "/config/custom_components/xtend_tuya/multi_manager/multi_manager.py", line 180, in _merge_devices_from_multiple_sources
    XTMergingManager.merge_devices(prev_device, current_device)
  File "/config/custom_components/xtend_tuya/multi_manager/shared/merging_manager.py", line 24, in merge_devices
    XTMergingManager._fix_incorrect_valuedescr(device1, device2)
  File "/config/custom_components/xtend_tuya/multi_manager/shared/merging_manager.py", line 69, in _fix_incorrect_valuedescr
    LOGGER.debug(f"Found invalid value descriptor for device {device1}, attempting fix: |{device1.function[code].values}|", stack_info=True)
2024-10-26 12:16:34.877 DEBUG (SyncWorker_4) [custom_components.xtend_tuya] Fix unsuccessful, clearing values

Error messages:

2024-10-26 08:16:46.430 ERROR (MainThread) [homeassistant.components.button] Platform xtend_tuya does not generate unique IDs. ID tuya.b********9f2f58dzgfreset_add_ele already exists - ignoring button.smart_plug_4_reset_consumption
2024-10-26 08:16:46.431 ERROR (MainThread) [homeassistant.components.button] Platform xtend_tuya does not generate unique IDs. ID tuya.b********5ce86d3e8qprkreset_add_ele already exists - ignoring button.5_christmas_lights_reset_consumption
2024-10-26 08:16:46.460 ERROR (MainThread) [homeassistant.components.sensor] Platform xtend_tuya does not generate unique IDs. ID tuya.b********9f2f58dzgfadd_ele already exists - ignoring sensor.smart_plug_4_consumption
2024-10-26 08:16:46.462 ERROR (MainThread) [homeassistant.components.sensor] Platform xtend_tuya does not generate unique IDs. ID tuya.b********9f2f58dzgfadd_ele_today already exists - ignoring sensor.smart_plug_4_daily_consumption
2024-10-26 08:16:46.463 ERROR (MainThread) [homeassistant.components.sensor] Platform xtend_tuya does not generate unique IDs. ID tuya.b********9f2f58dzgfadd_ele_this_month already exists - ignoring sensor.smart_plug_4_monthly_consumption
2024-10-26 08:16:46.463 ERROR (MainThread) [homeassistant.components.sensor] Platform xtend_tuya does not generate unique IDs. ID tuya.b********9f2f58dzgfadd_ele_this_year already exists - ignoring sensor.smart_plug_4_yearly_consumption
2024-10-26 08:16:46.467 ERROR (MainThread) [homeassistant.components.sensor] Platform xtend_tuya does not generate unique IDs. ID tuya.b********9f2f58dzgfcur_power already exists - ignoring sensor.smart_plug_4_power_2
2024-10-26 08:16:46.468 ERROR (MainThread) [homeassistant.components.sensor] Platform xtend_tuya does not generate unique IDs. ID tuya.b********5ce86d3e8qprkadd_ele already exists - ignoring sensor.5_christmas_lights_consumption
2024-10-26 08:16:46.469 ERROR (MainThread) [homeassistant.components.sensor] Platform xtend_tuya does not generate unique IDs. ID tuya.b********5ce86d3e8qprkadd_ele_today already exists - ignoring sensor.5_christmas_lights_daily_consumption
2024-10-26 08:16:46.470 ERROR (MainThread) [homeassistant.components.sensor] Platform xtend_tuya does not generate unique IDs. ID tuya.b********5ce86d3e8qprkadd_ele_this_month already exists - ignoring sensor.5_christmas_lights_monthly_consumption
2024-10-26 08:16:46.470 ERROR (MainThread) [homeassistant.components.sensor] Platform xtend_tuya does not generate unique IDs. ID tuya.b********5ce86d3e8qprkadd_ele_this_year already exists - ignoring sensor.5_christmas_lights_yearly_consumption
2024-10-26 08:16:46.473 ERROR (MainThread) [homeassistant.components.sensor] Platform xtend_tuya does not generate unique IDs. ID tuya.b********5ce86d3e8qprkcur_power already exists - ignoring sensor.5_christmas_lights_power_2
2024-10-26 08:16:46.566 ERROR (MainThread) [homeassistant.components.scene] Platform xtend_tuya does not generate unique IDs. ID tys********0aTAy already exists - ignoring scene.office_radiator_on_2
2024-10-26 08:16:46.566 ERROR (MainThread) [homeassistant.components.scene] Platform xtend_tuya does not generate unique IDs. ID tys********lqyFEALw already exists - ignoring scene.master_bathroom_radiator_mode_manual_mode_2
2024-10-26 08:16:46.567 ERROR (MainThread) [homeassistant.components.scene] Platform xtend_tuya does not generate unique IDs. ID tys********hwgvHA6P already exists - ignoring scene.switch_to_channel_4_plus_one_2
2024-10-26 08:16:46.567 ERROR (MainThread) [homeassistant.components.scene] Platform xtend_tuya does not generate unique IDs. ID tys********AjKRrlzy already exists - ignoring scene.switch_to_channel_4_2
2024-10-26 08:16:46.567 ERROR (MainThread) [homeassistant.components.scene] Platform xtend_tuya does not generate unique IDs. ID tys********zKHhrnll already exists - ignoring scene.switch_to_bbc_1_2
2024-10-26 08:16:46.568 ERROR (MainThread) [homeassistant.components.scene] Platform xtend_tuya does not generate unique IDs. ID tys********FIBLmzJ8 already exists - ignoring scene.activate_dtv_2
2024-10-26 08:16:46.568 ERROR (MainThread) [homeassistant.components.scene] Platform xtend_tuya does not generate unique IDs. ID tys********Ya1U9439 already exists - ignoring scene.change_tv_input_2
azerty9971 commented 1 day ago

These 2 are the weirdest devices I've seen so far oO. Are these added manually through another integration? Would you be able to share one of them with me so that I can see what's going on in there?

Also the duplicate ID errors are strange and they never happened in my side...

Would you be available for a google Meet to investigate this? if yes, feel free to contact me at devun999999@gmail.com and we'll schedule a meeting

Have a nice day, Azerty

aefo commented 21 hours ago

It's a purchase from ebay (back in 202). Listed as fairly generic "Tuya WiFi-IR Remote Control Hub 2.4G Wi-Fi Infrared Universal Remote Controller". I think the devices are being created / presented by the Smart IR. No extra / 3rd party integrations in place. Will see if I can find any other details or share across to you.

image

For the "Smart IR" device:

Device Information
Product Name
ZCJK 万能遥控器
Device ID
0322********113
Product Category
wnykq
Device Status
Online

For the "Set-top box" device:

Device Information
Product Name
红外机顶盒
Device ID
bf9d37*********bexy
Product Category
qt
Device Status
Online
Code Type Values
# STRING "#"
* STRING "*"
0 STRING "0"
1 STRING 1
2 STRING 2
3 STRING 3
4 STRING 4
5 STRING 5
6 STRING 6
7 STRING 7
8 STRING 8
9 STRING 9
Back STRING "Back"
C ENUM { "min": 1, "max": 999, "scale": 0, "step": 1, "type": "Integer" }
Channel+ STRING "Channel+"
Channel- STRING "Channel-"
Down STRING "Down"
Home STRING "Home"
Left STRING "Left"
Menu STRING "Menu"
OK STRING "OK"
Power STRING "Power"
Right STRING "Right"
Up STRING "Up"
Volume+ STRING "Volume+"
Volume- STRING "Volume-"

Thanks for getting the integration working for the other items that I do have! (They were the ones I was focused on)