Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an example for using regex #12822

Merged
merged 3 commits into from Apr 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 25 additions & 3 deletions source/_lovelace/entity-filter.markdown
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
```