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: '<=' not supported between instances of 'str' and 'int' #5

Open
RonRN18 opened this issue May 23, 2024 · 1 comment
Open

Comments

@RonRN18
Copy link

RonRN18 commented May 23, 2024

I am apparently unable to make a connection to my MQTT broker, which exists on a different device; a Home Assistant box. The screen just displays:

Connecting to 
MQTT broker...

Meanwhile, in my shell, I see:

/home/bigron/./ospiLCD-mqtt.py:256: DeprecationWarning: Callback API version 1 is deprecated, update to latest version
  client = mqtt.Client()
Traceback (most recent call last):
  File "/home/bigron/./ospiLCD-mqtt.py", line 259, in <module>
    client.connect(mqttAddress, mqttPort, 60)
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1433, in connect
    self.connect_async(host, port, keepalive,
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1525, in connect_async
    self.port = port
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 914, in port
    if value <= 0:
TypeError: '<=' not supported between instances of 'str' and 'int'
@RonRN18
Copy link
Author

RonRN18 commented May 27, 2024

I realized that it the TypeError was due to the way the mqttPass was defined in Line 32; the quotation marks need to be removed from the variable declaration. With quotation marks, it thinks that the port number is a string, not a number. Unfortunately, that didn't solve all of the issues. It now has an issue with calling the client.

/home/bigron/./ospiLCD-mqtt.py:256: DeprecationWarning: Callback API version 1 is deprecated, update to latest version
client = mqtt.Client()
[Connected with result code 5]
[Connected with result code 5]

On line 254 it says:

client = mqtt.Client()  

Apparently, this is attempting to connect with API version 1, which has been deprecated. I know that my MQTT broker supports version 5. I was doing some testing and can't figure out how to tell it to use version 5 but I did see a command to make it try version 2. If I change it to:

client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)

With this, I get an error saying:

Traceback (most recent call last):
  File "/home/bigron/./ospiLCD-mqtt.py", line 260, in <module>
    client.loop_forever()
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 2297, in loop_forever
    rc = self._loop(timeout)
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 1686, in _loop
    rc = self.loop_read()
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 2100, in loop_read
    rc = self._packet_read()
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 3142, in _packet_read
    rc = self._packet_handle()
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 3814, in _packet_handle
    return self._handle_connack()
  File "/usr/local/lib/python3.9/dist-packages/paho/mqtt/client.py", line 3934, in _handle_connack
    on_connect(
TypeError: mqtt_connect() takes 4 positional arguments but 5 were given

I am hoping I'm making progress but as of yet, I don't have it working.

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

1 participant