-
Notifications
You must be signed in to change notification settings - Fork 22
AttributeError: 'NoneType' object has no attribute 'write' #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, same error here. File "iec.py", line 5, in my code: client = Iec6205621Client.with_serial_transport(port='/dev/ttyUSB0') password_challange = client.access_programming_mode() client.send_password('00000000') # Common standard password data_answer = client.read_value('1.8.0') print(data_answer) any help ? |
Hi It seem like I have forgotten to add a crucial part of connection to the meter in the README. You will need to call But maybe you don't need the programming mode? I find that using the standard readout, that is not password protected is quite useful when fiddling with your meter at home. What devices are you guys using? Model and manufacturer. And maybe what country you are in. Some utility companies limits the functionality over the optical port. Could you try the following code and see if you get a response from the meter: from iec62056_21.client import Iec6205621Client
import logging
# set up logging so you get a bit nicer printout of what is happening.
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s,%(msecs)d %(levelname)s: %(message)s",
datefmt="%H:%M:%S",
)
client = Iec6205621Client.with_serial_transport(port="/dev/tty.usbserial-A704H991")
client.connect()
data_answer = client.standard_readout()
print(data_answer) I will update the example to a simpler one: #5 |
Hi 18:56:26,135 INFO: Staring init sequence I assume I do not get a response from the energy meter. The device I am trying to read is a Landis & Gyr E450 and I am living in Switzerland. When I do try to communicate with the device in a very simple manner (b"/x2F/x3F/x21/x0D/x0A" over the serial port with 300 or 9600 baud) I also do not get a response from the device. Is it correct to assume, that my network supplier needs to activate the d0 optical interface. Thank you very much Marc |
Sorry - I hit the wrong button. |
Your D0 port should be active. But it could have been set to only accept DLMS messages. First thing to try is to add the address to the RequestMessage. The problem is that I seem to have forgotten to add that use case in this library. I know I have it in a previous version that I did for a client but could not open source. To test if it is the address that is missing try the following code: import serial
from iec62056_21.messages import RequestMessage
import logging
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s,%(msecs)d %(levelname)s: %(message)s",
datefmt="%H:%M:%S",
)
PORT_NAME = "/dev/tty.usbserial-A704H991"
DEVICE_ADDRESS = "7820130"
port = serial.Serial(
PORT_NAME,
baudrate=300,
parity=serial.PARITY_EVEN,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.SEVENBITS,
writeTimeout=0,
timeout=30,
rtscts=False,
dsrdtr=False,
xonxoff=False,
)
request_msg = RequestMessage(device_address=DEVICE_ADDRESS)
port.write(request_msg.to_bytes())
print(port.readline()) The Device address should be printed on you meter. usually 7-8 numbers. (could be more though) |
Hi My energy provider also informed me, that the port is available and that the password is the initial one. I tried the commands above and got only an empty binary string How would I proceed if the device requires a DLMS message ? Thank you very much for your support. |
Did you find the address of the meter and used that in the code? The empty bytes are just because you hit the timeout. I do think you should be able to get a response somehow. Here is where the address should be from some online pictures I found. I am writing a DLMS library but I am not supporting communiation via the local port yet. https://github.com/pwitab/dlms-cosem. But it is next on my todo list You can always try Gurux, but I find it to be a bit messy. |
Hi, I tried a couple of times the code above and never got a response. Even with the right serial ID. With your code example above I now get b'?44337606!\r\n' as a response. The number represents the serial ID of the smart meter. Where can I find the different value ID's to read ? Thank you very much for your support best regards Marc |
Hmm. I think you are getting optical echo from the write command if you don't have the optical probe flush against the meter. TX is bouncing to RX and you just receive the same message as you are sending. request_msg = RequestMessage(device_address="44337606") would produce the bytes you are receiveing. |
Just one question. When you where talking to your energy provider, did they refer to the port as the "Kundenschnittstelle"? That is usually a different port on the meter that is a physical connection, like RJ12. |
I removed the tape and the IR-head sits again straight on the smart meter. I asked my energy supplier if the optical port needs to be activated. They confirmed, that it is active , operating a 300 baud and uses for reading the standard password "0000.0000" The last test code is not using the password anywhere. Could be the root cause ? |
No I don't think so.
|
I am very thankful for your support. I tried both using the following code, no success :-( I am wondering, if my meter is broke or if there is any other setting, on the device that I need to do.
The response I got was empty
|
Ops. I left out the leading char in requestmessage. It starts with a slash. Try to send either:
or
I found some old comments and I know just sending |
Sorry, for taking so long .... I also asked L&G if they could help me. Their response was that I am only allowed to read the meter if I have a permission from my local energy provider. I am somewhat surprised, that I need to ask someone to access my own data ?!?. (This can not be compatible to DSGVO) From my energy provider I got so far a good feedback. They told me that the optical port should be active and provided the baud rate & password. Still this did not resolve my issue. L&G also mentioned that the device can be read using the DLMS protocoll. Do you know a quick way to check for a response ? Last but not least they mentioned that I could read my data using a "Smart me" device. From what I found this seems to be an additional energy meter. Thank you so much for your help. |
Well thats the usual fluff, the meter manufacturers don't want to give all information about their devices to end users. I don't have a quick DLMS check, sorry. But so far you have had no response from the meter, but you did get a response back when you held the optical probe at a distance but then you only received exactly what you sent. What type of optical probe are you using? |
I am using this probe: https://shop.weidmann-elektronik.de/index.php?page=product&info=24 Could it be that the optical interface is deactivated by default. Since they did not activate it actively it may not be active ? of are they active by default ? Thank's for your help. |
OK. Seems like a proper one. They can order meters in any configuration they want pretty much. So it is hard to say. I saw that there were som example programs on the website of the probe. Have you tired any of them? Seems to do the same as this library but would be good to test. |
Hi, Finally I managed to talk to a technician from my local power supplier. He informed me, that some devices need dlms while others can be read using IEC62056. The device I have needs dlms. :-( I tried to connect to the device using the Gurux library and finally I got a response. Now I need to understand what response it is and how I get the typical 1.7, 1.8 ... values. The Gurux library seems to be far more complicated. If you have an hints - I would appreciate them very much. Thank you very much for your help. Marc |
Yay. Finally :) No problem. Yeah DLMS is a quite a bit more complex. My own implementation is not ready yet, I need to find some time/finance to complete the design of some of the basics. Gurux works but I also think the API flow i a bit complex. The python implementation seems to have been autogenerated from another language but it does seem to work well and the Gurux guys are very knowledgeable on DLMS. My own implementation aims for a simpler API so one doesn't have to know that much about DLMS to use it. If it is not too much work for you you could open up an issue in https://github.com/pwitab/dlms-cosem and describe your use case and how it is handled in Gurux. It would be good to have a well defined use case for continuing the work. I have been struggling on deciding on which end to start. |
Hi,
I am trying to read my Smart Meter using this libraray.
I am using a USB to IR adapter and I am trying to read it via the d0 interface.
I made a fresh install on a raspberry pi 4 with raspian buster lite and I continue to get the above failure message. Do you have any ideas on how to resolve the issue ?
It would be great, if anyone coulde help.
Thank you
Marc
Actual code:
from iec62056_21.client import Iec6205621Client
client = Iec6205621Client.with_serial_transport(port='/dev/ttyUSB0')
password_challange = client.access_programming_mode()
client.send_password('00000000') # Common standard password
data_answer = client.read_value('1.8.0')
print("Result:")
print(data_answer)
Full Error message:
Traceback (most recent call last):
File "reader.py", line 5, in
password_challange = client.access_programming_mode()
File "/home/pi/.local/lib/python3.7/site-packages/iec62056_21/client.py", line 164, in access_programming_mode
self.startup()
File "/home/pi/.local/lib/python3.7/site-packages/iec62056_21/client.py", line 143, in startup
self.send_init_request()
File "/home/pi/.local/lib/python3.7/site-packages/iec62056_21/client.py", line 239, in send_init_request
self.transport.send(request.to_bytes())
File "/home/pi/.local/lib/python3.7/site-packages/iec62056_21/transports.py", line 174, in send
self._send(data)
File "/home/pi/.local/lib/python3.7/site-packages/iec62056_21/transports.py", line 256, in _send
self.port.write(data)
AttributeError: 'NoneType' object has no attribute 'write'
PS: During the install I was only able to install the libraray using pip3 instead of pip.
The text was updated successfully, but these errors were encountered: