(Core 2025.3.4, Supervisor 2025.03.3, Operating System 15.0, Frontend 20250306 on an AMD64)
I am a complete newbie at MQTT and trying to make a simple publish connection using python from a separate AMD64 machine to record data in MQTT within HA.
So far I have tested against another MQTT server without password authentication and it worked fine. I also set up the user/password in HA and have tested that using a PC based client that works also.
The problem is that when I put a python script together (using Thonny) with the user/password authentication it runs without incident but nothing gets posted in the HA MQTT. I am suspecting it may be something to do with the placement of the user/password authentication but I do not have the experience to determine what I’ve done incorrectly.
Here’s my script
# Test MQTT for GA pumps
import paho.mqtt.client as mqtt #import the client
username="pumps" #HA user
password="pumps" #user password
broker_address="192.168.1.99" #HA broker
#create new instance
client = mqtt.Client("GA_pump")
client.username_pw_set(username, password)
client.connect(broker_address) #connect
client.publish("ga/w_pump","OFF") #publish
Any guidance or help would be appreciated.