Smart Thermostat

#hw_project #done
Motivated by rising energy prices I wanted to switch from a standard thermostat to a smart (but cheap) solution using Home Assistant, zigbee temperature sensors and wifi relay for controlling the gas boiler. In the following text I describe the system components and the setup process.


Setup steps

  1. Prepare the Zigbee dongle
  2. Install Home Assistant (HASS)
    1. Add Zigbee devices to HASS
  3. Set up reverse proxy for remote access
  4. Create the Wifi Relay

1) Flashing CC2531 with custom firmware using Raspberry PI

Additionally, I checked the connections after step 3 using the CC2531 pinout chart:

2) Setting up the hub


yaourt -Sy home-assistant rust  
systemctl enable --now home-assistant.service  
sudo vim /boot/config.txt # disable wifi and bluetooth to mitigate wifi/zigbee interference  
sudo gpasswd -a hass uucp # hass user must have access to /dev/ttyACM0

2a) Adding Zigbee devices to HASS

This is possible through the ZHA integration, which is available out-of-the-box in HASS. This way I was able to add my smart lights and crucially the thermometers.

2b) Nginx reverse proxy for Home Assistant

To allow remote access to my home assistant, I wanted to use reverse proxy. This way allows me to access HASS through https easily (using Lets encrypt certificate)

3) Creating the Smart Relay

$ pip install esphome
  • Create boiler.yaml. In the wizard select the esp01_1m board
$ esphome wizard boiler.yaml
  - platform: gpio
    name: "Relay"
    pin: GPIO0
  • Compile and flash ESPHome:
$ esphome run boiler.yaml
  • Connect ESP to the Relay board
  • Connect the boiler dry contacts into the relay (use COM and NC outputs)
  • Connect +5V power supply into the relay
  • Find the IP address of the relay and set up static IP through router settings (using the mac address)
  • Restart ESP and add it through ESPHome integration in Home Assistant (entering the static ip)
  • Ask your friend to print an enclosure box 
    Pasted image 20230818135256.png