Exclude Certain Devices in Template

I’m using the below template to show me “unavailable” devices. Sometimes I want to exclude certain devices (for example, the Christmas Lights when it’s not Christmas season. How can I exclude certain devices from being returned by this template?

{{ states
| selectattr('domain','in',['binary_sensor', 'climate', 'light', 'sensor', 'switch'])
| selectattr('state', 'in', ['unavailable'])
| map(attribute='entity_id')
| map('device_attr', 'name_by_user') 
| reject('match', 'None')
| unique
| list 
| sort 
| join('\n')
}}

This regex pattern matches any string containing the words Christmas or Halloween or Kitchen.
(Christmas|Halloween|Kitchen)

Therefore this filter will reject any device name containing any one of those three words.

reject('match', '(Christmas|Halloween|Kitchen)')

If you only want to reject names based on a single word, you can reduce it to this:

reject('match', 'Christmas')
{{ states
| selectattr('domain','in',['binary_sensor', 'climate', 'light', 'sensor', 'switch'])
| selectattr('state', 'in', ['unavailable'])
| map(attribute='entity_id')
| map('device_attr', 'name_by_user') 
| reject('match', 'None')
| reject('match', '(Christmas|Halloween|Kitchen)')
| unique
| list 
| sort 
| join('\n')
}}

EDIT

If you wish, you can consolidate the two reject filters.

Just out of curiosity have you seen this? I just released a significant update so you can exclude devices and entities with labels eliminating the need to use filters altogether. With the newest version you can just add the label “ignored” to any devices or entities you want to exclude from the sensor. It also now ignores entities belonging to disabled devices by default.