BrickPico Home Assistant (MQTT Discovery) Support - tjko/brickpico GitHub Wiki
MQTT Client support in BrickPico allows it to appear as "MQTT Device" in Home Assistant.
BrickPico supports MQTT Discovery feature in Home Assistant, making it easy to add FanPico units into Home Assistant. NOTE, BrickPico is using MQTT "Device Discovery" feature, so it will require recent version of Home Assistant.
Requirement
To use BrickPico with Home Assistant following is needed:
- Enable MQTT Integration in Home Assistant (see Home Assistant: MQTT Integration).
- Add user (person) for FanPico to use to connect to MQTT Server (see Adding a person to Home Assistant).
- Following information is needed to proceed:
- MQTT server hostname or IP address (usually this is same as the Home Assistant server)
- MQTT server port
- MQTT username
- MQTT password
- MQTT Discovery prefix (found in Home Assistant MQTT Integration configuration, typically "homeassistant")
Configure BrickPico as MQTT Device for Home Assistant
Here we assume BrickPico is already configured and connected to WiFi network. See BrickPico Web Interface for tutorial on how to configure WiFi on BrickPico.
Configure MQTT Server Information
First step is to configure MQTT Server information (hostname/IP, tcp port, username, and password).
FanPico will default to port 1883 when TLS is disabled and port 8883 if TLS is enabled.
This example assumes that Home Assistant is on IP address 192.168.1.10, and MQTT is not using TLS and is on default port 1883):
SYS:MQTT:SERVER 192.168.1.10
SYS:MQTT:TLS OFF
If MQTT is using non-standard port, it can be configured as follows:
SYS:MQTT:PORT 1884
Configure MQTT Credentials
Next we need to configure username and password that FanPico will use to authenticate with the MQTT server.
SYS:MQTT:USERNAME mqttsensor
SYS:MQTT:PASSWORD password123
Configure MQTT Discovery
Next we enable Home Assistant MQTT Discovery, so that BrickPico will automatically appear in Home Assistant.
Here we assume Home Assistant is using default discovery prefix "homeassistant" and that we want to send updates every 60 seconds (default is once every 600 seconds):
SYS:MQTT:HA:DISCOVERY homeassistant
SYS:MQTT:INT:STATUS 60
Configure What Information to Send to Home Assistant
Next we need to configure at which outputs to expose to Home Assistant using SYS:MQTT:MASK:PWM
command.
For example here we want first 4 outputs show up in Home Assistant:
SYS:MQTT:MASK:PWM 1-4
Save Configuration
Last step is to save configuration and reset (reboot) FanPico for MQTT client to get enabled during boot process:
CONF:SAVE
*RST
Check Sensor in Home Assistant
After BrickPico has rebooted, it should appear as MQTT Sensor in Home Assistant after couple minutes (assuming SYS:MQTT:INT:STATUS
was set to 60 seconds earlier).