Android Phone BT connection as a condition

I would like to trigger my garage door to open when entering my zone and use my phones BT connection as a condition.
I ride a motorcycle and have a BT headset connected to my phone and I would only like the door to open when the phone is connected to that BT device
I have tried everything and nothing works.
Running in Docker on Synology NAS
Home Assistant 2022.9.4
Frontend 20220907.2 - latest

condition: state
entity_id: sensor.sm_n986b_bluetooth_connection
attribute: connected_paired_devices
state: " D0:A4:6F:CB:BF:AA, 44:68:0C:82:04:E4"

any help would be much appreciated
Thanks

Something like this:

condition:
  - condition: template
    value_template: >-
      {{ "D0:A4:6F:CB:BF:AA" in state_attr("sensor.sm_n986b_bluetooth_connection", "connected_paired_devices") }}

I just took the first MAC, make sure it’s the correct one.

The mac is correct as that is my headset the second mac is the spen for the note ultra,

I get this
TypeError: argument of type ‘NoneType’ is not iterable

I don’t get that error.
Post the full automation.

What does it look like in template tools?

Taken From States connected_paired_devices: D0:A4:6F:CB:BF:AA (LC-B45), 44:68:0C:82:04:E4 (SPEN NA)
returns false just like yours, but how to i use that in a condition
Oh and thanks a bunch for taking the time to help

Switch the full automation to yaml mode.

This line here:
image

Is this:
image

Your full yaml looks currently like this:

condition:
  condition:
    -condition: template

it should be:

condition:
  -condition: template

EDIT, I think you can just delete what is yellow marked here:

 - platform: device
    type: turned_on
    device_id: 4b9b9be7043a94ae26ac691439b40e8d
    entity_id: switch.harley
    domain: switch
  condition:
  - condition: template
    value_template: '{{ "D0:A4:6F:CB:BF:AA, 44:68:0C:82:04:E4" in state_attr("sensor.sm_n986b_bluetooth_connection",
      "connected_paired_devices") }}'
  action:
  - type: turn_on
    device_id: 4b9b9be7043a94ae26ac691439b40e8d
    entity_id: light.computer
    domain: light
  mode: single

I am just using a light switch to test the condition

It was just one of the Bluetooth devices you wanted as a condition? You had both as a string.
That will only work when both is connected at the same time. And the name had LC-B45 also in it?

- platform: device
    type: turned_on
    device_id: 4b9b9be7043a94ae26ac691439b40e8d
    entity_id: switch.harley
    domain: switch
  condition:
  - condition: template
    value_template: '{{ "D0:A4:6F:CB:BF:AA (LC-B45)" in state_attr("sensor.sm_n986b_bluetooth_connection",
      "connected_paired_devices") }}'
  action:
  - type: turn_on
    device_id: 4b9b9be7043a94ae26ac691439b40e8d
    entity_id: light.computer
    domain: light
  mode: single

yes it has to be both because the phone a the BT S Pen

- platform: device
    type: turned_on
    device_id: 4b9b9be7043a94ae26ac691439b40e8d
    entity_id: switch.harley
    domain: switch
  condition:
  - condition: template
    value_template: '{{ "D0:A4:6F:CB:BF:AA (LC-B45)" in state_attr("sensor.sm_n986b_bluetooth_connection",
      "connected_paired_devices") }}'
  - condition: template
    value_template: '{{ "44:68:0C:82:04:E4 (SPEN NA)" in state_attr("sensor.sm_n986b_bluetooth_connection",
      "connected_paired_devices") }}'
  action:
  - type: turn_on
    device_id: 4b9b9be7043a94ae26ac691439b40e8d
    entity_id: light.computer
    domain: light
  mode: single
1 Like

Works perfectly thanks so much

Mate , you absolutly nailed it and it works perfectly … but if you run the test in the UI you will get the error below.

Error occurred while testing condition
template value should be a string for dictionary value @ data[‘value_template’]. Got Noneolutly nailed it … thanks … I will say that it works pefectly but in you run the test you get this

Perhaps this is when you test the condition if nothing is connected?
I assume that means the value is none then.

I’m pretty sure it is a long known about bug in the testing system.