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

Filter on Empty Values or Any Values #103

Open
SolusCado opened this issue Dec 3, 2024 · 12 comments
Open

Filter on Empty Values or Any Values #103

SolusCado opened this issue Dec 3, 2024 · 12 comments
Labels
enhancement New feature or request

Comments

@SolusCado
Copy link

I would like to setup two separate cards, one that shows all items where a specific attribute (Studio) is empty, and one where that attribute has any value at all. I cannot seem to get this to work.
I can use 'sort_by' on the 'studio' attribute to group the items, but I need to put them in separate cards so I can restrict who can see a specific grouping.
Is there any way to specify something like "filter: studio=''" or "filter: studio=empty"? (And conversely, "filter: studio!=''" or "filter: studio!=empty"...)

@SolusCado SolusCado added the enhancement New feature or request label Dec 3, 2024
@mkanet
Copy link
Collaborator

mkanet commented Dec 3, 2024

Hi @SolusCado please try version 0.6.1. I just updated this repo a few minutes ago with this enhancement. Please note that when upgrading Upcoming Media Card, sometimes, it requires deleting your web browser cache to remove lingering old upcoming media card javascript code after upgrading to the new version.

Let me know how it works for you!

@SolusCado
Copy link
Author

SolusCado commented Dec 4, 2024 via email

@mkanet
Copy link
Collaborator

mkanet commented Dec 4, 2024

Honestly, I didnt test this yesterday since I thought I was a pretty straight-forward fix. Can you post the full EXACT card code you're using? Ill see if I can reproduce the issue.

@SolusCado
Copy link
Author

SolusCado commented Dec 4, 2024

There isn't much to it:

type: custom:upcoming-media-card
title: Recently Added
entity: sensor.media_library_plex_recently_added
image_style: fanart
enable_tooltips: true
enable_transparency: true
hide_unflagged: false
flag: false
filter: studio=""
max: 20

@mkanet
Copy link
Collaborator

mkanet commented Dec 5, 2024

@SolusCado I tried to test this on my setup before uploading version 0.6.2. However, I had no Sonarr shows to test against that currently have no studio defined. Please try it let me know if it works

@SolusCado
Copy link
Author

SolusCado commented Dec 5, 2024 via email

@mkanet
Copy link
Collaborator

mkanet commented Dec 6, 2024

I dont know why I didnt think of that before. I just tested it. The following works: filter: studio="" or filter: studio=''

@SolusCado
Copy link
Author

Ok; those still don't work for me - BUT this does:
filter: studio=

So, if I just leave it blank to the right of studio, it filters out any records with any value at all. So, that's good enough.

NOW... is there any way to reverse that? To show a wildcard or something, so that I only get records WITH a studio?

@mkanet
Copy link
Collaborator

mkanet commented Dec 12, 2024

Ok; those still don't work for me - BUT this does: filter: studio=

So, if I just leave it blank to the right of studio, it filters out any records with any value at all. So, that's good enough.

NOW... is there any way to reverse that? To show a wildcard or something, so that I only get records WITH a studio?

Glad its working for you. If you have a suggestion on how to reverse this using filter setting, let me know.

@gfay63
Copy link

gfay63 commented Jan 28, 2025

You're right, I apologize. Let me write a clean version of the comment without any markdown formatting so you can easily copy/paste it to GitHub:

I'm experiencing similar filtering issues, but it appears the problem may be more fundamental. The filter functionality doesn't seem to work at all, regardless of the value or operator used.

Examples of filters I've tried (none work):

- filter: runtime=2 (to filter trailers)
- filter: runtime=97 (to match a specific movie)
- filter: rating='' (to match empty ratings)
- filter: title=Drop (to match a specific title)

Browser console shows repeated errors:

TypeError: this._config.filter.exclude is not iterable
  at Wt.update_entities (/local/auto-entries.js:182:7500)
  at async Wt.update_all (/local/auto-entries.js:182:3552)

This error suggests the filter implementation expects a different structure than what's documented in the README. I've tried alternative formats like:

filter:
  exclude: title=Drop

and

filter:
  include: title=Drop

but these produce the same error.

Looking at a trailer example in my data:

airdate: '2025-01-25T18:01:33Z'
aired: '2025-04-10'
release: $day, $date $time
flag: true
title: Drop
episode: ''
runtime: 2
studio: Blumhouse Productions
genres: Thriller, Drama
rating: ''

None of the documented filter approaches work to filter these items, suggesting this might be a broader issue with the filter implementation itself rather than just handling of empty values.

@mkanet
Copy link
Collaborator

mkanet commented Jan 28, 2025

@gfay63 Thats now how the general filter was designed to work. First of all, the filter currently only excludes the defined filter value, not include. Secondly, you can only have 1 filter per card. The only new enhancement I added here was to allow excluding items with null values. such as:

filter: studio='' or
filter: studio=

If you would like to see new features such as include filter or adding multiple filters, feel free to open a new issue for these feature requests.

@gfay63
Copy link

gfay63 commented Jan 28, 2025

@mkanet Gotcha. Thanks for the confirmation...and quick reply! I can work with that as well, but still cannot get it to work. E.g., for this movie:

- airdate: '2025-01-27T07:21:57Z'
  aired: '2024-08-28'
  release: $day, $date $time
  flag: false
  title: Night Call
  episode: ''
  runtime: 97
  studio: Daylight Films
  genres: Thriller, Action
  rating: ★ 7.7
  poster: /local/upcoming-media-card-images/plex/Recently_Added_Plex_Movies/p81426.jpg
  fanart: /local/upcoming-media-card-images/plex/Recently_Added_Plex_Movies/f81426.jpg

none of these filters exclude it:

filter: episode=''
filter: episode=
filter: runtime=97
filter: title=Night Call
filter: flag=true

FYI, the other parts of the YAML are:

title: Plex Recently Released Movies
type: custom:upcoming-media-card
entity: sensor.recently_added_plex_movies
image_style: fanart
sort_by: number
enable_tooltips: true
filter: episode=''

In fact, I can't get the filter to do anything. I've tried everything and have never seen it exclude any. I am on the latest version. I just installed it a few days ago for the first time.

Thank you!
Greg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants