Monster card - battery level (template sensor)

I have template sensors for all my Xiaomi devices which pull in the battery level so I can keep an eye on it in the frontend.
Capture
The issue I’m having is, I’m trying to make a monster card that only displays the devices with less than a certain percentage battery. I can’t seem to work out how to use the state filter on these template sensors. Hoping someone can help?

  - type: custom:monster-card
    show_empty: false
    card:
      type: glance
      title: Batteries
    filter:
      include:
        - entity_id: sensor.*_bat
          attributes:
            state: '< 40'

All the devices show if i remove the attribute code

Removing the “attributes:” line and unindenting “state: ‘< 40’” should work

2 Likes

Thanks for your help - all working as expected now.

image

Happy to help :slight_smile:

How did you get those bat sensors?
I’m looking to do almost the same with my xiaomi motion sensors and switches + cubes except I’d like to show all battery levels regardless of %
How would I go about this?

+1, I’d also want that!

NotoriousBDG, wrote a wonderful script:

1 Like

does this script still work? I just need copy the .py file in custom_components?

Just use the auto-entities card like below, and for alerts just use a template in an automation to check for low batteries.

There is no need to clutter your system up with a template sensor for each battery device as you can work right off the attributes…

  - type: custom:auto-entities
    show_empty: false
    card:
      type: custom:bar-card
      attribute: battery_level
      unit_of_measurement: "%"
      padding: 2px
      severity:
        - value: 60
          hue: "0"
        - value: 80
          hue: "40"
        - value: 100
          hue: "120"
      title_position: inside

    filter:
      include:
        - domain: zwave
          attributes:
            battery_level: "<= 100"

Yest it works well, you should copy script .py to packages folder (create it if don’t have)
In the begining of the script is a short manual with explanation how to use it.

I’m sorry, I used same code, but battery level of xiaomi door sensor not display

- title: BATTERY
    background: var(--background-image)
    icon: mdi:battery
    cards:
      - type: glance
        title: Bedroom
        entities:
          - binary_sensor.door_window_sensor_158d0002e2e117
      - type: custom:monster-card
        show_empty: false
        card:
          type: glance
          title: Batteries
        filter:
          include:
            - entity_id: binary_sensor.door_window_sensor_158d0002e2e117
              state: '< 100'


Does I miss something?