Templating command "in" (state attribute search) not working
The problem
Hi friends!
The template command "in" for searching strings in a state_attr is no longer working
Here an example of my code for searching: value_template: "{{(state_attr('sensor.enricfon_bluetooth_connection','connected_paired_devices')!=None) and ('EE:5C:0F:EF:B2:D2' in state_attr('sensor.enricfon_bluetooth_connection','connected_paired_devices'))}}"
One month ago it was working, no code changed, and no longer is working.
What version of Home Assistant Core has the issue?
2022-11-1
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
No response
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
- platform: template
sensors:
enric_blu_instinct:
value_template: "{{(state_attr('sensor.enricfon_bluetooth_connection','connected_paired_devices')!=None) and ('EE:5C:0F:EF:B2:D2' in state_attr('sensor.enricfon_bluetooth_connection','connected_paired_devices'))}}"
enric_blu_furgo:
value_template: "{{(state_attr('sensor.enricfon_bluetooth_connection','connected_paired_devices')!=None) and ('A0:14:3D:89:1D:F0' in state_attr('sensor.enricfon_bluetooth_connection','connected_paired_devices'))}}"
enric_blu_yaris:
value_template: "{{(state_attr('sensor.enricfon_bluetooth_connection','connected_paired_devices')!=None) and ('88:30:8A:93:C5:F2' in state_attr('sensor.enricfon_bluetooth_connection','connected_paired_devices'))}}"
enric_blu_altaveu:
value_template: "{{(state_attr('sensor.enricfon_bluetooth_connection','connected_paired_devices')!=None) and ('FC:58:FA:19:7F:6A' in state_attr('sensor.enricfon_bluetooth_connection','connected_paired_devices'))}}"
enric_blu_cascos:
value_template: "{{(state_attr('sensor.enricfon_bluetooth_connection','connected_paired_devices')!=None) and ('07:43:54:4A:DA:AE' in state_attr('sensor.enricfon_bluetooth_connection','connected_paired_devices'))}}"
Anything in the logs that might be useful for us?
No response
Additional information
No response
Syntax should be:
in [ a, b ]
Simone
Has de syntax changed?
Have you some other example?
The syntax hasn't changed. If you copy-paste this into the Template Editor you'll see it reports True.
{{ 'cat' in 'concatenate' }}
The question is has the value of connected_paired_devices changed?
Copy-paste the following into the Template Editor and see what it reports.
{{ state_attr('sensor.enricfon_bluetooth_connection', 'connected_paired_devices') }}
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.