Splicing1524

Displaying lights that are on in a chip card and when selected expands on the details in a pop-up

Dec 24th, 2024 (edited)
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.88 KB | Software | 0 0
  1. # The below is the YAML for a template sensor
  2.  
  3. ###############################################################################
  4. # Counting lights                                         #
  5. ###############################################################################
  6. #The below lists should remain in sync with the chip cards that count the below groupings.
  7. #Counts lights that are on inside
  8.   - sensor:
  9.     - name: current number of lights on
  10.       state: >
  11.        {% set lights = [
  12.            states.light.living_room_hue,
  13.            states.light.kitchen_light,
  14.            states.light.closet_2,
  15.            states.light.office_light,
  16.            states.light.outdoor_lights,
  17.            states.light.living_room_light,
  18.            states.light.garage_hue,
  19.            states.light.kitchen_fan,
  20.            states.light.kitchen_light,
  21.            states.light.kitchen_hue,
  22.            states.light.living_room_fan,
  23.            states.light.main_bathroom,
  24.            states.light.master_bedroom,
  25.            states.light.master_bedroom_hue,
  26.            states.light.hallway_light_2,
  27.            ]
  28.         %}
  29.         {{ lights | selectattr('state','eq','on') | list | count }} light(s) on
  30.  
  31.  
  32. #The below is the YAML used in a conditional mushroom chip card with browser mod to display the lights in a popup. This is used within the actual UI. I assume a badge would be very similar (or the same as the custom badge).
  33. #The below method allows you to easily change the display name of each light. If you want to keep the same name as the entity, then you can definitely remove the name line for each light.
  34. #Another tip, if you are only using the above and below for all lights and do not care about updating the light name in the UI, then I'd suggest checking out auto-entities in HACS. That way you won't need to update both the template sensor details above and yaml for the UI below. I personally didn't go this route and just duplicated the above and below code for both my indoor and outdoor lights, robot vacuums, humidifiers, fans, etc..
  35.  
  36. type: custom:mushroom-chips-card
  37. chips:
  38.   - type: conditional
  39.     conditions:
  40.       - entity: sensor.current_number_of_lights_on
  41.         state_not: "0"
  42.     chip:
  43.       type: entity
  44.       entity: sensor.current_number_of_lights_on
  45.       icon: mdi:lightbulb
  46.       icon_color: amber
  47.       tap_action:
  48.         action: fire-dom-event
  49.         browser_mod:
  50.           service: browser_mod.popup
  51.           data:
  52.             title: Lights currently on
  53.             content:
  54.               type: entity-filter
  55.               entities:
  56.                 - entity: light.living_room_hue
  57.                   name: Light name 1
  58.                 - entity: light.kitchen_light
  59.                   name: Light name 2
  60.                 - entity: light.closet_2
  61.                   name: Light name 3
  62.                 - entity: light.office_light
  63.                   name: Light name 4
  64.                 - entity: light.outdoor_lights
  65.                   name: Light name 5
  66.                 - entity: light.living_room_light
  67.                   name: Light name 6
  68.                 - entity: light.garage_hue
  69.                   name: Light name 7
  70.                 - entity: light.kitchen_fan
  71.                   name: Light name 8
  72.                 - entity: light.kitchen_light
  73.                   name: Light name 9
  74.                 - entity: light.kitchen_hue
  75.                   name: Light name 10
  76.                 - entity: light.living_room_fan
  77.                   name: Light name 11
  78.                 - entity: light.main_bathroom
  79.                   name: Light name 12
  80.                 - entity: light.master_bedroom
  81.                   name: Light name 13
  82.                 - entity: light.master_bedroom_hue
  83.                   name: Light name 14
  84.                 - entity: light.hallway_light_2
  85.                   name: Light name 15
  86.               state_filter:
  87.                - "on"
  88.               show_header_toggle: false
Advertisement
Add Comment
Please, Sign In to add comment