Reference: https://hometechhacker.com/mqtt-home-assistant-using-docker-eclipse-mosquitto/
-
Create the folders mkdir -p mosquitto/{log,config,data}
-
Create the mosquitto config then input texts in << >> nano mosquitto/config/mosquitto.conf
<< persistence true persistence_location /mosquitto/data/
user mosquitto
listener 1883
#Allow connection without authentication allow_anonymous true
log_dest file /mosquitto/log/mosquitto.log log_dest stdout
-
Ctrl+o - Enter, Ctrl+x to save
-
Run the MQTT docker container docker run -itd
--name=mqtt
--restart=always
--net=host
-v <folder_path>/mosquitto/config:/mosquitto/config
-v <folder_path>>/mosquitto/data:/mosquitto/data
-v <folder_path>>/mosquitto/log:/mosquitto/log
eclipse-mosquitto
Reference: https://www.home-assistant.io/installation/linux#install-home-assistant-container
-
Create the folder mkdir ha
-
Run the Home Assistant docker container docker run -d
--name homeassistant
--privileged
--restart=unless-stopped
-e TZ=Asia/Manila
-v <folder_path>/ha:/config
-v /run/dbus:/run/dbus:ro
--network=host
ghcr.io/home-assistant/home-assistant:stable
[email protected]:daniloc/PicoW_HomeAssistant_Starter.git
How to
- Set up the MQTT broker docker a. Make sure that the mosquitto.conf file is set Note: Error occurs when Adding user name and password, the docker image restarts always. Use without credentials.
- Test the MQTT broker a. Can use the Linux terminal as mosquitto-client b. Subscribe to a topic mosquitto_sub -h -t c. Test publish to a topic mosquitto_pub -h -t - m
- Set up the Home Assistant docker a. Add MQTT in the integration section b. Supply the configuration and credentials required for the MQTT broker (i.e. broker ip, port, username, password)
- Download the Arduino Pico-W project a. Configure the Credentials.h and supply the credentials of the MQTT broker b. Load the project to the pico-w board
Supposedly, the Pico-W board will automatically be added to the Home Assistant dashboard!
How?
- The Home Assistant supports auto discovery. The PicoW creates a discovery message within the firmware and publishes it to the topic that Home Assistant for configuration.