Hi
I need to know how to read a single Obis code with python, i've tried the following obis code which is for voltage value 1.1.32.7.0.255, I've been using GXDLMSDemandRegister, GXDLMSData, GXDLMSRegister and all I get is an error.
- Is it possible to pass an obis code as a string to those functions?
- is it possible to read single obis code without reading the getAssociationView first?
Also, among all the codes I've been using lately, this is the most generic one
obis = "1.1.32.7.0.255"
obj = GXDLMSRegister (obis, sn=1)
val = self.read(obj, 2)
self.showValue(2, val)
I also used this code, to separate obis code from index
main.py
reader.initializeConnection()
voltage = 0.0
try:
obis = "1.1.32.7.0.255.2"
voltage = reader.readByObis(obis=obis)
reader.showValue(2, voltage)
except Exception as ex:
print(ex)
GXDLMSReader.py
def readByObis(self, obis):
try:
aObjects = []
tmp = obis.split(":")
if len(tmp) != 2:
raise ValueError("Invalid Logical name or attribute index.")
aObjects.append((tmp[0].strip(), int(tmp[1].strip())))
for k, v in aObjects:
obj = self.client.objects.findByLN(ObjectType.NONE, k)
if obj is None:
raise Exception("Unknown logical name:" + k)
val = reader.read(obj, v)
return val
except (KeyboardInterrupt, SystemExit):
self.media = None
raise
finally:
self.close()
But nothing happend :(
I solved it, I found the way…
I solved it, I found the way to get it done :)
But it has a problem, It only works if I use GetAssociationView(), and data are saved in a text file named logFile.text (output file).
Is it possible read data from the meter but without saving data in a file?
great job with the library
Hi, You don't need the…
Hi,
You don't need the association view or you can save it to the file so it's not read from the meter after the initial read. You can use -o output.xml argument for that.
You can also add objects like this
obj = GXDLMSRegister ("OBIS CODE")
self.read(obj, 2)
BR,
Mikko
Hi, I did that and It works…
Hi,
I did that and It works but just one time, I'm reading the meter every 2 minutes. After the first read I get the following error Failed to receive reply from the device in given time.
Authentication: 0
ClientAddress: 0x10
ServerAddress: 0x4a92
Standard: 0
Data send failed. Try to resend 1/3
Data send failed. Try to resend 2/3
RX: 00:15:52 7E A0 21 21 00 02 2A 25 73 DC D6 81 80 12 05 01 80 06 01 3E 07 04 00 00 00 01 08 04 00 00 00 01 07 22 7E 7E A0 21 21 00 02 2A 25 73 DC D6 81 80 12 05 01 80 06 01 3E 07 04 00 00 00 01 08 04 00 00 00 01 07 22 7E 7E A0 21 21 00 02 2A 25 73 DC D6 81 80 12 05 01 80 06 01 3E 07 04 00 00 00 01 08 04 00 00 00 01 07 22 7E
This is part of the code i'm using
reader = GXDLMSReader(settings.client, settings.media, settings.trace, settings.invocationCounter)
settings.media.open()
reader.initializeConnection()
voltage = 0.0
try:
obis = "1.1.32.7.0.255"
obj = GXDLMSRegister(obis)
resultV = reader.read(obj, 2)
settings.invocationCounter = 1 + obj.value
except Exception as ex:
data.update({'error': True, 'message': str(ex)})
else:
reader.showValue(2, resultV)
voltage = round(float(resultV / 10), 1)
data['measures'].update({'voltage': voltage})
data.update({'error': False, 'message': ''})
I read in a topic that it's necesary to increase the value of invocationCounter
What would be the problem ?
Hi, There is a inactivity…
Hi,
There is a inactivity timeout and I believe that it's less than two minutes.
If you wait two minutes, the meter believes that the connection is closed and you need to establish a new connection.
You can try to establish the connection, read the data, and close the connection.
You can also try to read values every minute. If you are not receiving a reply. then try to establish a new connection.
BR,
Mikko