Home Assistant

Home Assistant server to use for smart home devices. The integrated MQTT server is not used, instead we use a separate Mosquitto server at


  1. Install according to: https://www.home-assistant.io/docs/installation/raspberry-pi/
  2. Setup autostart according to: https://www.home-assistant.io/docs/autostart/systemd/
  3. Set the MQTT broker settings in /home/homeassistant/.homeassistant/configuration.yaml as follows: mqtt: broker: username: mosquitto password: pw
  4. Restart hass: systemctl restart homeassistent.service.


The web interface can be accessed at:

Add Sonoff device

Configure the Sonoff device as follows:

MQTT Host:
MQTT Port:    1883
MQTT User:    mosquitto
MQTT Pass:    [pw]
MQTT Topic:   [unique identifier]

Add the following entry to /home/homeassistant/.homeassistant/configuration.yaml (light can be replaced with switch):

  - platform: mqtt
    name: "[insert description]"
    state_topic: "stat/[insert MQTT topic]/RESULT"
    value_template: '{{ value_json["POWER"] }}'
    command_topic: "cmnd/[insert MQTT topic]/POWER"
    availability_topic: "tele/[insert MQTT topic]/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: true

Restart hass: systemctl restart homeassistent.service.


see https://www.home-assistant.io/docs/installation/raspberry-pi/#updating