Home Assistant MQTT

Install MQTT broker (server) on Anroid
https://apkpure.com/mqtt-broker-app/server.com.mqtt/download

Create MQTT sensor
https://www.home-assistant.io/integrations/sensor.mqtt/

~/.homeassistant/configuration.yaml
/mnt/data/supervisor/homeassistant/configuration.yaml (on Raspery PI)

...
mqtt: !include inverter.yaml

~/.homeassistant/inverter.yaml

sensor:
  - name: "Inverter AC Power"
    unique_id: "inverter_ac"
    state_topic: "inverter/HM/ch0/P_AC"
    unit_of_measurement: "Wh"
    device_class: "energy"
    state_class: "measurement"
  - name: "Inverter DC Power"
    unique_id: "inverter_dc"
    state_topic: "inverter/HM/ch0/P_DC"
    unit_of_measurement: "W"
    state_class: "measurement"
  - name: "Inverter DC Volt CH1"
    unique_id: "inverter_dc_volt_ch1"
    state_topic: "inverter/HM/ch1/U_DC"
    unit_of_measurement: "V"
    state_class: "measurement"
  - name: "Inverter DC Current CH1"
    unique_id: "inverter_dc_current_ch1"
    state_topic: "inverter/HM/ch1/I_DC"
    unit_of_measurement: "A"
    state_class: "measurement"
  - name: "Inverter DC Power CH1"
    unique_id: "inverter_dc_ch1"
    state_topic: "inverter/HM/ch1/P_DC"
    unit_of_measurement: "W"
    state_class: "measurement"
  - name: "Inverter DC Volt CH2" 
    unique_id: "inverter_dc_volt_ch2"
    state_topic: "inverter/HM/ch2/U_DC"  
    unit_of_measurement: "V"            
    state_class: "measurement"
  - name: "Inverter DC Current CH2"
    unique_id: "inverter_dc_current_ch2"
    state_topic: "inverter/HM/ch2/I_DC"      
    unit_of_measurement: "A"           
    state_class: "measurement"  
  - name: "Inverter DC Power CH2"
    unique_id: "inverter_dc_ch2"
    state_topic: "inverter/HM/ch2/P_DC"
    unit_of_measurement: "W"
    state_class: "measurement"
  - name: "Inverter Yield Day"
    unique_id: "inverter_yield_day"
    state_topic: "inverter/HM/ch0/YieldDay"
    unit_of_measurement: "Wh"
  - name: "Inverter Yield Total"
    unique_id: "inverter_yield_total"
    state_topic: "inverter/HM/ch0/YieldTotal"
    unit_of_measurement: "kWh"
    device_class: "energy"
    state_class: "measurement"
  - name: "Inverter Temperature"
    unique_id: "inverter_temperature"
    state_topic: "inverter/HM/ch0/Temp"
    unit_of_measurement: "°C"
    icon: "mdi:thermometer"

Install mosquitto (MQTT broker) on Raspery PI OS as docker container

mkdir -p /mnt/data/supervisor/mosquitto//config /mnt/data/supervisor/mosquitto//data /mnt/data/supervisor/mosquitto//log
touch /mnt/data/supervisor/mosquitto/log/mosquitto.log
 
chmod 777 /mnt/data/supervisor/mosquitto/ -R
 
cat <<EOF> /mnt/data/supervisor/mosquitto//config/mosquitto.conf
persistence true
persistence_location mosquitto/data/
log_dest file mosquitto/log/mosquitto.log
log_dest stdout
#password_file config/mosquitto.passwd
allow_anonymous true
listener 1883
EOF
 
docker pull eclipse-mosquitto
 
docker run -d \
  -p 1883:1883 \
  -p 9001:9001 \
  --name mosquitto \
  --restart always \
  --mount type=bind,source=/mnt/data/supervisor/mosquitto//config,target=/mosquitto/config \
  -v /mnt/data/supervisor/mosquitto//data:/mosquitto/data \
  -v /mnt/data/supervisor/mosquitto//log:/mosquitto/log \
  eclipse-mosquitto:latest
 
# todo: use docker volume
# docker volume create mosquitto
# -v mosquitto:/mosquitto

Debug MQTT
http://mqtt-explorer.com/
https://snapcraft.io/install/mqtt-explorer/ubuntu#install

sudo snap install mqtt-explorer

Links
http://mqtt-explorer.com/
https://medium.com/swlh/android-and-mqtt-a-simple-guide-cb0cbba1931c