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. How To Write a New TOD To Meter With Python?

How to write a new TOD to meter with Python?

By Ali_nk , 10 July, 2024
Forums
DLMSDirector

Hi ,

I'm using Python with the Gurux DLMS library to interact with an Indian Standard meter, and I'm trying to write a new Time of Day (TOD) to it. Here's a snippet of my code:

class SampleClient:
@classmethod
def main(cls, args):
reader = None
settings = GXSettings()
try:
ret = settings.getParameters(args)
if ret != 0:
return
if not isinstance(settings.media, (GXSerial, GXNet)):
raise Exception("Unknown media type.")

reader = GXDLMSReader(settings.client, settings.media, settings.trace, settings.invocationCounter)
settings.media.open()
reader.initializeConnection()
reply = GXReplyData()

# Creating an instance of GXDLMSActivityCalendar
activity_calendar = GXDLMSActivityCalendar("0.0.13.0.0.255")

# Reading attributes of GXDLMSActivityCalendar object
for i in range(1, 11):
reader.read(activity_calendar, i)

# Print Day Profile Table Active
print("Day Profile Table Active:")
for day in activity_calendar.dayProfileTableActive:
print(f" Day ID: {day.dayId}")
for action in day.daySchedules:
print(f" Start Time: {action.startTime}, Script Logical Name: {action.scriptLogicalName}, Script Selector: {action.scriptSelector}")

# Print Day Profile Table Passive
print("Day Profile Table Passive:")
for day in activity_calendar.dayProfileTablePassive:
print(f" Day ID: {day.dayId}")
for action in day.daySchedules:
print(f" Start Time: {action.startTime}, Script Logical Name: {action.scriptLogicalName}, Script Selector: {action.scriptSelector}")

print("Time:", activity_calendar.time)

# Create new Day Profile
new_day_profile = GXDLMSDayProfile()
new_day_profile.dayId = 0
new_day_profile.daySchedules = [
GXDLMSDayProfileAction(startTime=GXTime("00:00:00"), scriptLogicalName="0.0.10.0.100.255", scriptSelector=1),
GXDLMSDayProfileAction(startTime=GXTime("12:00:00"), scriptLogicalName="0.0.10.0.100.255", scriptSelector=2)
]

# Update the passive day profile table
activity_calendar.dayProfileTablePassive = [new_day_profile]

# Write updated activity calendar
result = reader.write(activity_calendar, 10)

# Activate the passive calendar
result = reader.method(activity_calendar, 1, None)
except (ValueError, GXDLMSException, GXDLMSExceptionResponse, GXDLMSConfirmedServiceError) as ex:
print(ex)
except (KeyboardInterrupt, SystemExit):
traceback.print_exc()
except Exception as ex:
traceback.print_exc()
finally:
if settings.media:
settings.media.close()
if reader:
reader.close()
print("Ended. Press any key to continue.")

if __name__ == '__main__':
SampleClient.main(sys.argv)

I'm encountering the error "time data '00:00:00' does not match format ' %H:%M:%S'". Could someone please help me understand how to correctly format the time or resolve this issue?

Profile picture for user Kurumi

Kurumi

1 year 11 months ago

Hi, Update gurux-dlms to the…

Hi,

Update gurux-dlms to the version 1.0.156. There was one space that was causing problems with some Python versions.

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
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin