Help on a condition in an automation regarding bluetooth sensor from companion app

I’m trying to automate a gate opening depending on my entering a zone and my phone connected to specific bluetooth devices.
I use the guided automation builder. I chose:

  • the companion app bletooth sensor
  • the attribute: connected_paired_devices
  • I copied the string from the state defining the BT device I want to select
    HA always consider that condition false. Probably I wrote the statement in the wrong way.
    Can you help me?
    Below a picture from the trace of the automation.

Thanks
Al

image
image

connected_paired_devices is a list of bluetooth connections (even if you are only connected to one device), so you can’t just compare it to a specific bluetooth ID, you have to check to see if that bluetooth ID is in the list. Use a template condition instead, and your template would look something like:

{{ "FC:49:2D:04:22:97" in state_attr("sensor.alberto_edge_30_bluetooth_connection", "connected_paired_devices") }}

When using templates in automations, it’s a good idea to test them in the Developers Tools page to make sure they come back as true/false when you expect them to.

Thanks for your answer.- It works

Thanks

Al

Hey all, trying to follow this solution and I have a failure on the condition where it checks the connected_paird_devices. Can someone help me figure out what the problem might be?

This is not working for me… Tests false when it should be true. Is there something different with this the past 6 months?

{{ "B0:4A:6A:F8:CE:56" in state_attr("sensor.sas22_bluetooth_connection",
  "connected_paired_devices") }}