richibrics / IoTuring

Your Windows, Linux, macOS computer as MQTT and HomeAssistant integration

Home Page:https://pypi.org/project/IoTuring/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typerror when starting main.py on Linux host with Python 3.10

Lefuneste83 opened this issue · comments

Hello

On a PC running Linux Mint 21, when trying to start the main.py script after setting the connection variables I get :

With HA Warehouse :

1 - Manage entities
2 - Manage warehouses
C - Start IoTuring
Q - Quit

Select your choice: C

[ 2022-11-22 19:54:57 |   Info   |              App              ]  Name: IoTuring
[ 2022-11-22 19:54:57 |   Info   |              App              ]  Version: 1.0.0
[ 2022-11-22 19:54:57 |   Info   |              App              ]  Description: Simple and powerful script to control your pc and share stats to HomeAssistant.
[ 2022-11-22 19:54:57 |   Info   |          Configurator         ]  Run the script with -c to enter configuration mode
[ 2022-11-22 19:54:57 |   Info   |         Entity.AppInfo        ]  Initialization successfully completed
[ 2022-11-22 19:54:57 |   Info   |         Entity.AppInfo        ]  Post-initialization successfully completed
[ 2022-11-22 19:54:57 |   Info   |              MQTT             ]  Preparing MQTT client
[ 2022-11-22 19:54:57 |   Info   |              MQTT             ]  MQTT Client ready to connect to the broker
Traceback (most recent call last):
  File "/home/user/Temp/IoTuring/main.py", line 43, in <module>
    warehouse.Start()
  File "/home/user/Temp/IoTuring/ClassManager/../Warehouse/Deployments/HomeAssistantWarehouse/HomeAssistantWarehouse.py", line 43, in Start
    self.client.AsyncConnect()
  File "/home/user/Temp/IoTuring/Protocols/MQTTClient/MQTTClient.py", line 59, in AsyncConnect
    self.client.connect_async(self.address, port=self.port)
  File "/home/user/.local/lib/python3.10/site-packages/paho/mqtt/client.py", line 979, in connect_async
    if port <= 0:
TypeError: '<=' not supported between instances of 'str' and 'int'_

With MQTT Warehouse :

1 - Manage entities
2 - Manage warehouses
C - Start IoTuring
Q - Quit

Select your choice: C

[ 2022-11-22 19:57:13 |   Info   |              App              ]  Name: IoTuring
[ 2022-11-22 19:57:13 |   Info   |              App              ]  Version: 1.0.0
[ 2022-11-22 19:57:13 |   Info   |              App              ]  Description: Simple and powerful script to control your pc and share stats to HomeAssistant.
[ 2022-11-22 19:57:13 |   Info   |          Configurator         ]  Run the script with -c to enter configuration mode
[ 2022-11-22 19:57:13 |   Info   |         Entity.AppInfo        ]  Initialization successfully completed
[ 2022-11-22 19:57:13 |   Info   |         Entity.AppInfo        ]  Post-initialization successfully completed
[ 2022-11-22 19:57:13 |   Info   |              MQTT             ]  Preparing MQTT client
[ 2022-11-22 19:57:13 |   Info   |              MQTT             ]  MQTT Client ready to connect to the broker
Traceback (most recent call last):
  File "/home/user/Temp/IoTuring/main.py", line 43, in <module>
    warehouse.Start()
  File "/home/user/Temp/IoTuring/ClassManager/../Warehouse/Deployments/MQTTWarehouse/MQTTWarehouse.py", line 30, in Start
    self.client.AsyncConnect()
  File "/home/user/Temp/IoTuring/Protocols/MQTTClient/MQTTClient.py", line 59, in AsyncConnect
    self.client.connect_async(self.address, port=self.port)
  File "/home/user/.local/lib/python3.10/site-packages/paho/mqtt/client.py", line 979, in connect_async
    if port <= 0:
TypeError: '<=' not supported between instances of 'str' and 'int'_

From what I understand, their seems to be a type mismatch for the port number (defined as string but expects an int in client.py )

The connection variables seem properly defined though (ie for HA warehouse) :

❯ cat configurations.json                                                                   
{"active_entities": [{"type": "AppInfo"}], "active_warehouses": [{"address": "192.168.0.XX", "port": "1883", "name": "blahblah", "username": "mqtt-pcname", "password": "somepassword", "add_name": "N", "type": "HomeAssistant"}]}% 

Any idea how to solve this ?

Edit

It works if leaving default value when defining port number (just typing return when asked)

Then you have "port": 1883 instead of "port": "1883" in configurations.json

@Lefuneste83 can you try if it works now ?

Thank you for finding the bug.