Villhellm / lovelace-animated-background

Animated backgrounds for lovelace
191 stars 60 forks source link

default_url as list #26

Closed SeLLeRoNe closed 4 years ago

SeLLeRoNe commented 4 years ago

Describe the bug A clear and concise description of what the bug is. On a test view I don't want to define the background from the state of a specific entity but I would like to cycle from different backgrounds (mainly to test them).

Your Animated Background configuration

groups:
  - name: test
    config:
      default_url:
        - "/local/animated_backgrounds/test/Androm_Spin.mp4"
        - "/local/animated_backgrounds/test/biostorm.mp4"
        - "/local/animated_backgrounds/test/biostorm2.mp4"
        - "/local/animated_backgrounds/test/Bubbles_Animation.mp4"
        - "/local/animated_backgrounds/test/light_burst_animation.mp4"
        - "/local/animated_backgrounds/test/scifi-spin-v4.mp4"
        - "/local/animated_backgrounds/test/scifitunnel03.mp4"
        - "/local/animated_backgrounds/test/scifitunnel03.mp4"
        - "/local/animated_backgrounds/test/spin_cycle.mp4"

Your view configuration if it contains animated_background

animated_background:
  your_config

Version Numbers "Latest" is not a version number

Browser console log Post anything related to animated-background.js

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen. Havint the background to cycle from the default_url without having to be binded to a specific entity.

Device (please complete the following information):

Screenshots If applicable, add screenshots to help explain your problem.

SeLLeRoNe commented 4 years ago

I just realised that I used the bug report instead of the FR template, sorry!

Villhellm commented 4 years ago

Sorry, using an entity state is the way to test backgrounds. Cycling wouldn't really be possible because the array is only meant to function as a pool for random selection.

Here's an input select configuration and an animated background group to help

Input Select

input_select:
  background_test:
    name: Background Test
    options:
      - Background 1
      - Background 2
      - Background 3
      - Background 4
      - Background 5
      - Background 6
      - Background 7
      - Background 8
      - Background 9

Animated Background group

- name: background_test
  config:
    entity: input_select.background_test
    state_url:
      'Background 1' - "local/animated_backgrounds/test/Androm_Spin.mp4"
      'Background 2' - "local/animated_backgrounds/test/biostorm.mp4",
      'Background 3' - "local/animated_backgrounds/test/biostorm2.mp4"
      'Background 4' - "local/animated_backgrounds/test/Bubbles_Animation.mp4"
      'Background 5' - "local/animated_backgrounds/test/light_burst_animation.mp4"
      'Background 6' - "local/animated_backgrounds/test/scifi-spin-v4.mp4"
      'Background 7' - "local/animated_backgrounds/test/scifitunnel03.mp4"
      'Background 8' - "local/animated_backgrounds/test/scifitunnel03.mp4"
      'Background 9' - "local/animated_backgrounds/test/spin_cycle.mp4"

Admittedly I haven't tested these configs, but they should be valid.

PS make sure you don't try to use commas after each entry, the yaml parser will have a fit 😉 and no worries about the issue template, I understood what you were asking for.

SeLLeRoNe commented 4 years ago

Yep I noticed the comma on my config and I did fix that, didn't realize I did also copy them here, fixed the original message.

Thanks for the idea to test them, but what if I want them to cycle randomly without being directly related to an entity?

Not sure I understand why the same logic wouldn't be applicable to the default_url to be honest :)

Villhellm commented 4 years ago

If you want to get a new random background from the default_background array then you'd need to refresh the page, or switch to a view that has a different animated config and then go back. The previously used backgrounds that are selected from a random number are not stored anywhere. And what would be the trigger to cycle? There is no user input outside of an entity state change that can change the background

SeLLeRoNe commented 4 years ago

Sorry maybe I didn't explain myself properly.

Allow me to try again :D When for example you use the weather entity you can match the state, and for each state you can use different mp4 which are gonna be loaded randomly for if the state is matched. ex:

        'sunny':
          - "/local/animated_backgrounds/weather/hlhff0h8md4ev0kju5be.hd.mp4"
          - "/local/animated_backgrounds/weather/zjqsoc6ecqhntpl5vacs.hd.mp4"
          - "/local/animated_backgrounds/weather/jvw1avupguhfbo11betq.hd.mp4"
          - "/local/animated_backgrounds/weather/8cmeusxf3pkanai43djs.hd.mp4"
          - "/local/animated_backgrounds/weather/guwb10mfddctfvwioaex.hd.mp4"

What I was thinking is that it would be nice to have this option also for default_url, so that if you have no match configured (or matched) it will failback on the default_url one, but still randomly loading one of the available for the default_url

In this case, you can have an animated random background which is not stricly dependant on an entity state but it simply load a random one from a list defined in default_url

Was this clearer? I hope yes :)

Villhellm commented 4 years ago

Oh that should be possible do that already, are you having an issue when you define default_url as an array?

SeLLeRoNe commented 4 years ago

Ah! No I haven't tried because in the docs it says "string", not "list" ^^ I'll try right now!

Villhellm commented 4 years ago

Oops, yeah that was my other mission today, go through the docs to make sure everything is updated to the new standards 😝

Villhellm commented 4 years ago

I'm also working on defaulting to lovelace theme if there is an error finding a proper state/default url. Right now I think it would just go white if something was missing.

SeLLeRoNe commented 4 years ago

No worries at all, You actually gave me also a great way to select the background from a dropdown which can be very handy :)

After I test this I will make make the PR to update the docs for that matter also with an example

Villhellm commented 4 years ago

I'm working on the changes right now, so don't worry about it. They should be up within 20 minutes. But I'd appreciate if you would proofread for me again!

SeLLeRoNe commented 4 years ago

Confirmed that is working :)

I'll check the docs now :)

Villhellm commented 4 years ago

Okay I just updated the docs. And I removed dark sky from the examples :(

SeLLeRoNe commented 4 years ago

It seems all good to me.

Why removed dark_sky? beside that everyone (included me) will have to get rid of it (do you have a nice alternative?) :)

Villhellm commented 4 years ago

I was tired of people assuming that when dark sky gets removed it will break this plugin. And tired of people asking if they need dark sky for this to work.

I've just been using the default weather integration. It's definitely not as nice as dark sky and it only gives a 2 day forecast, but it at least gives you the current weather, which is all this plugin really needs to function as intended.

SeLLeRoNe commented 4 years ago

I see, thanks! :)