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?
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