Added an example for using regex (#12822)

* Added an example for using regex

This is a working example from my config. Hopefully can save someone some time with the general syntax.

* Update entity-filter.markdown

* Minor changes

Co-authored-by: Fabian Affolter <mail@fabian-affolter.ch>
This commit is contained in:
Sean Straus 2020-04-12 12:11:42 +02:00 committed by GitHub
parent 01c2cd3189
commit 32c9b7dd0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,7 +94,8 @@ attribute:
### Examples
Show only active switches or lights in the house
Show only active switches or lights in the house.
```yaml
type: entity-filter
entities:
@ -120,12 +121,13 @@ card:
type: glance
title: People at home
```
<p class='img'>
<img src='/images/lovelace/lovelace_entity_filter_glance.png' alt='Entity filter combined with glance card'>
Entity filter combined with glance card.
</p>
You can also specify multiple state_filters, in which case matching any condition will display the entity. This example will display everyone who isn't at home or at work.
You can also specify multiple `state_filter`s, in which case matching any condition will display the entity. This example will display everyone who isn't at home or at work.
```yaml
type: entity-filter
@ -143,7 +145,7 @@ card:
title: Who's Running Errands
```
Specify filter for a single entity
Specify filter for a single entity.
```yaml
type: entity-filter
@ -160,3 +162,23 @@ entities:
value: 50
attribute: humidity
```
Use a regex filter against entity attributes. This regex filter below looks for expressions that are 1 digit in length and where the number is between 0-7 (so show holidays today or in the next 7 days) and displays those holidays as entities in the entity-filter card.
```yaml
- type: entity-filter
card:
title: "Upcoming Holidays In Next 7 Days"
show_header_toggle: false
state_filter:
- operator: regex
value: "^([0-7]{1})$"
attribute: eta
entities:
- entity: sensor.upcoming_ical_holidays_0
- entity: sensor.upcoming_ical_holidays_1
- entity: sensor.upcoming_ical_holidays_2
- entity: sensor.upcoming_ical_holidays_3
- entity: sensor.upcoming_ical_holidays_4
show_empty: false
```