Using a BLE iTag without ESP32?

Hi everyone! In my home, I use the TP-Link Integration for detecting presence and to control the alarm system. But as this requires everyone to arrive home with their phones charged, I wanted to have a backup plan. The remote control keychain for my alarm system is too big and I wanted something smaller, so I was interested on these iTag BLE buttons, which are quite small and really cheap. The idea would be to have this device on my keychain and if I arrive home I can press the button so Home Assistant detects my presence.

As I saw this website explaining how to connect them to Home Assistant, I bought some of these buttons and when I got them I realised that this method requires an ESP32 device (it might seem obvious now, but I didn’t look for a guide before buying, silly of me).

I also found this guide but I don’t know how to install that, and I saw that it was updated 4 years ago, so I’m open to suggestions on how to implement this device on my Home Assistant. I could get an ESP32 if necessary and try to configure it, but I’d like to know if maybe there is an easier way of making this work directly with the bluetooth that’s already in place.

Thanks!
Rodrigo

Hey Rodrigo. Found your post while looking for more info on these iTag devices. Just get yourself an M5Stack Atom Lite - they are like $7 and work great with these iTag buttons. I have one set up with the example code here, works like a charm. You may want to pop off the speaker on the button though because it is annoyingly loud.

1 Like

Thanks @greenleaf for your reply!
I bought an ESP32 for other reasons and then I tested it with the iTag and it works but I couldn’t manage to make it work OK.

This code kind of worked for me, but has some flaws. It detects when the device turns on, but sometimes doesn’t detect when it turns off even after a couple of minutes. It could theoretically work for the purpose I first intended, but I need something that has less flaws:

binary_sensor:
  - platform: ble_presence
    mac_address: FF:FF:10:xx:xx:xx
    name: "iTAG Tracker 1"

When I use the example code from the page you sent me (which would supposedly read button presses and RSSI), the device never shows up in Home Assistant.

I decided to set a different method as my “backup plan” for when my phone’s battery is low, which doesn’t involve a separate device. Anyway I’m interested on giving this tracker some use, since now my ESP32 is up and running (I use it as a bluetooth proxy for getting sensors data to HA), I just need to get the right code. Could you share an example of your code?
If it’s the same code as the example (only changing the MAC address), I know I already tested and it didn’t work. In your case, does it appear in Home Assistant under the BTHome integration?

Thanks,
R.

Yep, here you go. You can find the MAC address of your button with any BLE scanner app, the Adafruit Bluefruit LE Connect works nicely for this. This is the code I’m using in ESPHome. You’ll still have to add the device and configure it in Home Assistant once this is rigged up:

esp32_ble_tracker:
  
ble_client:
  # Replace with the MAC address of your device.
  - mac_address: FF:FF:10:22:1E:DE
    id: itag_white

sensor:
  - platform: ble_client
    type: characteristic
    ble_client_id: itag_white
    name: "White iTag Button"
    service_uuid: 'ffe0'
    characteristic_uuid: 'ffe1'
    notify: true
    update_interval: never
    on_notify:
      then:
        - binary_sensor.template.publish:
            id: white_button
            state: ON
        - binary_sensor.template.publish:
            id: white_button
            state: OFF
  - platform: ble_client
    type: characteristic
    ble_client_id: itag_white
    name: "White iTag Battery"
    service_uuid: '180f'
    characteristic_uuid: '2a19'
    icon: 'mdi:battery'
    unit_of_measurement: '%'

binary_sensor:
  - platform: gpio
    pin:
      number: 39
      inverted: true
    name: ${friendly_name} Button
    on_press:
      then:
        - light.toggle: status_led
    filters:
      - delayed_on: 10ms
      - delayed_off: 10ms
  - platform: template
    id: white_button
    name: "White iTag Button"
    filters:
      delayed_off: 200ms

Thanks! Could you explain more about how to add it in Home Assistant?
I think I’m almost there, I see the entities in HA but they all show up as Unavailable.

Maybe my tracker is defective… I’ve been trying to follow a couple of examples with just a bit of success followed by failures…

R.

EDIT:
Paying more attention to the code, I noticed you’re not creating the template described in the BLE iTag Button page.
As I understand, you’re directly controlling a gpio pin from the bluetooth button, is it right?

Yes, so there are two steps required:

  1. Get your device working with esphome. This should be solved first before you even get to Home Assistant. Highly recommend turning on the web interface on your esp32 so you can connect in a browser, see logs, etc. Once you have the button rigged up and responding you can move on to step 2.
  2. Add the device in Home Assistant. If you have the esphome integration it should be auto-discovered but if not you can connect to the IP address. Copy the API key from your esphome config into Home Assistant setup and it will then become a device with entities in HA.
  3. Program your button to do whatever you need with an Automation.
1 Like