Advertisement
JLindvig

Bluetooth test

Jan 30th, 2022
1,303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.84 KB | None | 0 0
  1. sandbox:
  2.   template:
  3.     - sensor:
  4.         - name: Bluetooth
  5.           unique_id: 7fe0d75533cd472181516d3fcb6332b8
  6.           state: >-
  7.             {% set connected_devices = state_attr('sensor.redmi_9t_bluetooth_connection', 'connected_paired_devices')[1:-1].split(',') %}
  8.             {% set paired_devices = state_attr('sensor.redmi_9t_bluetooth_connection', 'paired_devices')[1:-1].split(',') %}
  9.             {% set device_names = {
  10.               'FF:FC:33:54:04:36': 'Høretelefoner',
  11.               'EN_ANDEN_MAC_ADDR': 'En anden lækker enhed'
  12.             } %}
  13.  
  14.             {% for device in connected_devices -%}
  15.               {% if device in paired_devices %}
  16.                 {{ device_names[device] }} er tilsluttet
  17.               {% elif loop.last %}
  18.                 Intet tilsluttet.
  19.               {%- endif %}
  20.             {%- endfor %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement