gcorgnet / sensor.emby_upcoming_media

Home Assistant component to feed Upcoming Media Card with the latest releases on an Emby instance.
MIT License
22 stars 17 forks source link

item(...).replace is not a function #34

Closed kolmpjess closed 6 months ago

kolmpjess commented 6 months ago

Hi,

I am unable to make this work, the card is turning red and only showing:

item(...).replace is not a function type: custom:upcoming-media-card entity: sensor.emby_latest_tv_shows title: sensor.emby_latest_movies

I've reinstalled it twice without succes, then i tried another custom plugin for upcoming-media-card (Steam Wishlist UMC) and that one did work. It's not alot to work with but i am not getting any error anywhere else for this apart from the card itself showing this.

Core 2024.3.3 Supervisor 2024.03.1

Thanks for your time

kolmpjess commented 6 months ago

Entity gets updated properly. Issue is within this component havent found a solution yet.

kolmpjess commented 6 months ago

The error is caused by the following code starting in line 593 of upcoming-media-card.js and is an issue from https://github.com/custom-cards/upcoming-media-card

` // Keyword map for replacement, return null if empty so we can hide empty sections let keywords = /\$title|\$episode|\$genres|\$number|\$rating|\$release|\$runtime|\$studio|\$price|\$day|\$date|\$time|\$aired|\$album|\$artist/g; let keys = { $title: item("title") || null, $episode: item("episode") || null, $genres: item("genres") || null, $number: item("number") || null, $rating: item("rating") || null, $release: item("release").replace("$date", format_date(item("airdate"), dateform)).replace("$year", format_date(item("airdate"), "yy")).replace(" $time", "  $ti> $studio: item("studio") || null, $price: item("price") || null, $album: item("album") || null, $artist: item("artist") || null, $runtime: runtime || null, $day: day || null, $time: airdate.toLocaleTimeString([], timeform) || null, $aired: format_date(item("aired"), dateform) || null };

`

So this is not an issue with your component and i managed to fix it.

gcorgnet commented 5 months ago

Thanks @kolmpjess . How did you end up fixing it? I have the same issue on my side

kolmpjess commented 5 months ago

Thanks @kolmpjess . How did you end up fixing it? I have the same issue on my side

Well for me it started after updating the ha core to the lastest version. After checking the code i found out it wasnt caused by this plugin, but by the main one called upcoming-media-card. I reported the issue with my findings there and they managed to fix it. So after that all i had to do was fully delete the upcoming-media-card plugin, restart HA, clearing my browser cache and reinstall the plugin.

Good luck!