Skip to content
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

TypeError: 'NoneType' #8

Open
speedbird620 opened this issue Nov 21, 2024 · 1 comment
Open

TypeError: 'NoneType' #8

speedbird620 opened this issue Nov 21, 2024 · 1 comment

Comments

@speedbird620
Copy link

speedbird620 commented Nov 21, 2024

I finally got the connection to my Home Assistant MQTT broker to work, but I had to add a MQTT-user and a password (see blue marking) in order to connect.

While trouble shooting I added the two lines in yellow in order to make thing easier.

The next hurdle I cant get my head around is a "NoneType" error message. Since the Pico isn´t connected to any HAN-meter I don´t understand the issue since there will not be any characters on the UART ... or what am I missing?

image

@vilhelmericson
Copy link

vilhelmericson commented Nov 22, 2024

I think you have to connect your Pico to a HAN port/serial port to use uart.readline() successfully using your code, otherwise there will be a timeout, see this query and its answers. Based on that I use this code in my Pico to read lines from the HAN port:
image

Tip: During development or testing, i.e. when the Pico isn't connected to a HAN port, you can fake a port using a text file instead as shown in the code below:
image
When using the faked port, i.e. when using the uart file object, you can use the same code to read lines from the file as used when reading lines from the HAN port. I use this text file to fake the port, test_data.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants