Linptech RS1BB rain sensor - need ESP32 BLE Sensor

Hi I have a Xiaomi lywsd03mmc ble temperature sensor which connects to my esp32 fine and I can get the temperature etc fine (without the need for HA - just using esp32_ble_tracker)

Now I would like to do the same for my Linptech RS1BB rain sensor which uses the same encrypted protocol as other Xiaomi products and shows up fine in the MI Home app.

Unfortunately it’s not listed as supported in Xiaomi Mijia BLE Sensors — ESPHome. and as a novice I have no idea how to create a custom sensor :frowning:

By searching around I found this on Github (feat: add support for Linptech RS1BB(MI) by kvakulo · Pull Request #77 · Bluetooth-Devices/xiaomi-ble · GitHub) but I think it relates to Home Assistant ?

Any help gratefully received.

I can get the advertising packet from the rain sensor using on_ble_advertise and I can decrypt it using the python code I found here (Reverse engineering the MiBeacon protocol | Passive BLE Monitor integration) if I use this website (Python Online Compiler & Interpreter).

How can I get this python code to execute on the ESP32 every time it sees one of these packets ?
thanks.

If anyone is interested - I got this working using