Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Refresh SVG on animation/time/state/... #249

Open
stinobook opened this issue Apr 7, 2024 · 1 comment
Open

Feature: Refresh SVG on animation/time/state/... #249

stinobook opened this issue Apr 7, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@stinobook
Copy link

The Problem To Be Solved

usersvg images are loaded on card load, not on image load.

Additional background:

trying to implement a camera(image stream, not camera stream) view inside the card.

A concise description of your preferred solution. Things to address include:

I have written a derived entity so that my 'state' always updates every few seconds.
It switches between 2 states, and i have 2 images 'coupled' to it.

(Optional): Suggested Solution

how i see it now the images are 'preloaded' by the card as soon as the card is loaded, but if we can just load the image when it is requested instead of on card load this would make it update each time and allow us to insert a stream inside the card.

my tool:

                - type: usersvg
                  position:
                    cx: 50
                    cy: 55
                    height: 35
                    width: 50
                  style: 'images'
                  entity_index: 12
                  derived_entity:
                    input : '[[[ return state ]]]'
                    state: >
                      [[[
                        if (typeof(entity) === 'undefined') return;
                        if (typeof(state) === 'undefined') return;
                        if (state === 'undefined') return;
                        var sec = state.slice(-1);
                        if (sec % 2 == 0) {
                            return ('even');
                        } else {
                            return ('uneven');
                        }
                  images:
                    - default: /api/image_proxy/image.----
                    - even: /api/image_proxy/image.----
                    - uneven: /api/image_proxy/image.----
                  animations:
                    - state: 'even'
                      image: even
                    - state: 'uneven'
                      image: uneven`


@stinobook stinobook added the enhancement New feature or request label Apr 7, 2024
@kkggaa45
Copy link

Hi, try this example (this is how I output the video stream from the camera and album covers from the media player)

            ####################################################
                  - type: usersvg
                    position:
                      cx: 50
                      cy: 38
                      height: 73
                      width: 97
                    clip_path:
                        position:
                          cx: 50
                          cy: 50      
                          height: 73  
                          width: 97
                          radius:    
                            top_left: 1.2
                            top_right: 1.2
                            bottom_right: 1.2
                            bottom_left: 1.2
                    entity_index: 0
                    style: 'images'
                    images: 
                      - default: >
                          [[[
                            {
                              return (entity_config?.entity_picture ||
                                     entity.attributes?.entity_picture || 'none');
                            }
                          ]]]
            ####################################################

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants