Random Movie Suggestion

Hello,

I'd like to share my random movie suggestion project.
Bellow you'll find every .yaml, and integration needed for the card (last card in the picture).
It generates a new suggestion if clicked (with background picture, rating and overview).
Optionally you can add filters.

You'll need a free TMDB API key.

Integrations:

  • HACS
  • :mushroom: Mushroom
  • card-mod

.yaml:
Add this to your configuration.yaml (and replace "YOUR API KEY"):

rest_command:
  tmdb_random_movie:
    url: "https://api.themoviedb.org/3/movie/popular?api_key=YOUR API KEY&page={{ range(1, 10) | random }}"
    method: GET
    
input_text:
  random_movie_overview:
    name: Random Movie Overview
    max: 255
    mode: text

Script:

alias: Random Movie Pick
mode: single
sequence:
  - response_variable: result
    action: rest_command.tmdb_random_movie
  - variables:
      movies: "{{ result.content.results | default([]) }}"
  - condition: template
    value_template: "{{ movies | length > 0 }}"
  - variables:
      movie: "{{ movies | random }}"
      first_sentence: >-
        {{ (movie.overview | default('No description available')).split('.')[0]
        ~ '.' if (movie.overview | default('')) | length > 0 else 'No
        description available' }}
  - target:
      entity_id: input_text.random_movie_title
    data:
      value: "{{ movie.title | default('Unknown') }}"
    action: input_text.set_value
  - target:
      entity_id: input_text.random_movie_overview
    data:
      value: "{{ first_sentence }}"
    action: input_text.set_value
  - target:
      entity_id: input_text.random_movie_backdrop
    data:
      value: "{{ movie.backdrop_path | default('') }}"
    action: input_text.set_value
  - target:
      entity_id: input_text.random_movie_rating
    data:
      value: "{{ (movie.vote_average | float(0)) | round(1) }}"
    action: input_text.set_value

Add Helpers:
input_text.random_movie_title
input_text.random_movie_overview
input_text.random_movie_backdrop
input_text.random_movie_rating

Mushroom Template Card:

type: custom:mushroom-template-card
primary: 🎬 {{ states('input_text.random_movie_title') }}
secondary: |-
  ⭐ {{ states('input_text.random_movie_rating') }}

  {{ states('input_text.random_movie_overview') }}
icon: mdi:plex
icon_color: orange
tap_action:
  action: call-service
  service: script.random_movie_pick
card_mod:
  style: |
    ha-card {
      border-radius: 45px;
      padding: px;
      min-height: 120px;
      max-width: 500px;

      background:
        linear-gradient(
          rgba(0,0,0,0.25),
          rgba(0,0,0,0.75)
        ),
        url("https://image.tmdb.org/t/p/original{{ states('input_text.random_movie_backdrop') }}");

      background-size: cover;
      background-position: center;
      background-repeat: no-repeat;

      color: white;

      backdrop-filter: blur(14px);
      -webkit-backdrop-filter: blur(14px);

      box-shadow: 0 20px 35px rgba(0,0,0,0.5);
    }

    ha-card .primary {
      font-size: 20px !important;
      font-weight: 700 !important;
      white-space: normal !important;
      word-wrap: break-word !important;
    }

    ha-card .secondary {
      font-size: 13px !important;
      opacity: 0.9;
      line-height: 1.4em;
      white-space: pre-wrap !important;
      word-wrap: break-word !important;
    }
grid_options:
  columns: 12
  rows: 1