Sorry but why do you think return is wrong. every function needs to have a return. This function’s return is in finally which is always executed in the try/catch situation hence why return is in finally.
It might be better to use latest version of python but in any case can you try Pip3 instead of pip?
If you can use python3.9 try this:
once again sorry for not directly helping with your python code. Did you try the alternate approach of using Raspberry PI GPIO directly from Home assistant? this will remove the need for this python code.
Or are you keen to get the python code working? (if i were you i would not give up until i figure this out but then there is a still a limit to how long you want to spend you time and energy on this)
I would like to get this script working. It’s will be a good school for learn.
I think the i understood the problem but i don’t know how to resolve it now.
Script in under a subfolder of \home path. This script is autostarted so i think that it is started from root user and paho i think is installed with pi user. I tried to istall paho with sudo ut it don’t resolve the problem…
Glad the import issue is resolved. Did you try running the python script directly and printing out the fanspeed to see if it is acquiring and logging data actually?
if it is then next thing to check is if your MQTT server is up and running. You can use MQTTSpy to monitor if the script is actually logging any readings. Then the last part is to make sure your Hassio is connected to this mqtt server. if you used Hassio addon for MQTT then last thing should not be a problem, the server and connection to it are automatically setup.
I’m using mqtt explorer to monitor mqtt publish and i don’t see this publish.
Mqtt is already configured in HA and it is working. I have other publish that arrive to my mqtt broker. I don’t know how i could print the fanspeed…
In your code i do not see you establishing the connection first with the MQTT server. try to follow my original code. you have to first connect with the server before calling the publish function. also remember to put proper error etc mesasge logs
don’t work… no error but don’t print nothing. Now i want to try a simply script just to understand if paho is working. i don’t know python so i should to find something to test…