Villhellm / lovelace-animated-background

Animated backgrounds for lovelace
195 stars 61 forks source link

custom sensor problem - only showing default url #36

Closed 0lmagalhaes0 closed 3 years ago

0lmagalhaes0 commented 3 years ago

After creation of a custom sensor to sum sun and weather, only the standard background is being showed.

Configuration.yaml (copied from example in documentation, I didn't build any template manually)

sensor:
  - platform: template
    sensors:
      sun_weather:
        friendly_name: "Sun and Weather"
        value_template: "{{states('sun.sun') + '-' + states('home.weather')}}"

Your view configuration if it contains animated_background

raw config

animated_background:
  default_url: 'https://cdn.flixel.com/flixel/ypy8bw9fgw1zv2b4htp2.hd.mp4'     #that's the only one showing up
  entity: sensor.sun_weather
  state_url:
    above_horizon-sunny:
      - 'https://1drv.ms/v/s!AlUhvEdB-IMWxC7vu17T6mqTsHiF'
    above_horizon-partlycloudy:
      - 'https://1drv.ms/v/s!AlUhvEdB-IMWxCXubRfvvYmCP_mX'
    above_horizon-cloudy:
      - 'https://1drv.ms/v/s!AlUhvEdB-IMWxC8b3r8ZOLDBkwTU'

There are other sensor values, but I also tried with only these and the original urls and got the same problem (only default url showing up)

Version Numbers

Browser console log Uncaught TypeError: Cannot read property 'background' of null at removeDefaultBackground (animated-background.js:535) at animated-background.js:576 animated-background.js:28 Animated Background: Starting chunk.dbba5c652adfa0940143.js:26537 Detected removal of the top Blocking Element. Uncaught (in promise) Animated Background: Starting Failed to load resource: the server responded with a status of 404 (Not Found)

To Reproduce I created the new sensor in configuration.yaml, changed from standard weather to new sensor (sun and weather) in raw editor, added new weather status as per its documentation (like snowy-rain and windy, for example) and new video sources. Restarted HA. Now it's cloudy and sun above horizon. I tried replacing the new video for the standard one (previously working), with no difference. The new custom sensor is being recognized by the system. Re-replaced the videos by the original ones. Re-restarted HA. No difference.

Expected behavior I expected to add custom videos (hosted in One Drive, Dropbox or other) to mirror weather and sun condition (night videos for night time and day videos for day time, according to their respective weather conditions).

Device (please complete the following information):

Screenshots It seems something is wrong in my sensor configuration, but since the codes are here, I wouldn't know what screenshot would be further helpful.

Sorry to bother, I'm a beginner with these technical configurations, so I'm pretty sure it's my fault.

Villhellm commented 3 years ago

There are several problems here, but the first is you need to check the actual state of the sensor in Dev Tools > states to see if it is actually showing a state that you've listed. If "{{states('sun.sun') + '-' + states('home.weather')}}" is your actual template then I doubt the state is valid because home.weather is not a valid entity.

The other problem is the video links you're trying to use are not going to work. The URL has to end in .mp4 otherwise it's not truly a link to the hosted video. It's just a link to the file share.

Villhellm commented 3 years ago

You can try clicking the video link, and then right click the video and select "open video in new tab". The URL that opens should be to the raw mp4 file

0lmagalhaes0 commented 3 years ago

You're right, it was supposed to be weather.home. It shows home.weather in my Entities list, I don't know why. But I switched it and it worked! And thanks for the tip regarding the video, I'll try it out.