Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # The below is the YAML for a template sensor
- ###############################################################################
- # Counting lights #
- ###############################################################################
- #The below lists should remain in sync with the chip cards that count the below groupings.
- #Counts lights that are on inside
- - sensor:
- - name: current number of lights on
- state: >
- {% set lights = [
- states.light.living_room_hue,
- states.light.kitchen_light,
- states.light.closet_2,
- states.light.office_light,
- states.light.outdoor_lights,
- states.light.living_room_light,
- states.light.garage_hue,
- states.light.kitchen_fan,
- states.light.kitchen_light,
- states.light.kitchen_hue,
- states.light.living_room_fan,
- states.light.main_bathroom,
- states.light.master_bedroom,
- states.light.master_bedroom_hue,
- states.light.hallway_light_2,
- ]
- %}
- {{ lights | selectattr('state','eq','on') | list | count }} light(s) on
- #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).
- #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.
- #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..
- type: custom:mushroom-chips-card
- chips:
- - type: conditional
- conditions:
- - entity: sensor.current_number_of_lights_on
- state_not: "0"
- chip:
- type: entity
- entity: sensor.current_number_of_lights_on
- icon: mdi:lightbulb
- icon_color: amber
- tap_action:
- action: fire-dom-event
- browser_mod:
- service: browser_mod.popup
- data:
- title: Lights currently on
- content:
- type: entity-filter
- entities:
- - entity: light.living_room_hue
- name: Light name 1
- - entity: light.kitchen_light
- name: Light name 2
- - entity: light.closet_2
- name: Light name 3
- - entity: light.office_light
- name: Light name 4
- - entity: light.outdoor_lights
- name: Light name 5
- - entity: light.living_room_light
- name: Light name 6
- - entity: light.garage_hue
- name: Light name 7
- - entity: light.kitchen_fan
- name: Light name 8
- - entity: light.kitchen_light
- name: Light name 9
- - entity: light.kitchen_hue
- name: Light name 10
- - entity: light.living_room_fan
- name: Light name 11
- - entity: light.main_bathroom
- name: Light name 12
- - entity: light.master_bedroom
- name: Light name 13
- - entity: light.master_bedroom_hue
- name: Light name 14
- - entity: light.hallway_light_2
- name: Light name 15
- state_filter:
- - "on"
- show_header_toggle: false
Advertisement
Add Comment
Please, Sign In to add comment