maxwroc/battery-state-card

Display precision ignored

alexruffell opened this issue · 2 comments

Describe the bug

When I set all my batteries to a default precision of no decimals, the battery percentage in the battery-state-card is still shown with one or 2 decimals. I therefore have to add round: 0 to get rid of them. It mostly appears to affect Zwave battery powered devices but that may just be due to my device mix. If I recall correctly most of my zigbee devices default to no decimals while the zwave ones have 1 or 2 decimals.

How to reproduce

Nothing really as I don't use any advanced settings. Just use an entities card and use type for the battery entity. I do this because I want to format the title and have a section separator for consistent look with all my other cards.

Expected behavior

Follow default precision or have a card wide setting to instruct card to follow it or not if this is by design.

YAML configuration

type: entities
card_mod:
  style: |
    .card-header {
    font-size: 18px;
    padding: 2px 15px 2px 15px
    }
entities:
  - type: section
  - type: custom:battery-state-entity
    entity: sensor.upstairs_bathroom_door_battery
    round: 0
  - type: custom:battery-state-entity
    entity: sensor.upstairs_bathroom_motion_sensor_battery
  - type: custom:battery-state-entity
    entity: sensor.upstairs_bathroom_sensor_battery
    round: 0
  - type: custom:battery-state-entity
    entity: sensor.upstairs_bathroom_toilet_motion_sensor_battery
title: Upstairs Bathroom Batteries
state_color: true

Screenshots

Version

2.1.1

I can confirm this issue...

What exactly do you mean by:

When I set all my batteries to a default precision of no decimals

I don't have repro on my side
image

Please try to use the below code in the UI editor, replace the entity name with the one which exists on your system and paste the screenshot here (similar as mine where the config is visible)

type: entities
show_header_toggle: false
title: Displayed as entity
entities:
  - entity: sensor.upstairs_bathroom_door_battery
  - type: custom:battery-state-entity
    entity: sensor.upstairs_bathroom_door_battery
    round: 0yaml