'ZCLAttributeDef' object is not subscriptable

Since 2023.7 (I believe), I have two custom quirks throwing this error:

‘ZCLAttributeDef’ object is not subscriptable

The full error is:

  File "/config/custom_zha_quirks/ts0601_trv_beca.py", line 716, in command
    (res,) = await self.write_attributes(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_zha_quirks/ts0601_trv_beca.py", line 669, in write_attributes
    attr_name = self.attributes[record.attrid][0]
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
TypeError: 'ZCLAttributeDef' object is not subscriptable

Both the affected quirks are very similar and have identical code blocks in the affected areas. Does anyone have any thoughts on what might of caused this ? is it a bug in the release, or an intended change that will need the quirks modifying ? (And if the latter, does anyone have any clues as to where to start).

having read up on the error, I kinda understand what the issue is, and have modified the quirk so that every instance of

self.attributes[record.attrid][0]

Has been changed to

self.attributes[record.attrid]

This has removed the errors from being thrown in the logs, but changing any of the settings for the device no longer work. Switches for instance, just return to their previous state (after a couple of seconds) if I click them.

For anyone else that comes across this thread, I finally solved the broken quirk by changing all instances of

self.attributes[record.attrid][0]

to

self.attributes[record.attrid].name

This effects the following TRV’s:-

Haozee brand, id’d as TS0601 by _TZE200_zivfvd7h

and

Moes brand, id’d as TS0601 by _TZE200_b6wax7g0

Hi,

thank you for your solution.
Somehow it is not working for me.
I have only one occurrence of “self.attributes[record.attrid][0]” in my custom quirks file.
I changed that line to “self.attributes[record.attrid].name” and the error message is gone, but the switch is falling back to off state after a couple of seconds.
Maybe I got you wrong.
Is there more to do?

Which quirk are you using ? and have you restarted HA ?

I am using this quirk:

https://github.com/zigpy/zha-device-handlers/files/10376432/ts0601_trv_me167.py.zip

Do you use another quirk

Yes, I restarted HA and did also a full reboot.

I downloaded a new version of that file and now it works.

Good news!