FamousWolf / week-planner-card

Custom Home Assistant card displaying a responsive overview or multiple days with events from one of multiple calendars
MIT License
172 stars 13 forks source link

Filtering Events #67

Closed maranhaoBruno closed 1 month ago

maranhaoBruno commented 4 months ago

Is there a way to filter events in or out so that they do or don’t appear in the calendar? I subscribe to some work and school (my kids) calendars that I don’t control, and I would like to restrict the number of events that appear on my calendar as not all of the events posted in the public calendar are pertinent to myself or my family?

thanks, B

doctorkb commented 3 months ago

Likewise, my Google Calendars are bringing in my working location -- would love to be able to ignore any event that matches a certain regex.

broyuken commented 1 month ago

I would like to request this as well. My wife is a fitness instructor and she has a calendar that lists who is teaching, but I would only want it to be listed on our calendar if she is teaching. Or only bring in events from my work calendar if the subject contains "Company Holiday" or similar.

FamousWolf commented 1 month ago

This has been added to the dev branch and will be included in the 1.7.0 release.

FamousWolf commented 1 month ago

You can use the filter configuration to define a regular expression. Any event title that matches the regular expression will be filtered out and not shown.

broyuken commented 1 month ago

Can you use this to filter in events too instead of out? Do you have an example we can work off of? Does it filter on a per calendar basis?

FamousWolf commented 1 month ago

It uses regular expression, which are very versatile. So yes, you can filter out any events that does not contain a certain string. It does get rather complex quickly though.

A simple example would be to filter out any even that contains the words secret or private, which would be filter: '(private|secret)'.

To filter out anything that does not contain the words secret or private you would need to use something called a negative lookahead assertion, which would be something like: filter: '^((?!(private|secret)).)*$'.

The current filter is for events from all calendars. It is currently not possible to only filter events from a single calendar and not others.

broyuken commented 1 month ago

So this wouldn’t solve my use cases then. I only want to filter IN events that say “company holiday” from my work calendar. Or filter in events with my wife’s name from her class calendar. Should we reopen this issue or should I open a new request to track this?

FamousWolf commented 1 month ago

Please create a new issue for this