Lovelace: Weather Mp4 Backgrounds

When looking into Lovelace I found a post on Reddit about using gifs as a background. Sadly a 1080p gif tends to be quite big in file size. So here is an option that allows you to use an mp4.

This card uses position absolute to load itself in the background. And I use an Iframe to then set the content of the absolute div. This is due to the fact that using the

How to install:

  1. Copy “weatherbg-card.js” and the folder “weather-animations” into your /www/
  2. Add the card to your resources in the ui-lovelace.yaml
      - url: /local/weatherbg-card.js
        type: module 
  1. Load the card as the last card in your view and hand it a weather object
        - type: "custom:weatherbg-card"
          weather: weather.dark_sky
          #NO CARDS AFTER THIS THEY WILL NOT BE SHOWN

You can change the videos to whatever you like by editing the HTML files in “weather-animations”.
By default, the video has a 20% opacity black overlay. This can be adjusted in the main .js file by changing the background of “.bg-wrap:before”

views:
  - title: Example
    id: example
    background: 
    theme:
    cards:
      - type: weather-forecast
        entity: weather.dark_sky
        
      - type: "custom:weatherbg-card"
        url: /local/custom_ui/weather-animations/cloud.html
        weather: weather.dark_sky
        #NO CARDS AFTER THIS THEY WILL NOT BE SHOWN

I am still looking on how to improve this or even creating a PR for Polymer.

9 Likes

Using the code you passed me I did this:

The choppiness is from the capture program, it’s actually smooth.

5 Likes

Holy sh*t … That’s amazing!!! Could you share how did you do that??

Thanks @perdemot for this nice card!!

That’s amazing, what impact does it have on the client, is this still usable remotely?

FYI @perdemot I used this bit in the HTML to autoplay and loop the video:

<video autoplay muted loop>
     <source src="myvideoloop.mp4" type="video/mp4">
</video>
1 Like

Runs smooth as silk when I browse it from my phone

Using the same in my iframe setup, but it doens’t properly work on some devices. Might be my adblock. Currently looking into it.

True, I only have tested it in Chrome on my desktop and cell phone.

I did have to modify the iframe a touch too:

<iframe class="bg-iframe" scrolling="no" src="${config.url}"/>

with a small mod to the css as well:

        .bg-wrap{
            position: absolute;
            right: 0;
            bottom: 0;
            min-width: 100vw; 
            min-height: 100vh;
            top:-117px;
            z-index: -1;
        }
1 Like

I want to know how to change different gifs

this needs to be a built-in HA option on any screen. thats killer, well done!

I set this in ui-lovelace.yaml:

  - icon: mdi:weather-cloudy
    id: meteo2
    title: Meteo2
    cards:
      - type: "custom:weatherbg-card"
        weather: weather.meteo_darksky

And i have weather.meteo_darksky configured in this way:

  - type: weather-forecast
    entity: weather.meteo_darksky

In configuration.yaml i have:

weather:
  - platform: darksky
    api_key: !secret darksky_api_key
    name: Meteo DarkSky
    mode: daily

But in the front end i can see only the mp4 video and not the card.
Where am i wrong?

Anyone can help me in finding where i am wrong?

Is it easy to set it as background in a weather card?

I cannot get the card over the background… i followed the instructions here, but i get only the mp4 background.

What browser are you using?

Chrome on a MAC Os X

Can you post your whole lovelace.yaml ?

  - url: /local/weatherbg-card.js
    type: module

  - icon: mdi:weather-cloudy
    id: meteo2
    title: Meteo2
    cards:
      - type: "custom:weatherbg-card"
        weather: weather.meteo_darksky

So you don’t have a weather card set to display so, try something like this:

    - type: custom:dark-sky-weather-card
      entity_sun: sun.sun
      entity_daily_summary: sensor.dark_sky_daily_summary
      entity_current_conditions: sensor.dark_sky_icon  
      entity_humidity: sensor.dark_sky_humidity
      entity_pressure: sensor.dark_sky_pressure
      entity_temperature: sensor.dark_sky_temperature
      entity_visibility: sensor.dark_sky_visibility
      entity_wind_bearing: sensor.dark_sky_wind_bearing
      entity_wind_speed: sensor.dark_sky_wind_speed
      entity_forecast_high_temp_1: sensor.dark_sky_daytime_high_temperature_1
      entity_forecast_high_temp_2: sensor.dark_sky_daytime_high_temperature_2
      entity_forecast_high_temp_3: sensor.dark_sky_daytime_high_temperature_3
      entity_forecast_high_temp_4: sensor.dark_sky_daytime_high_temperature_4
      entity_forecast_high_temp_5: sensor.dark_sky_daytime_high_temperature_5
      entity_forecast_low_temp_1: sensor.dark_sky_overnight_low_temperature
      entity_forecast_low_temp_2: sensor.dark_sky_overnight_low_temperature_1
      entity_forecast_low_temp_3: sensor.dark_sky_overnight_low_temperature_2
      entity_forecast_low_temp_4: sensor.dark_sky_overnight_low_temperature_3
      entity_forecast_low_temp_5: sensor.dark_sky_overnight_low_temperature_4
      entity_forecast_icon_1: sensor.dark_sky_icon_1
      entity_forecast_icon_2: sensor.dark_sky_icon_2
      entity_forecast_icon_3: sensor.dark_sky_icon_3
      entity_forecast_icon_4: sensor.dark_sky_icon_4
      entity_forecast_icon_5: sensor.dark_sky_icon_5   

      - type: "custom:weatherbg-card"
        weather: weather.meteo_darksky

Yes, i have it… forgot to quote…

  - type: custom:dark-sky-weather-card
    title: Meteo
    entity_weather: weather.meteo_darksky
    entity_sun: sun.sun
    entity_daily_summary: sensor.dark_sky_daily_summary
    entity_current_conditions: sensor.dark_sky_icon  
    entity_humidity: sensor.dark_sky_humidity
    entity_pressure: sensor.dark_sky_pressure
    entity_temperature: sensor.dark_sky_temperature
    entity_visibility: sensor.dark_sky_visibility
    entity_wind_bearing: sensor.dark_sky_wind_bearing
    entity_wind_speed: sensor.dark_sky_wind_speed
    entity_forecast_high_temp_1: sensor.dark_sky_daytime_high_temperature_1
    entity_forecast_high_temp_2: sensor.dark_sky_daytime_high_temperature_2
    entity_forecast_high_temp_3: sensor.dark_sky_daytime_high_temperature_3
    entity_forecast_high_temp_4: sensor.dark_sky_daytime_high_temperature_4
    entity_forecast_high_temp_5: sensor.dark_sky_daytime_high_temperature_5
    entity_forecast_low_temp_1: sensor.dark_sky_overnight_low_temperature
    entity_forecast_low_temp_2: sensor.dark_sky_overnight_low_temperature_1
    entity_forecast_low_temp_3: sensor.dark_sky_overnight_low_temperature_2
    entity_forecast_low_temp_4: sensor.dark_sky_overnight_low_temperature_3
    entity_forecast_low_temp_5: sensor.dark_sky_overnight_low_temperature_4
    entity_forecast_icon_1: sensor.dark_sky_icon_1
    entity_forecast_icon_2: sensor.dark_sky_icon_2
    entity_forecast_icon_3: sensor.dark_sky_icon_3
    entity_forecast_icon_4: sensor.dark_sky_icon_4
    entity_forecast_icon_5: sensor.dark_sky_icon_5
    entity_background: Beach.jpg