caffeinated00

main_button_coloring

Jun 18th, 2025
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. main_button_coloring:
  2. name: Main button unified ON color
  3. version: v1.5
  4. creator: You 😎
  5. link: https://github.com/Clooos/Bubble-Card/discussions
  6. supported:
  7. - button
  8. - calendar
  9. - climate
  10. - cover
  11. - horizontal-buttons-stack
  12. - media-player
  13. - pop-up
  14. - select
  15. - separator
  16. description: |
  17. Applies a single color to both the main button background and icon when the entity state is 'on'. Resets styles when not 'on'.
  18. code: |
  19. ${(() => {
  20. const cfg = this.config.main_button_coloring || {};
  21. const entityId = cfg.entity;
  22. const entity = hass.states[entityId];
  23. const state = entity?.state;
  24.  
  25. const btn = card.querySelector('.bubble-button-background');
  26. const icon = card.querySelector('.bubble-icon');
  27.  
  28. if (state === 'on') {
  29. if (btn) btn.style.backgroundColor = cfg.on_color;
  30. if (icon) icon.style.color = cfg.on_color;
  31. } else {
  32. if (btn) btn.style.backgroundColor = '';
  33. if (icon) icon.style.color = '';
  34. }
  35. })()}
  36. editor:
  37. - name: entity
  38. selector:
  39. entity: {}
  40. - name: on_color
  41. label: ON color for background & icon
  42. selector:
  43. text: {}
  44.  
Advertisement
Add Comment
Please, Sign In to add comment