Skip to main content
Home
for DLMS smart meters

Main navigation

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

Breadcrumb

  1. Home
  2. Writing Bytearray With Write()?

Writing bytearray with write()?

By mick93, 11 April, 2025
Forums
Gurux.DLMS

Hi,
I have problem with changing value of object, which has 'bytearray' - as I could see after reading that OBIS. For changing "normal" values, such as APN, I use the following python snippet:

d = GXDLMSData("obis")
d.apn = "newAPN"
self.write(d, 2)

And it works fine, but there's also manufacturer's specific object - pinging setup, which consists of target IP and interval. First one is bytearray, second is integer. After reading this object it looks like below:

-------- Reading 1 0.0.131.6.0.255 Manufacturer specific
Attribute: 1 Value: 0.0.131.6.0.255
Attribute: 2 Value: bytearray(b''), 0

Or, if it is enabled:
Attribute: 2 Value: bytearray(b'8.8.8.8'), 60

But when I use:
d = GXDLMSData("0.0.131.6.0.255")
d.value = bytearray(b"8.8.8.8"), 60
self.write(d, 2)

then I have error: Exception: Invalid parameter. In python value type must give.

Any ideas how to solve that problem?

Profile picture for user Kurumi

Kurumi

1 year ago

Hi, I believe that you need…

Hi,

I believe that you need to write a structure. You can do it like this:

s = GXStructure()
s.append(bytearray(b"8.8.8.8"))
s.append(GXUInt8(60))

BR,
Mikko

mick93

1 year ago

I did as suggested: self…

I did as suggested:

self.newObisValue = GXStructure()
self.newObisValue.append(bytearray(b"8.8.8.8"))
self.newObisValue.append(GXUInt16(60))

in GXDLMSReader.py:
d = GXDLMSData("0.0.131.6.0.255")
d.value = newValue #(self.newObisValue from previous)

So using write() it was writing it:
[bytearray(b'8.8.8.8'), 60]

Still, it gave error: Exception: Invalid parameter. In python value type must give.

Specifically, from write() function:
File "C:\Users\x\Desktop\GURUX\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 316, in write
data = self.client.write(item, attributeIndex)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\x\AppData\Local\Programs\Python\Python311\Lib\site-packages\gurux_dlms\GXDLMSClient.py", line 1082, in write
return self.__write(item.name, value, type_, item.objectType, index)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\x\AppData\Local\Programs\Python\Python311\Lib\site-packages\gurux_dlms\GXDLMSClient.py", line 1093, in __write
raise Exception("Invalid parameter. In python value type must give.")

If you'd need more information: I was able to read this obis from GXDLMSDirector app:
<Structure>
<OctetString Value="382E382E382E38" />
<UInt16 Value="001E" />
</Structure>

And from xml:
<WRAPPER len="1B" >
<SourceAddress Value="1" />
<TargetAddress Value="1" />
<PDU>
<SetRequest>
<SetRequestNormal>
<!-- Priority: Normal, ServiceClass: Confirmed, Invoke ID: 1 -->
<InvokeIdAndPriority Value="41" />
<AttributeDescriptor>
<!-- Data -->
<ClassId Value="0001" />
<!-- 0.0.131.6.0.255 -->
<InstanceId Value="0000830600FF" />
<!-- Value -->
<AttributeId Value="02" />
</AttributeDescriptor>
<Value>
<Structure Qty="02" >
<!-- 8.8.8.8 -->
<OctetString Value="382E382E382E38" />
<UInt16 Value="001E" />
</Structure>
</Value>
</SetRequestNormal>
</SetRequest>
</PDU>
</WRAPPER>

Profile picture for user Kurumi

Kurumi

1 year ago

Hi, You need also set the…

Hi,

You need also set the data type like this:

d = GXDLMSData("0.0.131.6.0.255")
d.setDataType(2, DataType.STRUCTURE)

BR,
Mikko

mick93

1 year ago

That did work, many thanks!

That did work, many thanks!

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 04/14/2026 - 11:47
    gurux.dlms.java 4.0.93
  • Mon, 04/13/2026 - 16:12
    gurux.dlms.java 4.0.92
  • Mon, 04/13/2026 - 11:39
    Gurux.DLMS.Net 9.0.2604.1301
  • Tue, 04/07/2026 - 17:17
    Gurux.DLMS.Python 1.0.197
  • Tue, 04/07/2026 - 15:03
    gurux.dlms.c 9.0.2604.0701

New forum topics

  • Connecting To iskrameco ME382- Single Phase Meter with Optical Probe
  • Create custom AARQ Request for encrypted communication
  • Issue when reading Itron Type620 meter
  • Handling Unexpected Disconnects
  • DLMS Communication Issue – No Response (L&T Meter via USB Probe)
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin