JLindvig

Untitled

Jan 29th, 2022 (edited)
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /config/template.yaml
  2. - sensor:
  3. - name: "Bluetooth Connection"
  4. state: >
  5. {% set connected_devices = state_attr('sensor.moto_g_8_plus_bluetooth_connection', 'connected_paired_devices')[1:-1].split(',') %}
  6. {% set paired_devices = state_attr('sensor.moto_g_8_plus_bluetooth_connection', 'paired_devices')[1:-1].split(',') %}
  7. {% set device_names = {
  8. 'F4:B6:88:43:0D:BA': 'Headset V5200',
  9. '00:02:19:24:26:17': 'Bil Radio',
  10. '93:94:DB:ED:95:74': 'BT højtaler', <-------- PRØV AT FJERNE KOMMAET HER.
  11. '37:43:7D:99:F9': 'UKENDT MFP', <-------- PRØV AT FJERNE HELE DENNE LINIE
  12. } %}
  13.  
  14. {% for device in connected_devices -%}
  15. {% if device in paired_devices %}
  16. {{ device_names[device] }} .
  17. {% elif loop.last %}
  18. NONE.
  19. {%- endif %}
  20. {%- endfor %}
  21.  
  22. Giver følgende fejl i log:
  23. Logger: homeassistant
  24. Source: components/bluetooth_tracker/device_tracker.py:63
  25. First occurred: 24:52:27 (52 occurrences)
  26. Last logged: 01:02:28
  27.  
  28. Error doing job: Task exception was never retrieved
  29. Traceback (most recent call last):
  30. File "/usr/src/homeassistant/homeassistant/components/bluetooth_tracker/device_tracker.py", line 192, in update_bluetooth
  31. await perform_bluetooth_update()
  32. File "/usr/src/homeassistant/homeassistant/components/bluetooth_tracker/device_tracker.py", line 156, in perform_bluetooth_update
  33. devices = await hass.async_add_executor_job(discover_devices, device_id)
  34. File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
  35. result = self.fn(*self.args, **self.kwargs)
  36. File "/usr/src/homeassistant/homeassistant/components/bluetooth_tracker/device_tracker.py", line 63, in discover_devices
  37. result = bluetooth.discover_devices(
  38. File "/usr/local/lib/python3.9/site-packages/bluetooth/bluez.py", line 26, in discover_devices
  39. device_id = _bt.hci_get_route()
  40. OSError: [Errno 19] No such device
  41.  
  42. OG:
  43.  
  44. Logger: homeassistant.helpers.template
  45. Source: helpers/template.py:1779
  46. First occurred: 24:52:28 (2 occurrences)
  47. Last logged: 24:52:28
  48.  
  49. Template variable warning: 'dict object' has no attribute ' 93:94:DB:ED:95:74' when rendering '{% set connected_devices = state_attr('sensor.moto_g_8_plus_bluetooth_connection', 'connected_paired_devices')[1:-1].split(',') %} {% set paired_devices = state_attr('sensor.moto_g_8_plus_bluetooth_connection', 'paired_devices')[1:-1].split(',') %} {% set device_names = { 'F4:B6:88:43:0D:BA': 'Headset V5200', '00:02:19:24:26:17': 'Bil Radio', '93:94:DB:ED:95:74': 'BT højtaler', '37:43:7D:99:F9': 'UKENDT MFP', } %} {% for device in connected_devices -%} {% if device in paired_devices %} {{ device_names[device] }} . {% elif loop.last %} NONE. {%- endif %} {%- endfor %}'
Add Comment
Please, Sign In to add comment