For full instruction see the Microhomie repository.
This repository has a lot of pre written nodes for Microhomie, the MicroPython implementation of the Homie v2 convention.
Most of these nodes can be used out of the box to publish data.
Install nodes with upip:
>>> import upip
>>> upip.install('microhomie-node-dht22')