Thanks Hellis, I havent explored proximity intergation…i will now. Do you still have to specify a zone so it can calculate its distance? I have 2 entrances to my home but only one that has the gate…will that make a difference? Im glad i have some options to try now
Yes it needs a zone.
Hi Nathan, do you mind running your eyes over my process:
Here is my yaml for my esp32
esp32_ble_tracker:
scan_parameters:
interval: 1100ms
window: 1100ms
It installed and I have integrated into HA.
I installed the ibeacon integration.
On my companion app I have enabled BLE transmitter and recorded the UUID in my app at the bottom of that page.
I have enabled Beacon monitor, then I see a tracking attribute device UUID of 45m my proxy is less than 1m away. Its not the UUID that is in my app.
I have enabled the iBeacon intergration and when I add a device it wants the UUID, I provided the one in my app.
I then see five entities with the same name, if I click on one it has an estimated distance of 2m which doesn’t change, I’m assuming its measuring the distance between my phone and bluetooth proxy?
BTW if I unplug my bluetooth proxy the strange UUID i have is still tracking distance, so I’m wondering whether the proxy is doing anything. I enabled the web server and it shows no devices and yet the esp logs say its all working.
Not sure what else I need to do, is this right so far?
Here is a copy of my log if it helps:
Should active be enabled for this default its off?
[13:50:48][C][wifi:600]: WiFi:
[13:50:48][C][wifi:428]: Local MAC: Redacted
[13:50:48][C][wifi:433]: SSID: [redacted]
[13:50:48][C][wifi:436]: IP Address: 192.168.1.102
[13:50:48][C][wifi:440]: BSSID: [redacted]
[13:50:48][C][wifi:441]: Hostname: 'bluetooth'
[13:50:48][C][wifi:443]: Signal strength: -47 dB ▂▄▆█
[13:50:48][C][wifi:447]: Channel: 2
[13:50:48][C][wifi:448]: Subnet: 255.255.255.0
[13:50:48][C][wifi:449]: Gateway: 192.168.1.1
[13:50:48][C][wifi:450]: DNS1: 192.168.1.1
[13:50:48][C][wifi:451]: DNS2: 0.0.0.0
[13:50:48][C][logger:177]: Logger:
[13:50:48][C][logger:178]: Max Level: DEBUG
[13:50:48][C][logger:179]: Initial Level: DEBUG
[13:50:48][C][logger:181]: Log Baud Rate: 115200
[13:50:48][C][logger:182]: Hardware UART: USB_CDC
[13:50:48][C][bluetooth_proxy:091]: Bluetooth Proxy:
[13:50:48][C][bluetooth_proxy:092]: Active: NO
[13:50:48][C][bluetooth_proxy:093]: Connections: 0
[13:50:48][C][bluetooth_proxy:094]: Raw advertisements: YES
[13:50:48][C][esp32_ble:418]: ESP32 BLE:
[13:50:48][C][esp32_ble:420]: MAC address: CC:BA:97:15:3E:FD
[13:50:48][C][esp32_ble:421]: IO Capability: none
[13:50:48][C][esp32_ble_tracker:677]: BLE Tracker:
[13:50:48][C][esp32_ble_tracker:678]: Scan Duration: 300 s
[13:50:48][C][esp32_ble_tracker:679]: Scan Interval: 1100.0 ms
[13:50:48][C][esp32_ble_tracker:680]: Scan Window: 1100.0 ms
[13:50:48][C][esp32_ble_tracker:681]: Scan Type: ACTIVE
[13:50:48][C][esp32_ble_tracker:682]: Continuous Scanning: YES
[13:50:48][C][esp32_ble_tracker:683]: Scanner Idle: NO
[13:50:48][C][esp32_ble_tracker:684]: Scan End: NO
[13:50:48][C][esp32_ble_tracker:686]: Connecting: 0, discovered: 0, searching: 0, disconnecting: 0
[13:50:48][C][captive_portal:089]: Captive Portal:
[13:50:48][C][web_server:153]: Web Server:
[13:50:48][C][web_server:154]: Address: bluetooth.local:80
[13:50:48][C][mdns:116]: mDNS:
[13:50:48][C][mdns:117]: Hostname: bluetooth
[13:50:48][C][esphome.ota:073]: Over-The-Air updates:
[13:50:48][C][esphome.ota:074]: Address: bluetooth.local:3232
[13:50:48][C][esphome.ota:075]: Version: 2
[13:50:48][C][esphome.ota:078]: Password configured
[13:50:48][C][safe_mode:018]: Safe Mode:
[13:50:48][C][safe_mode:020]: Boot considered successful after 60 seconds
[13:50:48][C][safe_mode:021]: Invoke after 10 boot attempts
[13:50:48][C][safe_mode:023]: Remain in safe mode for 300 seconds
[13:50:48][C][api:140]: API Server:
[13:50:48][C][api:141]: Address: bluetooth.local:6053
[13:50:48][C][api:143]: Using noise encryption: YES
Thanks
Sounds like you are making the solution difficult on purpose?
As I understand it you want the garage door to open when your car is close?
In my cars I have an ESP8266-01 in each car. When it connects to my WiFi, the car is nearby.
Your right I’m over complicating things, what kind of response times are you getting? because I initially used wifi router connecting and disconnecting to open/close my door. The problem I have is the wifi signal is super strong(it holds on till death) and I’m almost in the next block before it closes and when I arrive I sit there for a minute or so before it opens. I really can’t afford to leave the door opened for too long as its in a busy traffic area. Ideally I’d like to see the door start to close in my revision mirror as i drive away. With the esp32 I was going to try(never did) to vary the wifi power until it disconnected at the point that i would be happy with. Do you think this will work?
Additionally I have 2 entries one where we go out with car and the other for walkins…I dont want to get to a point where I park at the front of my home and the door opens in the rear.
Thanks for your input.
Contradicts this:
I don’t rely on the ESP connecting to the WiFi to open or close the door, but only to enable other automations to open or close the door. For example, I can open/close the door using an Amazon Echo command: “Alexa, open door number one”. If the Jeep is not present, the automation triggered by Alexa won’t execute the action to open the door.
I have a work in progress that would use a license plate reader to open the door if the Jeep is in the driveway. Again, if the ESP does not connect then the door will not be able to open. This would prevent someone from using a fake license plate to open the door when the Jeep is gone.
The bottom line here is that two things have to be true for the door to open.
So you incorporate voice, its funny my existing wireless takes ages to disconnect and also takes long to connect. Anyway my second condition is only open if its connected to my car bluetooth. The reason im also looking into Nathan suggestion is that i can set distance to proxy so that i dont get caught parking at the front while still connected to bluetooth it may also connect to wifi which will open my door…So your ESP in your car is used for voice control?
No. The ESP in the car is only for presence. The door won’t open if the car is not present.
I have Alexa devices all over the house, including the garage and in the cars (Alexa Auto). I also have Home Assistant widget on my watch, but I haven’t added a button for the garage door.
Sorry for such dumb questions…I’ve looked up esp presence and it requires MQTT. So when you get to your garage door what is your esp in your car waiting to receive before it knows your presence? is it waiting to receive a bluetooth response from your server? I have had a look at the esp components ESPHome Docs — ESPHome and could not see any configurations for esp presence. If you don’t mind could you please point me in the right direction. Eventually I’d like to try all of these suggestions from this thread so that I can learn along the way.
Thanks for taking the time to respond.
Can someone please confirm for me if this is operating correctly? I’ve started from scratch, I’ve realized trying to use GPS or router home and away entities reacts way too slow, even with high accuracy mode on and when only in the zone. I’ve reverted to using a ESP32 setup as a bluetooth proxy as suggested by Nathan.
I have now set this up and installed the ibeacon integration. I have also enabled in my companion app BLE transmitter. On the same page I have recorded my UUID and provided that to the iBeacon integration. I’m using an android phone if that makes a difference. Is there anything else I should be enabling or installing? I’ve noticed that if the state is unknown because of distance and I move within the zone it instantly updates. But once detected a distance within that zone it remains on that distance until I get out of the zone and renter. Is this normal behavior? At first it didn’t display distance, I had to increase transmitting power from ultralow to low. I could make this work except that when it goes out of range it is still displaying a distance for around 10mins…too long to trigger an automation. The actual doco does say it could take a few minutes to activate state change from home to away.
This is my esphome config, for bluetooth proxy
esp32_ble_tracker:
scan_parameters:
active: false
bluetooth_proxy:
active: true
web_server:
port: 80
Thanks in advance.
For those who are interested to know ive moved over to esperence and it makes a huge difference. I have a couple of other issues but i think i can make it work. Thanks to all who provided assistane.
The ESP in the car does nothing but connect to the WiFi. An automation in Home Assistant detects the connection then sets a helper to “Home”. If the ESP device is disconnected for a few minutes the helper is changed to “Away”.
Thanks, mind my ignorance just so I understand why do you create a helper? Doesnt the esp have entities that are created…home when connected and not home when disconnected? Thats my basis of how im testing espresence.
Thanks again
Because the ESP is sleeping most of the time. I don’t need real-time presence so the ESP sleeps for 1 minute, wakes and tries to connect to the WiFi then goes back to sleep. The helper remembers the last status while the ESP sleeps.
What does “1am” have to do with anything? The only people with bedtimes are baby’s and quitters!
I expect to see 72 hours of nonstop production out of you before even mentioning bedtime! If you put in a solid 36 hours, ill let you take a 5min water break as a reward!!
If Google or AI isnt taking nap breaks, neither are you and dont disappoint me again!
Surely you know im joking… maybe.
Have you heard about or ever tried the HA add-on Bermuda? It does all that tracking for you and displays devices distance and which room a device is in.
I personally use Espresence which is different but basically does the same tasks and heres an example of some of my BT beacons and devices.
Thanks for your input…great username btw. Ive tried bermuda…to be honest all i want to achieve is to detect my car when in front of my garage so it will open.
Things ive tried:
Wifi connect / disconnect takes too long to respond.
Geolocation with high accuracy, some success but hit and miss.
Espresence good but takes too long to disconnect even with away timeout set to 5 secs takes anywhere from 30secs to 1min. Im already in the next block and my door is still open
Next thing i will try is an esp like Steve suggested and adjust the Tx power to see if i get better results. I also think half my battle is my garage is colourbond and it acts as a wifi/ bluetooth shield. Im also considering using a motion detector for away mode and a combination of the others on my return. I do have an AP in my garage but my sensors are zigbee and the signal strength is crap in there. Ill keep battling on…at least im learning stuff as i go on.
I think you need another approach.
The further away the signal is received, the better the response will be when you arrive.
But on the other hand, the worse it will be when you leave.
My suggestion is that you use one of these in your car, to open the gate when you arrive.
https://pt.aliexpress.com/item/1005006301631031.html?spm=a2g0o.order_list.order_list_main.176.40d3caa4EmdiQx&gatewayAdapt=glo2bra
I use one of these in my cars, with this configuration:
binary_sensor:
- platform: ble_presence
mac_address: XX:XX:XX
name: "UP! ESP"
timeout: 30s
I don’t use it to open the garage door, but to disable the alarm, so I don’t care so much about the time to disconnect.
And when you leave, you check the status of the gate with some door sensor (possibly you already have one) and the presence of the car with an ultrasonic or ToF sensor.
So if the gate is open and the distance sensor doesn’t detect the car for XX seconds, it will be closed.
Thanks i have bought a couple, hopefully i can get something to work. Do you use the ibeacon integration? I have found this to be really slow in reacting to home to not_home
Once i get them i might come back here to pick your brains if i have issues.
No, just the esphome sensor.
This is my yaml, not everything is necessary, but since I intend to configure Bermuda one day, I have already configured it as a proxy as well.
esphome:
name: btcar
friendly_name: btcar
esp32:
board: esp32dev
framework:
type: esp-idf # This is important: the default "arduino" framework does not perform well.
sdkconfig_options:
# @grigi found in testing that these options resulted in better responsiveness.
# BLE 4.2 is supported by ALL ESP32 boards that have bluetooth, the original and derivatives.
CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y
# Also enable this on any derivative boards (S2, C3 etc) but not the original ESP32.
# CONFIG_BT_BLE_50_FEATURES_SUPPORTED: y
# Extend the watchdog timeout, so the device reboots if the device appears locked up for over 10 seconds.
CONFIG_ESP_TASK_WDT_TIMEOUT_S: "10"
# Enable logging
logger:
level: WARN
baud_rate: 0
# Enable Home Assistant API
api:
encryption:
key: "BkZPcHnuBRf8+dJ3tQlJUTmG+99DiRxDppjjHG+9Chk="
# Only enable BLE tracking when wifi is up and api is connected
# Gives single-core ESP32-C3 devices time to manage wifi and authenticate with api
on_client_connected:
- esp32_ble_tracker.start_scan:
continuous: true
# Disable BLE tracking when there are no api connections live
on_client_disconnected:
if:
condition:
not:
api.connected:
then:
- esp32_ble_tracker.stop_scan:
ota:
- platform: esphome
password: "xxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
# ap:
# ssid: "Btcar Fallback Hotspot"
# password: "xxx"
# captive_portal:
bluetooth_proxy:
active: true # allows outbound connections from HA to devices.
esp32_ble_tracker:
scan_parameters:
# Don't auto start BLE scanning, we control it in the `api` block's automation.
continuous: False
active: True # send scan-request packets to gather more info, like device name for some devices.
interval: 320ms # default 320ms - how long to spend on each advert channel
window: 320ms # default 30ms - how long to actually "listen" in each interval. Reduce this if device is unstable.
# If the device cannot keep up or becomes unstable, reduce the "window" setting. This may be
# required if your device is controlling other sensors or doing PWM for lights etc.
on_ble_service_data_advertise:
- mac_address: xx:xx:xx:xx:xx
service_uuid: "5242"
then:
- lambda: 'id(up_bat).publish_state(x[1]);'
- mac_address: xx:xx:xx:xx:xx
service_uuid: "5242"
then:
- lambda: 'id(punto_bat).publish_state(x[1]);'
sensor:
- platform: template
name: "UP! Battery"
id: up_bat
device_class: "battery"
unit_of_measurement: "%"
entity_category: "diagnostic"
accuracy_decimals: 0
- platform: template
name: "Punto Battery"
id: punto_bat
device_class: "battery"
unit_of_measurement: "%"
entity_category: "diagnostic"
accuracy_decimals: 0
binary_sensor:
- platform: ble_presence
mac_address: xx:xx:xx:xx:xx
name: "UP! ESP"
timeout: 30s
- platform: ble_presence
mac_address: xx:xx:xx:xx:xx
name: "Punto ESP"
timeout: 30s
You can try reducing the timeout.
One thing that crossed my mind was using the min_rssi option.
You can create 2 sensors, 1 with the default options for arrival
and another with a higher min_rssi when you leave.
This way the beacon will need to be very close to stay connected
binary_sensor:
- platform: ble_presence
mac_address: xx:xx:xx:xx:xx
name: "UP! ESP arrival"
timeout: 30s
- platform: ble_presence
mac_address: xx:xx:xx:xx:xx
name: "UP! ESP leave"
timeout: 5s
min_rssi: -30dB
Thanks so much cant wait to test it. Your binary sensors are they created in HAS or did you add them to esphome? I know dumb questions but I’m working through things.