Successfully Integrating ESPResense with Binary Sensors for Smart Lighting Automation

Hey everyone,

I wanted to share my recent experience integrating ESPResense sensors with binary sensors to create a smart lighting automation system. It’s been a journey of learning and problem-solving, and I’d love to hear if anyone else has tackled similar projects!

The Goal:
I’ve been working on automating my home’s lighting system to turn off when no one is in the room. The idea is to save energy while maintaining comfort. I decided to use ESPResense sensors to detect the presence of BLE devices, like my family’s smartphones, and a binary sensor to trigger the lights based on their presence.

The Setup:
I started by setting up ESPResense sensors around my house. These sensors detect nearby BLE devices and send their data to Home Assistant. I then created a binary sensor using a template to check if any of my family’s devices were in the room. The binary sensor would switch to ‘on’ if a device was detected and ‘off’ after a delay if no devices were present.

Here’s a snippet of the configuration I used:
yaml

  • template:
    • binary_sensor:
      master_br_occupancy:
      friendly_name: Master Bedroom Occupancy
      state: >
      {{ “ESPresense_br_primary” in [ states(‘sensor.espresence_lynn_iphone’), states(‘sensor.espresence_ashley_iphone’)] }}
      delay_on: 5
      delay_off: 30

The Challenge:
Initially, I ran into some issues with the configuration. I kept getting errors about missing keys and invalid schemas. After some research, I realized I needed to structure my YAML files correctly. I separated my sensor configurations into a dedicated sensors.yaml file and included it in my main configuration.yaml. This helped eliminate the errors and allowed the binary sensor to function properly.

The Outcome:
After resolving the configuration issues, the system worked beautifully! The lights now turn off automatically after 30 seconds if no one is in the room, and they turn back on as soon as someone enters. It’s been a great way to save energy without sacrificing convenience.

Lessons Learned:

  1. Attention to YAML Syntax: Even small syntax errors can cause big issues. Using a YAML validator helped me catch mistakes early.
  2. Community Resources: The Home Assistant community is amazing. I found a lot of helpful guides and examples that I could adapt to my project.
  3. Testing Incrementally: Instead of trying to set everything up at once, I tested each component separately. This made troubleshooting much easier.

Next Steps:
I plan to expand this system to other rooms in the house. I’m also looking into integrating motion sensors for added reliability. If anyone has tips or suggestions, I’d love to hear them!

It’s incredible how much you can achieve with a little research and experimentation. I’m excited to see how my home becomes even smarter in the coming months!

Best,
Lynn