Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. Error: TypeError: 'type' Object Has No Attribute '__getitem__' Class Authentication - GXDLMSClient - Python2.7

Error: TypeError: 'type' object has no attribute '__getitem__' Class Authentication - GXDLMSClient - Python2.7

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By dwnmastrodomenico , 14 November, 2019
Forums
Gurux.DLMS

Hi. I am trying to read a meter using tcp / ip using the gurux_dlms and gurux_net libraries in python2.7. Python 2.7 is the version that I have available in my system. But, when I run my script it shows me the following error.

Traceback (most recent call last):
File "readRMSMeter.py", line 40, in <module>
client.authentication = Authentication["LOW"]
TypeError: 'type' object has no attribute '__getitem__'

I am assigning the necessary information for the connection directly, as follows

replyBuff = bytearray(8 + 1024)
waitTime = 5000
logFile = open("logFile1.txt", "a")
readObjects = []
media = None
media = GXNet(NetworkType.TCP, "127.0.0.1", 8082)
client = GXDLMSSecureClient(True)
client.useLogicalNameReferencing = True
client.password = "ABCDEFGH"
client.authentication = Authentication["LOW"]
client.clientAddress = 1
client.serverAddress = 145
trace = TraceLevel.VERBOSE
iec = True

Im importing

from gurux_common.enums import TraceLevel
from gurux_dlms.secure import GXDLMSSecureClient
from gurux_common.io import Parity, StopBits
from gurux_common import ReceiveParameters, TimeoutException
from gurux_dlms import GXByteBuffer, GXReplyData, GXDLMSTranslator, GXDLMSException
from gurux_dlms.enums import InterfaceType, ObjectType, Authentication, DataType, Security
from gurux_dlms.objects import GXDLMSObject, GXDLMSRegister, GXDLMSDemandRegister, GXDLMSProfileGeneric, GXDLMSObjectCollection
from gurux_net.enums import NetworkType
from gurux_net import GXNet

Can someone help me please to identify why this error happens, since in GXDLMSClient and Authentication, I don't see this '__getitem__' parameter or method.

Profile picture for user Kurumi

Kurumi

6 years 7 months ago

Hi,

Hi,

I belive that reason for this is this line:
client.authentication = Authentication["LOW"]

Try to use this:
client.authentication = Authentication.LOW

BR,
Mikko

dwnmastrodomenico

6 years 7 months ago

Thanks for your collaboration

Thanks for your collaboration, I really appreciate it. The problem was corrected, but I can't connect yet with the meter. My script work in python 3.5, so I try again with the the example given in the gurux github in python2.7. And I'm giving the follow parameters:

$> python main.py -h 127.0.0.1 -p 8082 -c 1 -s 145 -P ABCDEFGH -a Low -i

and show me this error:

Authentication: 1
ClientAddress: 0x1
ServerAddress: 0x91
DisconnectRequest
Traceback (most recent call last):
File "main.py", line 80, in main
reader.readAll()
File "/home/dev/rms/GXDLMSReader.py", line 423, in readAll
self.initializeConnection()
File "/home/dev/rms/GXDLMSReader.py", line 241, in initializeConnection
self.client.parseAareResponse(reply.data)
File "/home/dev/lib/python2.7/site-packages/gurux_dlms/GXDLMSClient.py", line 522, in parseAareResponse
self.isAuthenticationRequired = _GXAPDU.parsePDU(self.settings, self.settings.cipher, reply, None) == SourceDiagnostic.AUTHENTICATION_REQUIRED
File "/home/dev/lib/python2.7/site-packages/gurux_dlms/_GXAPDU.py", line 641, in parsePDU
ret = _GXAPDU.parsePDU2(settings, cipher, buff, xml)
File "/home/dev/lib/python2.7/site-packages/gurux_dlms/_GXAPDU.py", line 792, in parsePDU2
_GXAPDU.updateAuthentication(settings, buff)
File "/home/dev/lib/python2.7/site-packages/gurux_dlms/_GXAPDU.py", line 959, in updateAuthentication
settings.authentication = Authentication(ch)
TypeError: object() takes no parameters
Ended. Press any key to continue.

Can help me, please?

Profile picture for user Kurumi

Kurumi

6 years 7 months ago

Hi,

Hi,

Are you running this on Linux? What is your distro?

Can you modify the package? Change this line from :GXAPU.py:
settings.authentication = Authentication(ch)
to:

settings.authentication = ch

We'll change this and publish a new version on Monday.

BR,

Mikko

dwnmastrodomenico

6 years 7 months ago

Thank you very much for your

Thank you very much for your help. The errors that I had were fixed. Im working with two linux distros, openSuSE Tumbleweed and an Openwrt, in the last is where I will leave it running at the end. Again Thanks.

Profile picture for user Kurumi

Kurumi

6 years 6 months ago

Hi,

Hi,
We'll test this with OpenSuSE also on Monday.

BR,
Mikko

Profile picture for user Kurumi

Kurumi

6 years 6 months ago

Hi,

Hi,

A new version (1.0.36) is released where this is fixed.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin