Button pressed events for ShellyBLU Button1?

would be good if some stuff would actually get pushed to the device log too :smiley:

Will look into that.

1 Like

I also interested in the iBeacon functionality but what do you mean with Shelly BLE debug app?

1 Like

Looks like that there is no debug app for iOS

Ah sorry could be, you’ll have to ask devs :smiley: i kinda avoid iOS :slight_smile:

You could run an Android Vm on a laptop and see if you can push bluetooth

I think i will wait until it is possible to update via Shelly App or maybe via Home Assistant and then hopefully iBeacon can be activated via HA :slight_smile:

You can use one of my beacons for something like this. Firstly, buy one of my beacons that has a button, such as the BC021 or the BC011 (the BC08 button is a little awkward to press).

Then configure the beacon with a “button trigger” and set it to broadcast for x seconds after the button is pressed. In other words, make it do nothing normally, but broadcast for 10 seconds after the button press.

Note that the UUID being broadcast will be slightly modified from the regular UUID of the beacon, depending on which type of button press you choose (single, double, or triple). Check out the Quick Start Guide for the BC021 beacon on our website for a more detailed explanation how to set this up.

OK, once you have the beacon set up, next do the HA set up using the iBeacon Tracker integration as I explained in this link: Anyone else experience issues with iBeacons? - #5 by BlueCharmBeacons

The only thing to keep in mind is that this integration doesn’t react super quickly to your beacon being in range (in your case, your beacon suddenly beginning to broadcast after you press the button). It takes at least a few seconds and somethings longer to trigger the “in range” automation that you set up. The out of range automation (in your case, the beacon stops broadcasting x seconds after you initially pressed the button i.e. you don’t need to press it again to make it stop) is even slower. It takes a couple of minutes at least. Depending on your selected automations, those delays may or may not be significant.

Alternatively, you could set up a different button click for the opposite automation, e.g. double click to turn on the lights, then triple click to turn them off. Something like that. Edit: After further thought, I am not sure you can use one beacon (with one single MAC) and two different UUIDs (one UUID from double click and another UUID from triple click) with the iBeacon Tracker integration. I need to test this out to confirm.

Come to think of it, you might just be able to use your Shelly button and my link to make your Shelly do what you need. Give it a try.

1 Like

Just curious, but were you able to get these working for iBeacon purposes?

Using the Shelly debug app I was able to enable the beacon and it seems like it’s now sending out some kind of update periodically since the signal strength entity now updates without me having to press the button, but I can’t find it as a device or entity in the iBeacon Tracker integration.

Also it seems like via the Shelly debug app you can remotely locate it. I wonder if that’s also possible via HA. This device is supposed to comply with BTHome after all so I would think it would be fully integrated.

1 Like

Also +1. Can’t find the Shelly Blu Button 1 in the Ibeacon Integration in Homeassistant. Would be interessting if this is not supported or integrated with the Ibeacon

I was able to setup Shelly BLU Button1 with BTHome using an ESP32 as a HA Bluetooth proxy, then enabling the Beacon mode using the Shelly BLE Debug app after upgrading its firmware.

I also added its mac address to the known_devices.yaml. Note that I added the BLE_ prefix to it first.

shelly_ble:
  name: Shelly BLU Tracker
  mac: BLE_BC:02:6E:C4:37:C6
  consider_home: 120

This made it as a great presence detection (I’m still checking its battery consumption, but so far, so good)

One issue I had though was with the ESP32 proxy: I used the default parameters for the ble_tracker and it didn’t update often enough (so the device was considered Away most of the time). The fix was to change the interval and window parameters on the ESP32 config to:

esp32_ble_tracker:
  scan_parameters:
    interval: 1100ms
    window: 1100ms
    active: true

To close up, I would love to find a way to make it beep from HA. I usually misplace my keys at home so to ask HA to find them would be godsend.
The way the debug app does it is: it waits for the BLE pulse, pairs to the device, sends a “locate me” signal and that triggers the beeping.

One comment: When you set the interval and window to the exact same number, the ESP scans continuously, and I mean CONTINUOUSLY. This sometimes makes it behave a bit wonky sometimes because it has no remaining computing power to do anything else (such as send a signal to your HA). Yours seems to be working fine but just in case, I would suggest you leave a little bit of a gap between the two numbers, e.g. interval 1100ms and window 1000ms. That leaves a gap of 100ms when the ESP is not scanning BLE, so it can use this period to do its own housekeeping stuff more effectively.

“Active: true”: You don’t ned to set this “true” since a BLE beacon scan is always passive. An active scan is something like a scan request from the ESP to the beacon, then the beacon responds with some non-standard broadcast info such as the battery power or whatever else it is able to communicate (according to the beacon’s firmware).

Beep: For my beacons that can beep (only the BC021), the beep is accomplished by

  1. connecting to the beacon
  2. authorizing with the correct password
  3. then sending a JSON message to the beacon in a specific format to make the beep happen (also telling it for how long to beep, etc. parameters)
    -The very tricky part is sending the password, which must be done using an MD5 algorithm to perform connection authentication via MTU. It’s complicated stuff.

I am also interested to use the BLU Button as an iBeacon but i do not fully understand your steps how to set it up.

Can i ask you to write a litte more detailed what those steps are mean? What do you mean with using an ESP32?

Some time ago i have already activated Beacon Mode via the Shelly BLE Debug App but i did not understand how to identify the Blue Button via the iBeacon Integration.

Why have you added the MAC to known_devices.yaml and where is this file stored.

Sorry for all that questions but it looks like that a bit more background knowledge is required to be able to get the Shelly BLU running as iBeacon in HA.

You can’t use the iBeacon integration with the Shelly BLU Button1, instead, it will be added to the BTHome integration when discovered (this is okay, we want that because we’ll be also using the button events)

So, in my case, first thing I did was to was setup the Bluetooth integration on HA. However, I didn’t connect a Bluetooth dongle to my HA machine but used the Bluetooth Proxy integration on ESPhome here
Basically, I use the built-in bluetooth antenna on ESP32 (flashed with ESPhome) to capture all bluetooth traffic and send it over WiFI to my HA instance. By using the configuration esp32_ble_tracker: that I posted before, I’m able to capture EVERY SINGLE Bluetooth Low Energy pulse on my home and sent it to process on HA.

WIth that, HA recognized a lot of my BLE devices, including the Shelly BLU Button, which was added to BTHome integration. However, with this alone it is not usable as a presence detection yet (as a contrast, iBeacon integration does this presence detection automatically when any device is added to its integration).

Next step is to use the Shelly BLE pulse as presence detection. To do that, first I enabled Beacon Mode on the Shelly. Then, I used Device Tracker on HA, adding this to configuration.yaml:

device_tracker:
    - platform: bluetooth_le_tracker
      track_new_devices: false

This integration will create a known_devices.yaml file on the same folder as your configuration.yaml. Here, you’ll need to find your Shelly MAC Address (you can use the Shelly Debug app for that) and add it as a new device like I did on my previous post (note that I added the BLE_ prefix on the mac: value). I increased the the consider_home: value to 240 just to make it more consistent overall but you can choose what you want here.

After all this and a good reboot, you’ll find a new device_tracker entity. It will iterate between home and not_home state. Everytime the ESP32 captures a pulse of the Shelly and sends it to HA, this will set the entity back to home and start again the countdown in seconds set in the consider_home: . If no other pulse of the same MAC is sent to HA during this period, the device will be set to not_home.

And that’s it. Now add this device_tracker to your Person entity and you have a presence detection. Note that, on my case at least, my ESP was not able to capture every single Shelly pulse (it happens between every 10-15 secs) and sometimes a whole 2 minutes happened before I captured another pulse, so set your consider_home: having this issue in mind.

Hope that helps.

I actually had a problem with setting Active: false. The presence detection stopped working so I turned back to true.

1 Like

It must not be broadcasting a standard beacon signal then. Instead, it sounds like a proprietary broadcast of some sort that is requiring a scan request from the ESP and then sends a scan response with some data and identifier. Probably the same reason it doesn’t work with the iBeacon integration. Interesting stuff!

I see the Shelly now as Device Tracker Entity. Thank you for you detailed How-To.
What is not clear for me now, how the Device is actively detected as at home?
I mean when i press the button i can fire the event and the device is detected as at home.
How can that be automated?
How do you use the tracker functionality?

You need to activate Beacon Mode using the Shelly Debug App. That will make the Shelly Button broadcast a pulse each number of seconds.
If you don’t activate Beacon Mode, the only pulse the Button will broadcast (and update the Device Track Entity) is when you click the button.

So, for the Device Tracker BLE to be considered at home, a BLE pulse needs to had been captured by HA corresponding to the MAC address you added on the yaml. This will set the Device Tracker to home. If no other pulse of this MAC address is detected after x seconds (set on the consider_home), the Device Tracker will switch to not_home. To be restored to home, a new pulse need to be captured by HA.

Sorry, my fault, some weeks ago i’ve update the BLU Button and thought i had activated the Beacon function but i did not check it again. Now i have activated the Beacon function.

But i read some time ago in the forum here that the known_devices.yaml is depracted? Does it lead to problems now to continue using known_devices.yaml?

Is there an alternative option to get devices like the BLU Button as Tracker device?

So, I come with some bad news: After 2 weeks my BLE Button1 went from 100% to 0% battery while using Beacon Mode only (no button presses at all, no sound enable either). I wonder if this is normal for the device or my device is malfunctioning.

To compare, my BlueCharm is 1 year without battery change and still going strong.

It might be related to my earlier comment about active scanning. Technically, beacons do not need to be active scanned (which is a strange way of saying “the scanner sends a scan request, then receives a scan response from the beacon”). But you said it did NOT work without active scanning turned on. So maybe the HA is too frequently requesting info from the beacon button, which is wearing out the battery too fast.

What kind of battery is inside the beacon button? 2 weeks seems really short even if the HA is requesting info every 100ms.

So maybe look into how to slow down the communication between the HA and the beacon button. Turning off active scan won’t work (as you said before), but maybe there is a way to change the interval/window for how often the HA requests info from the beacon button.