ESP Automations

All done in esphome

Het Walber I gotta thankyouā€¦Iā€™ve been stuffing around for over 2 weeks between reading posts and googling, your post put everything in place. I think it was a combination of learning as I made mistakes which is good. Whilst Iā€™m waiting for my beacons to arrive I did a simple test using my Bluetooth earbuds as my beacon. My environment is not the best as my Bluetooth tracker is in my garage which is color bond (metal) so acts like one big shield. However without any automations I open my roller door and drive as I wouldā€¦bloody blue-tooth doesnā€™t let go until I way down the street. The good thing as you suggested I can use the RSSI values to close my door when it gets to a certain level. I think the trouble I may have is when Iā€™m arriving home and the door is shut I practically have to drive through it for the bluetooth to connect again. Do you have any ideas to improve this? I now have 2 entities in home assistant that I can useā€¦one for the tracker and the other for RSSI value. Anyway I have posted my yaml for any suggested improvements.

esphome:
  name: presence
  friendly_name: Presence

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "++ycUT3TgMrYKlR+MONb9xrbMkXs6HBudhnXTHL6WZM="
  on_client_connected:
     - esp32_ble_tracker.start_scan:
        continuous: true
  on_client_disconnected:
    if:
      condition:
        not:
          api.connected:
      then:
        - esp32_ble_tracker.stop_scan: 

ota:
  - platform: esphome
    password: "ccdbafb98d0e8898d2b925a559b3bd2b"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Presence Fallback Hotspot"
    password: "9B7tKacBz5ln"

captive_portal:

web_server:
  port: 80

esp32_ble_tracker:

binary_sensor:
  - platform: ble_presence
    mac_address: 00:1B:66:18:51:7E
    name: "Car Dongle"
    timeout: 30s

sensor:
  - platform: ble_rssi
    mac_address: 00:1B:66:18:51:7E
    name: "Car Dongle RSSI"

When you leave, you can manage it using the RSSI or using other sensors inside the garage.
But when you arrive, you need a strong signal.
The iBeacon will probably have a better range than the earbuds, but if it is not enough, you will have to improve the signal,
by moving the board or using a board with an external antenna.

Thanks im just happy i actually got something working. The key for me was i previously used BLE tracker but didnt know i had to setup sensors within ESP, im learning and really appreciate your time in responding

Hi Walber, do you mind clarifing the following, whilst Iā€™m waiting for my beacons to arrive I flashed another ESP32 with the ibeacon software (https://esphome.io/components/esp32_ble_beacon)

here is my config yaml

esphome:
  name: beacon
  friendly_name: Beacon

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "jHNGtKYhTlnQaWI5qCsiE7EIyR56DpiOrGS/KE7FH2E="

ota:
  - platform: esphome
    password: "206edc47a7ed88c2a16af71b5dc4fab0"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Beacon Fallback Hotspot"
    password: "UytEIsoAnA1a"

captive_portal:

esp32_ble_beacon:
  type: iBeacon
  uuid: "c4ac38cd-0830-e516-e570-441ba8e4e67a"

I substituted my MAC address from my earbuds to the MAC address of my beacon ESP32
Config yaml as a reference:

esphome:
  name: car-tracker
  friendly_name: Car Tracker

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "+CVC3HJrMLlBecM9l9lGKikntLoKTf5d70InYesGCx0="
  on_client_connected:
     - esp32_ble_tracker.start_scan:
        continuous: true
       
  on_client_disconnected:
    if:
      condition:
        not:
          api.connected:
      then:
        - esp32_ble_tracker.stop_scan:  

ota:
  - platform: esphome
    password: "3aeaac1160e02761d8e318e26d7884f4"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Car-Tracker Fallback Hotspot"
    password: "o0PdT6S2WKAH"

captive_portal:

web_server:
  port: 80
# Change active to false to test
esp32_ble_tracker:
  scan_parameters:
    active: true

binary_sensor:
  - platform: ble_presence
    mac_address: CC:BA:97:15:53:18 (Beacon ESP32)
    name: "Car Dongle"
    timeout: 30s

sensor:
  - platform: ble_rssi
    mac_address: CC:BA:97:15:53:18
    name: "Car Dongle RSSI"

The states in development tools for my sensor do not change like they do for the earbuds.
Could it be because the docs for the beacon config say this:

For using these beacons to track the location of your phone, you will need to use another app. For example, I used this guide by the owntracks app to let my Home Automation system know when Iā€™m home or away. Another nice Android app is Beacon MQTT. It can work with multiple beacons simultaneously.

Thanks

I have never used esp32_ble_beacon.
Have you tested it with uuid?

binary_sensor:
  - platform: ble_presence
    ibeacon_uuid: c4ac38cd-0830-e516-e570-441ba8e4e67a
    name: "Car Dongle"
    timeout: 30s

sensor:
  - platform: ble_rssi
    ibeacon_uuid: c4ac38cd-0830-e516-e570-441ba8e4e67a
    name: "Car Dongle RSSI"

Iā€™m trying to put into practice what I said.
I believe itā€™s reliable, but I donā€™t know if it will be fast enough.

Thanks the UUID worksā€¦I did try it with UUID but used this format service_uuid: instead of ibeacon_uuid:, half the battle for people who are learning is trying to find the information. Where did you find the correct syntax. My battle has always been the time it takes for any device to change state. This method thus far has been the best. I think leaving my garage should be ok as I will use a motion sensor which will close my door after xx secs that its clear. Coming back on the other hand Iā€™m hoping that as I drive down my lane way around 30m by the time I reach the door it will open. With the beacon that I bought as long as its in my parked car in the garage the state will always be ā€œonā€ correct? if this method works I will see if I can buy a usb powered one so that when I start the car it can also be used to trigger the opening of my door. Really appreciate your help this door is driving me crazy but Iā€™m not letting it go.

Yes.

You just need to place the ESP somewhere to pick up both the signal when the car is parked and the signal when it arrives.

What does this mean? (English is not my first language)

My garage is made of bricks and concrete and my gate is metal,
detection happens at about 20/30 meters