vortex
October 5, 2018, 12:56pm
1
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.
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
poebae
October 5, 2018, 1:08pm
2
Removing the “attributes:” line and unindenting “state: ‘< 40’” should work
2 Likes
vortex
October 5, 2018, 1:22pm
3
Thanks for your help - all working as expected now.
Daaf24
(Dave Appelman)
February 7, 2019, 6:37am
5
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?
Grzech
(Grzech)
March 10, 2019, 9:52am
7
NotoriousBDG, wrote a wonderful script:
Edit May 14th, 2019: The latest code and instructions are available on GitHub at:
Original post:
I have many battery powered devices that have various methods to track battery level. Some of my devices have a separate entity that just represents battery while most of them have a battery_level attribute. To make it even more complex, I have some devices that report an 0-100 integer and others that use strings (Low, Medium, Full, etc.).
I’ve been wanting a way to identify any batteries that…
1 Like
ward0
March 22, 2019, 12:50pm
8
does this script still work? I just need copy the .py file in custom_components?
jwelter
(John Welter)
March 22, 2019, 12:57pm
9
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"
Grzech
(Grzech)
March 22, 2019, 2:51pm
10
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.
kazihaha
(Kazihaha)
October 18, 2019, 12:02pm
11
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?