From 32c9b7dd0edece52ec5866282b444ab6bbbb5b36 Mon Sep 17 00:00:00 2001 From: Sean Straus Date: Sun, 12 Apr 2020 12:11:42 +0200 Subject: [PATCH] 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 --- source/_lovelace/entity-filter.markdown | 28 ++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/source/_lovelace/entity-filter.markdown b/source/_lovelace/entity-filter.markdown index f19775a52d6..34e932a96a3 100644 --- a/source/_lovelace/entity-filter.markdown +++ b/source/_lovelace/entity-filter.markdown @@ -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 ``` +

Entity filter combined with glance card Entity filter combined with glance card.

-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 +```