Set location of phone in my house based on binary BLE switch

Hi all, newbie here.

I'm trying to get home assistant to track where our phones are in the house. I have used this guide:
(Comprehensive Room Presence Detection: Linking it all up! - Gergo) with ESPresense installed on a bunch of ESP32's. These have proven to be completely unreliable at reading what phone is where.

I have reflashed a couple of the ESP's to the stock ESPHome, and setup an iBeacon binary sensor for my phone. When the phone is in the room its set to 'on', and when I leave its set to off. I've done this for 3 rooms, so have 3 binary sensors

Is there a way of making a sensor/template that will change its output to the name of the room my phone is in, rather than a bunch of separate switches? Basically if I walk into the living room, it becomes living room, then when it senses a change of room it changes to that room, and if the phone is away and not connected to house wifi, then set as not home.

Hope I've made myself clear?

thanks in advance!

I've never bothered with something like this as it seems too much like hard work and the beacons tend to be not that cheap so it seemed like there wouldn't be any realistic payback.

However, it is interesting. I would think that you should be able to do it as long as you can capture both the id of the location sensor and the id of the triggering beacon (the phone).