Help getting sensor data to HA via MQTT

Looking for some help, advice, or direction on doing the following: Grab current temperature from an Enviro-Phat which is connected to a RPi Zero W (not my RPi) and send that temperature reading to HA via MQTT.

Part 1: I can print out the current temp reading with the following (based on the Enviro Phat example documentation):

#!/usr/bin/env python3
from envirophat import weather
    while True:
        temperature = (weather.temperature() * 1.8) + 32
except KeyboardInterrupt:

Part 2: I have separately and successfully sent TEST “sensor” data (see number “50” below) to HA via MQTT with the following:

#!/usr/bin/env python3
import paho.mqtt.client as mqtt
client = mqtt.Client()
client.username_pw_set(username="systmdata", password="mycatsname")
client.publish("kids/room/temperature", "50");

Part 3: With the following in my configuration.yaml; (I see the “test” data arrive and post just fine):

- platform: mqtt
  state_topic: "kids/room/temperature"
  name: 'Kids Room Temperature'
  unit_of_measurement: "F"

How do I get the data from Part 1 (temperature reading) into Part 2 (replace the “50” with real data) and sent over to HA?

Full disclaimer, I like challenge and at time’s that means I get my hands dirty learning enough to just get by with some code and hopefully not butchering it along the way. This time though, I feel a bit in over my head.