Raspberry Pi Mastery

Home Automation and IoT Hub

30 min

Home Assistant

The most popular open-source home automation platform. On a Pi 4/5 you can install Home Assistant OS (a dedicated system) or run it in Docker. It integrates thousands of devices: lights, plugs, thermostats, cameras and your own ESP32 sensors.

Connecting devices

  • MQTT: run Mosquitto (as an add-on or container); your ESP32 devices publish and subscribe (Arduino & IoT track).
  • ESPHome: configure ESP32 devices in YAML and adopt them automatically.
  • Zigbee/Thread: a USB coordinator stick connects battery-powered sensors and switches without Wi-Fi.

Automations

alias: Greenhouse pump when soil is dry
trigger:
  - platform: numeric_state
    entity_id: sensor.greenhouse_soil_moisture
    below: 30
    for: "00:10:00"
action:
  - service: switch.turn_on
    target: {entity_id: switch.greenhouse_pump}
  - delay: "00:00:30"
  - service: switch.turn_off
    target: {entity_id: switch.greenhouse_pump}
mode: single

Design automations to fail safe: a pump that stays on forever floods the greenhouse, so always add timeouts.

Security

  • Strong passwords and two-factor authentication on Home Assistant.
  • Remote access through a VPN or Home Assistant Cloud, not open ports.
  • Keep Home Assistant and add-ons updated.

Exercise

Install Home Assistant, connect an ESPHome or MQTT sensor, create a dashboard with history graphs and an automation with a safety timeout, and access it remotely through a VPN.

Check yourself

  • What does a Zigbee coordinator add?
  • Why add timeouts to automations controlling pumps or heaters?
  • How should Home Assistant be accessed remotely?

I tuoi progressi sono salvati solo in questo browser.

Invia per la revisione (10 punti)