I’ve been diving into the world of smart home automation lately, and I must say, it’s been an exciting journey! I recently started using an ESP32 board alongside Xiaomi thermometers to monitor temperatures in my home. It’s been working like a charm so far, but I ran into an interesting challenge that I wanted to share and get some advice on.
I’m currently using the ESP32 with ble_tracker to import temperature readings from my Xiaomi thermometers into Home Assistant. That part is working perfectly. I also have a heater controlled by a thermostat, which switches on a relay based on the temperature readings. To add some redundancy, I wanted to merge these two solutions so that my ESP32 board, which already collects the temperature data, could also control the relay directly. The goal is to have a failsafe system where the heater turns on if the temperature drops below a certain threshold, even if Home Assistant is down.
I’ve looked into the automations help-page for esphome and found some useful templates, but I’m stuck on how to access the temperature values from ble_tracker within the YAML configuration. I understand that I need to reference the sensor values somehow, but I’m not quite sure how to structure the code. Here’s what I have so far:
yaml
switch:
- platform: gpio
name: “heater”
pin: 5
id: heater
esp32_ble_tracker:
sensor:
- platform: atc_mithermometer
mac_address: “A4:C1:38:85:3F:B4”
temperature:
name: “Bedroom 1 Temperature”
humidity:
name: “Bedroom 1 Humidity”
battery_level:
name: “Bedroom 1 Battery-Level”
battery_voltage:
name: “Bedroom 1 Battery-Voltage”
signal_strength:
name: “Bedroom 1 Signal”
From what I gather, I need to use an automation that triggers when the temperature falls below a certain value. The example I found uses a Dallas sensor, but I’m not sure how to adapt it for the ble_tracker values. I think the solution is simpler than I’m making it out to be, but since I’m still getting the hang of YAML, I could use a bit of guidance.
If anyone has experience with this or knows how to reference the ble_tracker sensor values in an automation, I’d really appreciate the help! It would be amazing to have this failsafe system up and running. Thanks in advance for any insights or suggestions you might have!