XKNX / xknxproject

ETS project parser written in python
GNU General Public License v2.0
78 stars 16 forks source link

ValueError: invalid literal for int() with base 10: 'L-1' #361

Closed envy closed 6 months ago

envy commented 6 months ago

I updated to HA 2024.02 and needed to reparse my project but when I upload it I get the following error:

Traceback (most recent call last):
  File "/home/weichbr/xknxproject/test.py", line 6, in <module>
    project: KNXProject = knxproj.parse()
  File "/home/weichbr/xknxproject/xknxproject/xknxproj.py", line 41, in parse
    project = XMLParser(knx_project_content).parse(self.language)
  File "/home/weichbr/xknxproject/xknxproject/xml/parser.py", line 141, in parse
    self._load(language=language)
  File "/home/weichbr/xknxproject/xknxproject/xml/parser.py", line 233, in _load
    device.apply_module_instance_arguments()
  File "/home/weichbr/xknxproject/xknxproject/models/models.py", line 205, in apply_module_instance_arguments
    coir.apply_module_base_number_argument(self.module_instances)
  File "/home/weichbr/xknxproject/xknxproject/models/models.py", line 324, in apply_module_base_number_argument
    self.number += next(
  File "/home/weichbr/xknxproject/xknxproject/models/models.py", line 325, in <genexpr>
    int(arg.value)
ValueError: invalid literal for int() with base 10: 'L-1'

(obviously this is from a local xknxproject to get the full stacktrace, HA just gives me the value error)

I added a print(self) and print(_module_instance) before line 325 and got this:

ComObjectInstanceRef(identifier=None, ref_id='MD-1_M-1_MI-1_O-2-0_R-7', text='EVG 1, Schalten Flur', function_text='On/Off', read_flag=False, write_flag=True, communication_flag=True, transmit_flag=False, update_flag=False, read_on_init_flag=False, datapoint_types=[{'main': 1, 'sub': 1}], description=None, channel=None, links=['GA-114', 'GA-205'], com_object_ref_id='M-0083_A-0153-10-297A-O00EF_MD-1_O-2-0_R-7', name='ECG 1, Switching', object_size='1 Bit', base_number_argument_ref='M-0083_A-0153-10-297A-O00EF_MD-1_A-2', number=0, module=None)

ModuleInstance(identifier='MD-1_M-1_MI-1', ref_id='MD-1_M-1', arguments=[ModuleInstanceArgument(ref_id='M-0083_A-0153-10-297A-O00EF_MD-1_A-1', value='L-2', name='ParamOffsBase'), ModuleInstanceArgument(ref_id='M-0083_A-0153-10-297A-O00EF_MD-1_A-2', value='L-1', name='ObjNumberBase'), ModuleInstanceArgument(ref_id='M-0083_A-0153-10-297A-O00EF_MD-1_A-3', value='L-3', name='ECG_NO')])

Based on this info, the bad device is a MDT DALI Control PRO64

envy commented 6 months ago

Related to this, I looked at some of the successfully parsed things and I also noticed this device:

ComObjectInstanceRef(identifier=None, ref_id='MD-1_M-1_MI-1_O-2-1_R-100', text='T1/2: Rollladen Süd', function_text='Stop/Slats Open/Close', read_flag=False, write_flag=False, communication_flag=True, transmit_flag=True, update_flag=False, read_on_init_flag=False, datapoint_types=[{'main': 1, 'sub': 9}], description=None, channel=None, links=['GA-64'], com_object_ref_id='M-0083_A-0098-11-29A3_MD-1_O-2-1_R-100', name='Eingang Obj1', object_size='1 Bit', base_number_argument_ref='M-0083_A-0098-11-29A3_MD-1_A-2', number=1, module=None)

ModuleInstance(identifier='MD-1_M-1_MI-1', ref_id='MD-1_M-1', arguments=[ModuleInstanceArgument(ref_id='M-0083_A-0098-11-29A3_MD-1_A-1', value='0', name='ParamOffsBase'), ModuleInstanceArgument(ref_id='M-0083_A-0098-11-29A3_MD-1_A-2', value='0', name='ObjNumberBase'), ModuleInstanceArgument(ref_id='M-0083_A-0098-11-29A3_MD-1_A-3', value='1/2', name='ChNoGr'), ModuleInstanceArgument(ref_id='M-0083_A-0098-11-29A3_MD-1_A-4', value='1', name='ChNo1'), ModuleInstanceArgument(ref_id='M-0083_A-0098-11-29A3_MD-1_A-5', value='2', name='ChNo2')])

The value 1/2 of the third module instance argument is also not an int but apparently this did not cause an error.

farmio commented 6 months ago

Hi 👋! Thank you for filing this issue! I had a look yesterday, but didn't yet find out how to parse these object numbers correctly.

We only cast "ObjNumberBase" arguments to int, as I thought these are always the base numbers of the current module. Apparently I was wrong 😬
I have yet to find out what Allocations do.

But so your other device should work fine as "1/2" is a different arguments value.

El4azlongy commented 6 months ago

Hi, Same issue to me invalid literal for int() with base 10: 'L-3' any help with this issue

vampsm commented 6 months ago

Hello, i have this error since the update to XKNX Version 2.12.0 KNX-Frontend Version 2024.1.20.105944 when i upload a x.knxproj file

  invalid literal for int() with base 10: 'L-4'
farmio commented 6 months ago

Hi 👋! It is already fixed in xknxproject 3.6.0 which will ship with HA 2024.2.2