Been trying to specifically configure a binary sensor(not a standard sensor) with little to no luck and I can’t seem to find a rhyme or reason
Configuration.yaml - working for my other templates
# Include Templates
template: !include_dir_merge_named templates/
If I do a regular ‘sensor’ in configuration.yaml the below works
- platform: template
sensors:
brad_phone_connected_car_bluetooth:
friendly_name: "Brad Phone Connected To Car Bluetooth"
value_template: >-
{{(state_attr('sensor.brad_pixel_6_pro_bluetooth_connection', 'connected_paired_devices')!=None)
and ('08:76:95:92:A7:B7' in state_attr('sensor.brad_pixel_6_pro_bluetooth_connection','connected_paired_devices'))
or ('00:32:A0:03:47:1B' in state_attr('sensor.brad_pixel_6_pro_bluetooth_connection','connected_paired_devices'))}}
However I specifically need a binary sensor - as shown here for
ulm_card_person_driving_entity
https://ui-lovelace-minimalist.github.io/UI/usage/custom_cards/custom_card_person_info/#description
Inside of templates/brad_phone_car_bluetooth.yaml I have tried the following, which shows the correct results when connected to either bluetooth(have included screenshots of both true and false). However the binary_sensor never actually updates when the state changes.
binary_sensor:
- name: "Brad Phone Connected To Car Bluetooth"
state: >-
{{(state_attr('sensor.brad_pixel_6_pro_bluetooth_connection', 'connected_paired_devices')!=None)
and ('08:76:95:92:A7:B7' in state_attr('sensor.brad_pixel_6_pro_bluetooth_connection','connected_paired_devices'))
or ('00:32:A0:03:47:1B' in state_attr('sensor.brad_pixel_6_pro_bluetooth_connection','connected_paired_devices'))}}
I’ve also tried the following variations.
binary_sensor:
- name: "Brad Phone Connected To Car Bluetooth"
state: >
{{ (is_state('sensor.brad_pixel_6_pro_bluetooth_connection', 'connected_paired_devices')!=None)}}
attributes:
connected_paired_devices: >
{% if (is_state('sensor.brad_pixel_6_pro_bluetooth_connection', 'connected_paired_devices')!=None) %}
{{ is_state_attr('sensor.brad_pixel_6_pro_bluetooth_connection','connected_paired_devices', '08:76:95:92:A7:B7') }}
{% elif %}
{{ is_state_attr('sensor.brad_pixel_6_pro_bluetooth_connection','connected_paired_devices', '00:32:A0:03:47:1B') }}
{% endif %}
binary_sensor:
- name: "Brad Phone Connected To Car Bluetooth"
state: >
{{ (is_state('sensor.brad_pixel_6_pro_bluetooth_connection', 'connected_paired_devices')!=None)}}
attributes:
koup: >
{% if (is_state('sensor.brad_pixel_6_pro_bluetooth_connection', 'connected_paired_devices')!=None) %}
{{ '08:76:95:92:A7:B7' in state_attr('sensor.brad_pixel_6_pro_bluetooth_connection','connected_paired_devices') }}
{% endif %}
s2000: >
{% if (is_state('sensor.brad_pixel_6_pro_bluetooth_connection', 'connected_paired_devices')!=None) %}
{{ '00:32:A0:03:47:1B' in state_attr('sensor.brad_pixel_6_pro_bluetooth_connection','connected_paired_devices') }}
{% endif %}
binary_sensor:
- name: "Brad Phone Connected To Car Bluetooth"
state: >
{{ (is_state('sensor.brad_pixel_6_pro_bluetooth_connection', 'connected_paired_devices')!=None)}}
attributes:
koup: >
{% if '08:76:95:92:A7:B7' in state_attr('sensor.brad_pixel_6_pro_bluetooth_connection','connected_paired_devices') %}
on
{% endif %}
s2000: >
{% if '00:32:A0:03:47:1B' in state_attr('sensor.brad_pixel_6_pro_bluetooth_connection','connected_paired_devices') %}
on
{% endif %}
Am I missing something, because it doesn’t seem obvious when looking at the templating documentation as to why this binary_sensor won’t actually update when the states are clearly changing?