battery-state-card
battery-state-card copied to clipboard
Great card but state_map not working for my binary sensors
Describe the bug
When I add my binary sensors (for instance binary_sensor.front_door_keypad_battery
), the state_map
config does not map the on/off values to 100/0% as desired.
How to reproduce See config below. Note that these sensors are reported as "?" rather than 100/0. See the screenshot.
I tried various "from" states: plain off/on, 0/1, "off"/"on", "Off"/"On"... nothing triggers. From the debug state it looks like "off" should work.
Expected behavior Batteries should show up as 100% or 0% according to off/on state of sensor.
YAML configuration
type: custom:battery-state-card
secondary_info: "{last_changed}"
filter:
include:
- name: "attributes.device_class"
value: "battery"
state_map:
- from:"off"
to:100
- from:"on"
to:0
sort:
by: "state"
collapse: 8
debug: false
bulk_rename:
- from: " Battery"
- from: " level"
colors:
steps:
- '#ff0000'
- '#ffff00'
- '#00ff00'
gradient: true
Entity debug data
{
"entity_id": "binary_sensor.front_door_keypad_battery",
"state": "off",
"attributes": {
"last_event_info": "System Armed (Home) by Keypad Front Door",
"last_event_sensor_name": "Front Door",
"last_event_sensor_type": "keypad",
"last_event_timestamp": 1712286222,
"system_id": 4882848,
"device_class": "battery",
"friendly_name": "Front door Keypad Battery"
},
"context": {
"id": "01HTQ88GVEPDKSMCT2EQCA6W",
"parent_id": null,
"user_id": null
},
"last_changed": "2024-04-05T13:48:07.406Z",
"last_updated": "2024-04-05T13:48:07.406Z",
"display": {
"entity_id": "binary_sensor.front_door_keypad_battery",
"device_id": "f127976adf9908bbf0c09dbfdde1",
"labels": [],
"platform": "simplisafe",
"entity_category": "diagnostic",
"name": "Battery"
},
"device": {
"area_id": "front_door",
"configuration_url": "https://webapp.simplisafe.com/new/#/dashboard",
"config_entries": [
"d914ea1cffb145d19f4ea9147eff"
],
"connections": [],
"disabled_by": null,
"entry_type": null,
"hw_version": null,
"id": "f127976adf9908bbf0c09dbfdde1",
"identifiers": [
[
"simplisafe",
"017fdxxx"
]
],
"labels": [],
"manufacturer": "SimpliSafe",
"model": "Keypad",
"name_by_user": null,
"name": "Front door Keypad",
"serial_number": null,
"sw_version": null,
"via_device_id": "1fbe8255b22b13d2511792a7f5eb"
},
"area": {
"aliases": [],
"area_id": "front_door",
"floor_id": "main_floor",
"icon": null,
"labels": [],
"name": "Front Door",
"picture": null
}
}
Dev console errors None
Screenshots
Version Latest, 3.2.1
Hi Gary, can you please check if adding default_state_formatting: false
to your config (at the root level) fixes anything and let me know?
Sorry, doesn't seem to change anything:
Having the exact same issue.