ESPresense and HA Automation Setup

I recently setup a few ESP32 devices with ESPresense in various rooms in my home. I have them all working and recognizing when my iPhone is in each room. I’m now ready to setup my first automation using presence detection, but am having difficulty understanding how to do that.

I would like the smart plug for my CPAP machine to turn on when I enter the bedroom anytime after 10pm. I setup the automation shown below, which runs correctly using Run Action. But when I test the automation, my phone’s presence is detected in the Bedroom, but the smart switch does not come on. I can control the switch from my dashboard, so all devices are functioning. Is there something wrong with my automation setup? TIA

Are you using the right sensor to start off the automation? Is “Bill’s IPhone 13Plus” the name of the MQTT sensor you created for Espresense? Is it showing the state as Bedroom? or does it show Home/Away?

Maybe I’m wrong but, that looks like a regular proximity sensor that HA sets up when you add a phone to HA. You need to use your newly created mqtt_room sensor like this one. Notice it shows my room location and not just Home?

Screenshot from 2025-01-06 23-21-39

Like, this is a standard one that’s added with a phone. Notice the state is only a broad “Home” location instead of which room inside of Home?

Thanks for the reply. Yes, my iPhone is setup as a sensor and is being tracked by the various ESP32s in the house. Here’s a shot of the device tracking history. I think my problem may be in the logic of the automation. I also have a Zepp/Amazfit watch setup as a sensor, so I’m going to add that to the logic and see if that helps.