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. Python DLMS Client - Problems With Authentication and ActivityCalendar

Python DLMS Client - problems with Authentication and ActivityCalendar

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 kadhaus , 14 November, 2020
Forums
Gurux.DLMS

Hello, GuruX!

I have some issues with authentication and writing to ActivityCalendar. Let me elaborate on my problems.

1. Authentication problem

After upgrading version of library gurux_dlms from version 1.0.91 to 1.0.94 I can't connect with the meter. My code to connect looks like:

client = GXDLMSClient(forAuthentication=Authentication.HIGH)
client.clientAddress = 48
client.serverAddress = client.getServerAddress2(1, 23, 1)
client.authentication = Authentication.HIGH
client.password = "2"*16
port = GXSerial(port="/dev/ttyUSB0")
port.open()
reader = GXDLMSReader.GXDLMSReader(
client=client,
media=port,
trace=0x8,
invocationCounter=0,
useOpticalHead=False,
)
reply = GXReplyData()
data = client.snrmRequest()
if data:
reader.readDLMSPacket(data, reply)
client.parseUAResponse(reply.data)
for it in client.aarqRequest():
reply.clear()
reader.readDLMSPacket(it, reply)
client.parseAareResponse(reply.data)

reply.clear()
reader.readDLMSPacket(client.getApplicationAssociationRequest(), reply)
client.parseApplicationAssociationResponse(reply.data)

On the penultimatte line I get the exception:

Traceback (most recent call last):
File "/home/akreskin/development/com-port-test/dlms-ctd/gurux.py", line 163, in <module>
reader.readDLMSPacket(client.getApplicationAssociationRequest(), reply)
File "/home/akreskin/.local/share/virtualenvs/com-port-test-mDPSA0Ke/lib/python3.7/site-packages/gurux_dlms/GXDLMSClient.py", line 581, in getApplicationAssociationRequest
challenge = GXSecure.secure(self.settings, self.settings.cipher, self.settings.cipher.invocationCounter, self.settings.getStoCChallenge(), pw)
AttributeError: 'NoneType' object has no attribute 'invocationCounter'

How can I solve this Issue? With the 1.0.91 version of library this code works properly.

2. ActivityCalendar writing issue:

I'm trying to write some data to 9'nth attribute - DayProfileTablePassive. I hope, that I'm clearly understand how to write attributes with gurux_dlms, but I can't resolve, what format of time should I give for parameter startTime of the class GXDLMSDayProfileAction. I mean this string in the method __setDayProfileTable of class GXDLMSActivityCalendar:

ac.startTime = _GXCommon.changeType(settings, it2[0], DataType.TIME)

I have already tried give to it2[0] ISO-8601-time string, datetime object. As I understand, I should give byte string, looks like the string, returning in answers of reading ProfileGeneric objects with the reader.readRowsByEntry(), but I can't find a method or function to get it. Can you help me with this?

Thanks in advance for your reply!

Profile picture for user Kurumi

Kurumi

5 years 6 months ago

Hi,

Hi,

1. Have you made any changes to the source code? I just tested this and it works as expected.

2. You can give it using datetime or GXDateTime format. Some meters expect that seconds are set to zero. Try to read the value and then write it back. Are you receiving any error?

BR,
Mikko

kadhaus

5 years 6 months ago

Hi,

Hi,

1. No, I didn't made any changes to the source. This error occurs only if I trying to connect with HIGH level og authentication, and only way that I can connect with meter is manually add:

client.settings.cipher = GXCiphering('')
client.settings.cipher.invocationCounter = 0

but it seems as a trick for me.

2. I've already tried everything that I can imagine :) And I can't read this data and write it back, because when I trying to do this I got a TypeError: 'GXDLMSDayProfile' object is not subscritable. Look at this code snippet:

data_from_cloud = [
{
'start_time': "06:00:00",
'tariff_number': 1,
},
{
'start_time': "12:30:00",
'tariff_number': 2,
},
{
'start_time': "16:00:00",
'tariff_number': 1,
},
{
'start_time': "20:00:00",
'tariff_number': 3,
},
]

script_ln = "0.0.10.0.100.255"

day_schedules_data = []
for point in data_from_cloud:
day_schedules_data.append(
[
GXTime(point.get('start_time'), "%H:%M:%S"),
script_ln,
point.get('tariff_number')
]
)

return [[1, day_schedules_data]]

day_profile_table_passive_attr = GXDLMSAttribute(
index=9,
type_=activity_calendar.getDataType(9),
uiType=activity_calendar.getDataType(9),
order=9,
)
day_profile_table_passive_attr.value = day_schedules_data

activity_calendar.setValue(
reader.client.settings,
day_profile_table_passive_attr,
)

reader.write(activity_calendar, 9)

When i run this snippet i got this error:

Traceback (most recent call last):
File "/home/akreskin/development/com-port-test/dlms-ctd/gurux.py", line 234, in <module>
day_profile_table_passive_attr,
File "/home/akreskin/.local/share/virtualenvs/com-port-test-mDPSA0Ke/lib/python3.7/site-packages/gurux_dlms/objects/GXDLMSActivityCalendar.py", line 347, in setValue
self.dayProfileTablePassive = self.__setDayProfileTable(settings, e.value)
File "/home/akreskin/.local/share/virtualenvs/com-port-test-mDPSA0Ke/lib/python3.7/site-packages/gurux_dlms/objects/GXDLMSActivityCalendar.py", line 313, in __setDayProfileTable
ac.startTime = _GXCommon.changeType(settings, it2[0], DataType.TIME)
File "/home/akreskin/.local/share/virtualenvs/com-port-test-mDPSA0Ke/lib/python3.7/site-packages/gurux_dlms/internal/_GXCommon.py", line 231, in changeType
raise ValueError("Change type failed. Not enought data.")
ValueError: Change type failed. Not enought data.

Same error i get, if I trying to give datetime object. What am I do wrong?

Thank you very much!

Profile picture for user Kurumi

Kurumi

5 years 6 months ago

Hi,

Hi,

The reason was too clear. You must use the secure client. Like this:

client = GXDLMSSecureClient(forAuthentication=Authentication.HIGH)

You can write passive day profile table like this:

ac = GXDLMSActivityCalendar("0.0.13.0.0.255")
dp = GXDLMSDayProfile()
dp.dayId = 1;
ac = GXDLMSDayProfileAction()
ac.startTime = 'Get start_time'
ac.scriptLogicalName = "Get script_ln"
ac.scriptSelector = "Get script selector"
it.daySchedules.append(ac)
ac.dayProfileTablePassive.append(dp)
reader.write(activity_calendar, 9)

BR,
Mikko

kadhaus

5 years 6 months ago

Thank you very much!! It

Thank you very much!! It works for me!

  • 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