resoai / TileBoard

A simple yet highly configurable Dashboard for HomeAssistant
MIT License
1.63k stars 278 forks source link

Scripts with same id overwrite background #425

Closed tobycheese closed 4 years ago

tobycheese commented 4 years ago

I have a bunch of tiles that call the same script, as follows:

           {
              position: [0, 0],
              type: TYPES.SCRIPT,
              id: 'script.sonos_wallpanel',
              bg: 'images/radiostations/radioparadise.png',
              variables: {source: 'radioparadise'},
           },
           {
              position: [1, 0],
              type: TYPES.SCRIPT,
              id: 'script.sonos_wallpanel',
              bg: 'images/radiostations/demoscene.png',
              variables: {source: 'demoscene'},
           },

Clicking these launch the script with different variable values, this works as expected. However, both tiles show the same background image radioparadise.png. When changing the id of the second tile, the background is then respected (demoscene.png is shown for the second tile).

akloeckner commented 4 years ago

I believe, the background is cached in the state entity, and not in the tile item. Try changing that line to var obj = item;:

https://github.com/resoai/TileBoard/blob/538d00a40a7418f4058cd3eae795e676a0ade9e6/scripts/controllers/main.js#L415

Now, the question is why this is how it is. I'd suspect it is just a coincidence and most re-appearances of this piece of code could be changed in the way to use item instead of entity.

tobycheese commented 4 years ago

@akloeckner Yes, changing that line fixed the issue, thanks! Will this result in a fix eventually?

rchl commented 4 years ago

Makes sense to change that IMO.

rchl commented 3 years ago

Fix released in https://github.com/resoai/TileBoard/releases/tag/v2.0.2