Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. anchors:
  2. card_base: &card_base
  3. type: custom:button-card
  4. show_name: false
  5. aspect_ratio: 1/1
  6. notification_count_style: &notification_count_style
  7. background-color: >
  8. [[[
  9. function activeCount(entities, active, operator) {
  10. var count = 0;
  11. for ( var entity in entities ) {
  12. if ( states[entities[entity]] ) {
  13. switch (operator) {
  14. case ">":
  15. count += states[entities[entity]].state > active;
  16. case "<":
  17. count += states[entities[entity]].state < active;
  18. break;
  19. default:
  20. count += states[entities[entity]].state === active;
  21. break;
  22. }
  23. }
  24. }
  25.  
  26. return count;
  27. }
  28. var count = activeCount(entity.attributes.entity_id, 'open', '=') + activeCount(entity.attributes.entity_id, 'on', '=') + activeCount(entity.attributes.entity_id, 'playing', '=') + activeCount(entity.attributes.entity_id, 40, '<') + activeCount(entity.attributes.entity_id, 'problem', '=');
  29. if (count > 0)
  30. return "var(--accent-color)";
  31. return "";
  32. ]]]
  33. notification_count_field: &notification_count_field
  34. notification: >
  35. [[[
  36. function activeCount(entities, active, operator) {
  37. var count = 0;
  38. for ( var entity in entities ) {
  39. if ( states[entities[entity]] ) {
  40. switch (operator) {
  41. case ">":
  42. count += states[entities[entity]].state > active;
  43. case "<":
  44. count += states[entities[entity]].state < active;
  45. break;
  46. default:
  47. count += states[entities[entity]].state === active;
  48. break;
  49. }
  50. }
  51. }
  52.  
  53. return count;
  54. }
  55. var count = activeCount(entity.attributes.entity_id, 'open', '=') + activeCount(entity.attributes.entity_id, 'on', '=') + activeCount(entity.attributes.entity_id, 'playing', '=') + activeCount(entity.attributes.entity_id, 40, '<') + activeCount(entity.attributes.entity_id, 'problem', '=');
  56. if (count > 0)
  57. return count;
  58. return "";
  59. ]]]
  60. count_button: &count_button
  61. <<: *card_base
  62. styles:
  63. card:
  64. - padding: 0px
  65. grid:
  66. - position: relative
  67. custom_fields:
  68. notification:
  69. - <<: *notification_count_style
  70. - border-radius: 50%
  71. - position: absolute
  72. - left: 60%
  73. - top: 15%
  74. - height: 20px
  75. - width: 20px
  76. - font-size: 10px
  77. - line-height: 20px
  78. - font-family: Helvetica
  79. custom_fields:
  80. <<: *notification_count_field
  81. title: Home
  82. views:
  83. - path: summary
  84. title: Summary
  85. badges: []
  86. panel: true
  87. cards:
  88. - <<: *count_button # Lights
  89. <<: *standard_button_state
  90. <<: *light_tap_action
  91. entity: group.lights
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement