maxwroc/battery-state-card

Combining Color Gradient & Charging Status

JAudi23 opened this issue · 5 comments

Describe what is wrong
I just started playing with this today, and have successfully used the color gradient card, and then I was able to add the sort option.
I tried to also include the charging_state code, however the card does not seem to recognize it.
Is this possible, or is my code incorrect somewhere?

YAML configuration

type: custom:battery-state-card
title: Device Battery Levels
sort: state
charging_state:
  attribute:
    - name: Battery State
      value: Charging
    - name: is_charging
      value: true
  state:
    - charging
    - Charging
colors:
  steps:
    - '#ff0000'
    - '#ffff00'
    - '#00ff00'
  gradient: true
entities:
  - entity: sensor.front_door_battery
    name: Front Door Lock
  - entity: sensor.interior_garage_door_battery
    name: Interior Garage Door Lock
  - entity: sensor.roomba_battery
    name: Roomba Vacuum
  - entity: sensor.nest_temperature_sensor_daughter_s_bedroom_battery_level
    name: Daughter's Room Temperature Sensor
  - entity: sensor.nest_temperature_sensor_son_s_bedroom_battery_level
    name: Son's Room Temperature Sensor
  - entity: sensor.nest_temperature_sensor_master_bedroom_battery_level
    name: Master Bedroom Temperature Sensor
  - entity: sensor.water_level_sensor_battery_level
    name: Sump Pit Water Level Sensor
  - entity: device_tracker.daughter
    name: Daughter's iPhone
  - entity: device_tracker.son
    name: Son's iPhone
  - entity: device_tracker.spouse
    name: Spouse's iPhone
  - entity: device_tracker.mine
    name: My Samsung Galaxy S22 Ultra

Screenshot

image

Version

v3.0.1

If you don't have any non-standard devices then the charging state should be working out of the box. In other words you don't need to have charging_state in your config.

In case of some non standard devices which expose charging state with non standard way or you want to customize how the state is being shown then yes - you need to add such section int he config.

First of all to help you I would need to see how does your entity data look like. You can find it in the HA developer tools > states. Please paste here the entity data showing how is the charging state exposed by your device. Sometimes it is exposed as an attribute of the main entity but sometimes as a separate entity.

When I use my device_tracker.jeff entity, I see only the colored battery and percentage.

image

When I use the sensor.sm_s908w_battery_state entity, I see this unknown battery icon.

image

However, when I click into the entity for battery state I see this icon with a minus symbol.

image

Here is the developer tools > state information for this entity.

image

Let me know if that helps?

Don't you have something like sensor.sm_s908w_battery_level? If you do have it then this one should be used in the card and then the charging state will be fetched automatically (when charging_state is not manually configured).

Card tries automatically to get the charging state from xxx_battery_state if the entity added to the card is like xxx_battery_level.

I assume you get this via companion app. If the xxx_battery_level is missing please expose this entity in the app settings

That did it, thanks!
I guess I was assuming any entity that sees battery level (%) would be able to use the charging state icons if it was increasing charge %.
In other words, I thought the device_tracker.jeff entity would be able to co-relate to the battery entities and show the charge state.

image

image

There is no pattern in entity name which we could use to locate the relevant battery state (in other words how could we know that the battery state for device_tracker.jeff entity is the sensor.sm_s908w_battery_state? It is impossible to match these two together)

I'm glad that you have sorted this out. Closing