A simple micro-python mqtt client which enables simple plug-and-play functionality and interoperability with Home Assistant.
"availability_topic": "home/wateringsystem/back/status",
"state_topic": "home/wateringsystem/back/output/solenoid3",
"command_topic": "home/wateringsystem/back/output/solenoid3/set",
The overall standard of MQTT topics that will be used going forward is:
<area>/<entity>/<location>/<property>/<object>/<modifier>
but there's no set requirement on structure.
topic_prefix is: <area>/<entity>/<location>
This simplifies it down to:
<topic_prefix>/<property>/<object>/<modifier>
Following the official Raspberry Pi Docs
- Hold down the bootsel button while plugging in pi pico for the first time
- Open Thonny with the pico plugged in
- Choose the micropython language selector in the bottom right hand corner of the UI
- Choose the latest version of Micropython and install it onto the raspberry pi
- In the top bar of Thonny, under
Tools
, there should be an option toManage Packages
, select that option - Then search for
umqtt
in the package manager, there should be one calledmicropython-umqtt.simple
and install it onto the Pi Pico.- You could potentially use mpremote
mpremote mip install micropython-umqtt.simple
(untested) in the Thonny console when the Pi Pico is connected
- You could potentially use mpremote
- Clone the mqtt-home repository to a local area
- Create an appropriate
config.json
file based off thetest-config.json
- Upload
config.json
,main.py
,boot.py
andmain
to the Pi Pico - Manually run
boot.py
andmain.py
in Thonny to ensure that the SSID and password are correct, in addition to the Home Assistant connection. - Once confirmed connected, disconnect the Pi Pico and plug it in from cold to ensure that the start up works as expected.
- Once the status LED is shining, that is an indication that
main.py
is running and the Pi Pico should be up and running!
- Using a virtual environment, install the python dependencies listed in
requirements.txt
by runningpython -m pip install -r requirements.txt