Automation | Phone Bluetooth Trigger on Connecting to a second Device - how to create a contains not equals trigger value?

Hi,

Reasonably new to this so sorry for the simple question. So far I have mainly used the UI to create my automations.
I’m trying to setup a trigger for when my phones Bluetooth connects to the car.

This was simple for setting up if my phone connects to one device but I have a smart watch so I’m always often connected to that too. Outside of setting up multiple triggers for the every possible group of connections. How do I set up a trigger to fire if it contains a value not the default which seems to be equals a value?

Current setup that only triggers when the attribute “connected paired devices” equals the value.

Ideally I’d like to only use the normal editor, no node red or extra stuff. It’s too much for me to grasp right now.

2 Likes

This template returns true on my phone now since my glasses is connected.

{{'00:02:5B:01:5F:D1' in state_attr('sensor.andreas_bluetooth_connection', 'connected_paired_devices') }}
1 Like

Ahhh, took me a while to find the template trigger option.

Thanks this works perfectly.

Hi there,
I’m gonna hijack this one. I have the exact same problem.
Where do I put the template? Would you mind sharing your setup @Akiva ?
Thanks

If anyone is still wondering, as of HASS 2023.3, you need to include the device name as well for this template to work.

{{'F4:4E:FD:75:90:64 (SoundCore mini2)' in state_attr('sensor.pixel_6_pro_bluetooth_connection', 'connected_paired_devices') }}
2 Likes

Hello @cjade ,

this is almost the solution to my problem. Unfortunately my headset regularly changes MAC address and I can’t disable this. The “in” filter seems to be looking for an exact match. In your example i would also want to receive a true template when searching for “(SoundCore mini2)”.

Edit: I found a solution:
{{ state_attr('sensor.sensor_name', 'connected_paired_devices') | regex_findall(find='whatever', ignorecase=False) | count > 0 }}

5 Likes

This. You are a hero, this needs a GUI interface… Thank you!