Is my garage open?

We have a garage door with bluetooth. In the official app it displays (as percentage) how open or closed the door is right now and it updates in realtime. Once I realized this works with just bluetooth, I figured it must be possible to get this value outside from the Hörmann app.

A "bit" later, I came up with the following script, which runs on a Shelly Plus Uni and publishes the current value to my MQTT-broker.

function bleCallback(ev, res) {
    if (ev === BLE.Scanner.SCAN_RESULT && res.addr === "aa:bb:cc:dd:ee:ff") {
        let sixthByte = res.scanRsp.charCodeAt(5);
        let openPercent = Math.round(sixthByte / 2);
        console.log("percentage: ", openPercent);
        MQTT.publish("shelly/hoermann/garagentor/offen", JSON.stringify(openPercent), 0, false);
    }
}

if (!BLE.Scanner.isRunning()) {
  BLE.Scanner.Start({
    duration_ms: -1,
    active: true,
    interval_ms: 100,
    window_ms: 30,
  });
}

BLE.Scanner.Subscribe(bleCallback);

Just use the correct mac-address and mqtt-topic.