Create an automation which helps find your keys, wallet or else with Home Assistant.
Introduction
A man leaves the house with three things. Those would be wallet, keys and a phone. The catch is, that we are always searching for one of those three things around the house.
Previously I tackled the issue of finding the phone, you can find that tutorial here. Now it is time to find the keys and wallet.
The idea is to trigger a loud sound on the key chain after pressing a button on the Home Assistant dashboard. This will hopefully be enough for me to locate them.
Please note that this implementation is not suited for large homes, but rather for smaller apartments like mine, since the range is limited to around 10 meters.
Required Hardware
To build this we will need:
Home Assistant instance – Since you are reading this, you probably already have it set up.
ESP32 board – Any ESPHome compatible variant of the board will work.
Bluetooth beeper tags – These are mostly generic, with a single clickable button.
The heart of the project are these cheap Bluetooth beeping tags you can find on AliExpress or Temu.
They mostly have a replaceable battery, feature BLE(Bluetooth Low Energy) and have a single clickable button on them. This makes them perfect for the job. They come in a few flavors, and I have ordered three types to test each for robustness, beeping volume and battery life. Personally I found the tag pictured in the middle of the photo to be the best.
They are intended to connect to your phone via Bluetooth through an app called ISearchingApp. This then allows you to trigger a beeping sound from te app itself.
Sadly I could not find a Home Assistant integration available for them so I had to improvise with an ESP32 board running ESPHome.
Implementation
To make the tag a valid component in Home Assistant, we need to:
Connect the tags to Home Assistant.
Make the tags start and stop beeping on demand from Home Assistant.
Find a way to make the Single click on the tag button register in Home Assistant.
Find a way to make the Double click on the tag button register in Home Assistant.
Once the this is done we will make a few automatons to:
Trigger a beeping sound ON from a Home Assistant Dashboard.
Once the beeping sound is active, and we have found the key, we need a convenient way to turn the beeping OFF without going all the way to the Dashboard or taking my phone out. For this I will be using the Single click of the tag button. By clicking the tag once the beeping will stop.
BONUS Feature - Make the Double click of the tag button trigger the Find My Phone automation so that, when I have my keys I can easily find my Phone.
ESPHome setup
I am not going to go into detail on how you can setup the ESP32 board to work with Home Assistant. There are plenty of tutorials for that. Instead I am going to share the YAML code needed to make the tags usable with Home Assistant.
First I started out by trying to reverse engineer the communication between the ISearching App and the Bluetooth tags. As luck would have it someone already managed to do this.
# BLE Clientsble_client:- mac_address:00:00:00:00:00:00#Put your tag MAC address here in uppercase.id:vlade_house_key_tagon_connect:then:- delay:2s- ble_client.ble_write:id:vlade_house_key_tagservice_uuid:FFE0characteristic_uuid:FFE2value:[0x00]- mac_address:00:00:00:00:00:00#Put your second tag MAC address here in uppercase.id:vlade_car_key_tagon_connect:then:- delay:2s- ble_client.ble_write:id:vlade_car_key_tagservice_uuid:FFE0characteristic_uuid:FFE2value:[0x00]- mac_address:00:00:00:00:00:00#Put your third tag MAC address here in uppercase.id:vlade_wallet_tagon_connect:then:- delay:2s- ble_client.ble_write:id:vlade_wallet_tagservice_uuid:FFE0characteristic_uuid:FFE2value:[0x00]sensor:- platform:ble_clienttype:characteristicble_client_id:vlade_house_key_tagid:vlade_house_key_tag_ble_btnservice_uuid:'FFE0'characteristic_uuid:'FFE1'icon:"mdi:button"notify:trueupdate_interval:neveron_notify:then:- binary_sensor.template.publish:id:vlade_house_key_tag_btnstate:ON- delay:20ms- binary_sensor.template.publish:id:vlade_house_key_tag_btnstate:OFF- platform:ble_clienttype:characteristicble_client_id:vlade_car_key_tagid:vlade_car_key_tag_ble_btnservice_uuid:'FFE0'characteristic_uuid:'FFE1'icon:"mdi:button"notify:trueupdate_interval:neveron_notify:then:- binary_sensor.template.publish:id:vlade_car_key_tag_btnstate:ON- delay:20ms- binary_sensor.template.publish:id:vlade_car_key_tag_btnstate:OFF- platform:ble_clienttype:characteristicble_client_id:vlade_wallet_tagid:vlade_wallet_tag_ble_btnservice_uuid:'FFE0'characteristic_uuid:'FFE1'icon:"mdi:button"notify:trueupdate_interval:neveron_notify:then:- binary_sensor.template.publish:id:vlade_wallet_tag_btnstate:ON- delay:20ms- binary_sensor.template.publish:id:vlade_wallet_tag_btnstate:OFFbinary_sensor:- platform:templateid:vlade_house_key_tag_btnon_multi_click:- timing:- ONfor at most 0.3s- OFFfor at least 0.8sthen:- homeassistant.event:event:esphome.tag_clickdata:click_type:'single'tag:'switch.find_my_keys_esphome_vlade_house_keys_beeper'- timing:- ONfor at most 0.3s- OFFfor at most 0.8s- ONfor at most 0.3s- OFFfor at least 0.8sthen:- homeassistant.event:event:esphome.tag_clickdata:click_type:'double'tag:'switch.find_my_keys_esphome_vlade_house_keys_beeper'- platform:templateid:vlade_car_key_tag_btnon_multi_click:- timing:- ONfor at most 0.3s- OFFfor at least 0.8sthen:- homeassistant.event:event:esphome.tag_clickdata:click_type:'single'tag:'switch.find_my_keys_esphome_vlade_car_keys_beeper'- timing:- ONfor at most 0.3s- OFFfor at most 0.8s- ONfor at most 0.3s- OFFfor at least 0.8sthen:- homeassistant.event:event:esphome.tag_clickdata:click_type:'double'tag:'switch.find_my_keys_esphome_vlade_car_keys_beeper'- platform:templateid:vlade_wallet_tag_btnon_multi_click:- timing:- ONfor at most 0.3s- OFFfor at least 0.8sthen:- homeassistant.event:event:esphome.tag_clickdata:click_type:'single'tag:'switch.find_my_keys_esphome_vlade_wallet_beeper'- timing:- ONfor at most 0.3s- OFFfor at most 0.8s- ONfor at most 0.3s- OFFfor at least 0.8sthen:- homeassistant.event:event:esphome.tag_clickdata:click_type:'double'tag:'switch.find_my_keys_esphome_vlade_wallet_beeper'switch:- platform:templatename:"Vlade House Keys Beeper"id:vlade_house_key_tag_beepericon:"mdi:key-chain-variant"optimistic:trueturn_on_action:- ble_client.ble_write:id:vlade_house_key_tagservice_uuid:'1802'characteristic_uuid:'2A06'value:[0x01]turn_off_action:- ble_client.ble_write:id:vlade_house_key_tagservice_uuid:'1802'characteristic_uuid:'2A06'value:[0x00]- platform:templatename:"Vlade Car Keys Beeper"id:vlade_car_key_tag_beepericon:"mdi:car-key"optimistic:trueturn_on_action:- ble_client.ble_write:id:vlade_car_key_tagservice_uuid:'1802'characteristic_uuid:'2A06'value:[0x01]turn_off_action:- ble_client.ble_write:id:vlade_car_key_tagservice_uuid:'1802'characteristic_uuid:'2A06'value:[0x00]- platform:templatename:"Vlade Wallet Beeper"id:vlade_wallet_beepericon:"mdi:wallet"optimistic:trueturn_on_action:- ble_client.ble_write:id:vlade_wallet_tagservice_uuid:'1802'characteristic_uuid:'2A06'value:[0x01]turn_off_action:- ble_client.ble_write:id:vlade_wallet_tagservice_uuid:'1802'characteristic_uuid:'2A06'value:[0x00]
Connect the tags to Home Assistant
This is the code responsible for connecting the ESP32 to the Bluetooth tag. Replace the zeros with the MAC address of your own tag.
1
2
3
4
5
6
7
8
9
10
- mac_address:00:00:00:00:00:00#Put your tag MAC address here in uppercase.id:vlade_house_key_tagon_connect:then:- delay:2s- ble_client.ble_write:id:vlade_house_key_tagservice_uuid:FFE0characteristic_uuid:FFE2value:[0x00]
You can see that this section is duplicated to connect to all the three tags (house keys, car keys, wallet), so if you have more or less tags, just be sure to have one section for each of them.
The on_connect section with the delay is there as a quality of life improvement. These tags have a feature which makes them beep once the tag is disconnected from your phone due to it being out of range. I do not want this, so by sending the bluetooth write command, I am disabling this feature. I suggest that you also copy this section completely.
Create Home Assistant controls for the tags.
Next lets configure the toggle for turning the beeping ON and OFF, to do that I will be using a toggle switch.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
switch:- platform:templatename:"Vlade House Keys Beeper"id:vlade_house_key_tag_beepericon:"mdi:key-chain-variant"optimistic:trueturn_on_action:- ble_client.ble_write:id:vlade_house_key_tagservice_uuid:'1802'characteristic_uuid:'2A06'value:[0x01]turn_off_action:- ble_client.ble_write:id:vlade_house_key_tagservice_uuid:'1802'characteristic_uuid:'2A06'value:[0x00]
Note the turn_on and turn_off actions. We are sending Bluetooth commands to turn the beeping ON and OFF.
With this in place, and the code uploaded to your ESP32, the toggles should be visible in Home Assistant.
You can now try out manually toggling the beeping ON and OFF. With any luck you should hear them beeping.
binary_sensor:- platform:templateid:vlade_house_key_tag_btnon_multi_click:- timing:- ONfor at most 0.3s- OFFfor at least 0.8sthen:- homeassistant.event:event:esphome.tag_clickdata:click_type:'single'tag:'switch.find_my_keys_esphome_vlade_house_keys_beeper'#When a click is detected I dispatch a home assistant event.- timing:- ONfor at most 0.3s- OFFfor at most 0.8s- ONfor at most 0.3s- OFFfor at least 0.8sthen:- homeassistant.event:event:esphome.tag_clickdata:click_type:'double'tag:'switch.find_my_keys_esphome_vlade_house_keys_beeper'
Registering the Single and Double clicks required some code gymnastics. The bottom line is this code allows you to receive the clicks as Home Assistant events.
I opted to use a single event which I named esphome.tag_click for all of my tags. Then in the data object I provide the click type (single, double) and the ID of the clicked tag beeper. You do not have to do the same, but I found it useful since all the tags have a shared behavior.
And with that we have successfully integrated the tags with Home Assistant.
In the documentation for ESP32 it is said that it can handle 9 simultaneous bluetooth connections. So the three tags I have connected should not be an issue.
Setting up the UI and the rest of the automations
Add the new toggles to a convenient dashboard. Mine are right next to the button used to find the phone.
Single click turn OFF beeping automation
The first automation will be to make the single click to the tag button disable beeping.
To do this we will need to create an automation which is triggered by the single click, identifies the correct tag, and sends a command for it to stop beeping.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
alias:Turn Off Tag Beeperdescription:Turn the tag beeping off when the tag button is pressed oncetriggers:- event_type:esphome.tag_clickevent_data:click_type:singletrigger:eventconditions:[]actions:- data:entity_id:"{{ trigger.event.data.tag }}"action:homeassistant.turn_offmode:parallel
You can now see the reason why I included the ID of the tag in the click event data.
1
entity_id:"{{ trigger.event.data.tag }}"
This way I can easily figure out which tag is the target to turn the beeping off.
We need to make the automation listen to the esphome.tag_click event. When the event_data of the event contains the click_type = double, the automation will be triggered.
alias:Find my Phonedescription:Automation used to find my phone.triggers:- entity_id:- input_button.find_my_phonetrigger:state- trigger:event#New event trigger.event_type:esphome.tag_clickevent_data:click_type:doubleconditions:[]actions:- data:message:"{{ notification_message }}"title:"{{ notification_title }}"data:ttl:0priority:highimportance:highchannel:"{{ notification_channel }}"action:"{{ target_device }}"variables:target_device:notify.mobile_app_vlade_poconotification_channel:find_my_phonenotification_title:Find my Phonenotification_message:Hey phone, someone is looking for you!mode:single
Conclusion
I have been testing this for about a month so far. The only thing which I have found troublesome is that sometimes I turn the tags OFF completely by mistake. This sometimes happens when I sit on the keys. But other than that it works fine.
Potential improvements will include adding a battery state monitor for each of the tags, so that I can check if the battery is running out.
Thank you for reading this far, I hope it helps you!