I have had a script built for the past 6 months that will tell me if any windows or doors are open set to run at a specific time. I had to use a rejectattr to exclude the integration of my Toyota, as it was catching my vehicles doors as open. Everything was working fine until I upgraded to the latest stable release, and now the script/template does not seem to ignore what I am telling it to. Not sure if this is a bug in the latest release or if something has changed and I need to update my script.
My current template is as follows:
message: >
{%- set windowsanddoors = states.binary_sensor|
selectattr('attributes.device_class', 'in',['door','window'])|
selectattr('state','eq','on') | map(attribute='name') |
rejectattr('entity_id', 'in', integration_entities('Lexus NX450h+')) | list
%} {% if windowsanddoors | length == 0 %} All windows and doors are closed.
{%- elif windowsanddoors | length == 1 %} {{ windowsanddoors[0] }} is open.
{%- else %} {{ windowsanddoors[:-1] | join(', ') }}{{',' if windowsanddoors
| length > 2 else ''}} and {{ windowsanddoors[-1]}} are open. {%- endif %}
EDIT: I currently disabled the Toyota integration as a workaround
Are you sure the name of the integration is “Lexus NX450h+”?
Also, you should always select for the device class attribute being defined prior to selecting for its value… there will often be entities that don’t have a defined device class and it will cause your template to fail.
After you do | map(attribute='name') you don’t have the full state objects to work with anymore, only the names. So using selectattr('entity_id', 'in' whatever) won’t work anymore.
Move the map filter to after the selectattr() filter
These 2 filters have to be switched. After applying the first one (| map()) you will only have the names left, so you don’t have access to the entity_id anymore to use in the second one (| rejectattr())