Bluetooth attributes in an automation

For the life of me I cannot figure out how to accomplish a specific automation task. I want to use the attributes of the “Bluetooth Connection” that is reported from my mobile phone to HA. In the attributes it lists the paired and connected devices. What I’m trying to accomplish is that when I enter a geofenced zone and a specific BT device is connected to open the garage door. To add a bit of context, if I go for a walk and enter the zone, I don’t want the garage door to open. I also have two garage doors so if a different BT device is connected it could open the other door. I cannot see how to use the attribute in an automation. The garage door is MyQ enabled and I have that integration in HA already. So I just need to combine the geofence, BT connected device attribute and MyQ all together. The attributes for connected BT devices is where I’m stuck.

I’m running 2022.12.4

An example I have tried is to use my smart watch as the device since I can more easily test if it meets the conditions before going to actual BT device which will be a vehicle.

condition: state entity_id: sensor.sm_s908b_bluetooth_connection attribute: connected_paired_devices state: B0:4A:6A:A9:1C:A1 (Galaxy Watch5 Pro (NNWN))

This is what the YAML looks like:

condition: state
entity_id: sensor.sm_s908b_bluetooth_connection
attribute: connected_paired_devices
state: B0:4A:6A:A9:1C:A1 (Galaxy Watch5 Pro (NNWN))

If it use it exactly as displayed as an attribute in HA, it doesn’t pass the condition when I go into the automation and have it check it. I have tried it exactly as displayed in HA, with " " around it as well as ’ ’ and it still doesn’t work. Any ideas? Or is there a bug in Home Assistant preventing this from working?

That attribute returns a list not a string so you need to set your condition up to work with that.

Keep in mind that conditions are evaluated as soon as the trigger fires, they do not wait. If there is a lag between your location updating and the BT connection being established you may need to use a wait action in you automation.

1 Like

Interesting. Thank you for the explanation. In the visual editor it is treating it as a string. I wonder if that is the intended operation that Home Assistant is trying to do.

I don’t think a wait will be needed since the BT connection should be established long before I enter the geofenced area. But still nice to know that a wait might be required.