Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8023

Python • Re: MQTT publish fomatted sensor reading

$
0
0
client.publish("sensor1",temperature_formatted()) omit the braces after temperature_formatted

And, perhaps, omit the braces in
temperature_formatted = ( f"{temperature:.1f}" )

Side topic, I would add a client.loop_start() after the connect.
Removing the () brackets fixed it, thank you. I then didn't touch the curly brackets.
client.loop_start() added - thanks for the tip.

Statistics: Posted by richard238 — Sun Apr 20, 2025 3:36 pm



Viewing all articles
Browse latest Browse all 8023

Trending Articles