I have a problem with multiple bluetooth devices and would like to use the device based on the mac-addr rather than the name hci#.
So far I’ve managed to get all the information as sensors:
Making it possible to use the secret in command_line (sensors/switches…)
- platform: template
sensors:
mac_bt_internal:
value_template: !secret mac_bt_internal
Getting the hci# from the template sensor
- platform: command_line
name: dev_bt_internal
command: hcitool dev | grep {{ states.sensor.mac_bt_internal.state }} | grep -oP hci.
Getting the # from the template sensor
- platform: command_line
name: id_bt_internal
command: hcitool dev | grep {{ states.sensor.mac_bt_internal.state }} | grep -oP hci. | tail -c 2
The entities
sensor.dev_bt_internal hci2 friendly_name: dev_bt_internal
sensor.id_bt_internal 2 friendly_name: id_bt_internal
sensor.mac_bt_internal AA:BB:CC:DD:EE:FF friendly_name: mac_bt_internal
Now I would like to use them as a template for multiple components, but here is one example with adapter: int
and one with adapter: string
adapter: int (in this case device_id, but same usage)
- platform: bluetooth_tracker
track_new_devices: no
device_id: 2
adapter: string
- platform: mitemp_bt
name: 'Living Room'
median: 3
adapter: 'hci2'
mac: !secret mac_bt_mitemp
monitored_conditions:
- temperature
- humidity
- battery
I’ve tried thing like, both with the hci# and #:
adapter: {{ states.sensor.dev_bt_internal.state }}
adapter: >
{{ states.sensor.dev_bt_internal.state }}
adapter: >-
{{ states.sensor.dev_bt_internal.state }}
adapter: >
{% set hci = states.sensor.dev_bt_internal.state %}
{{ hci }}
adapter: >-
{% set hci = states.sensor.dev_bt_internal.state %}
{{ hci }}
Anyone got any suggestions?