maxwroc / battery-state-card

Battery state card for Home Assistant
MIT License
853 stars 38 forks source link

Other sensor state as secondary info #231

Closed pesor closed 2 years ago

pesor commented 3 years ago

I would like the secondary info to show a sensor value.

I have a lot of plant sensors running on batteries, and I would like as secondary value to show the number of days on battery, as this figure compared to the battery level tells the State of the battery.

In my case the sensor in question look like this.

sensor.begonia_1_daysonbattery

which contain the calculated days on battery since last charge.

pesor commented 3 years ago

It could be fine if you could add the secondary-info-card, as it gives HTML editing etc.

tomlut commented 3 years ago

This would be a great addition. iOS devices have the charging state as a second sensor.

maxwroc commented 3 years ago

This would be a great addition. iOS devices have the charging state as a second sensor.

If it is a matter of displaying whether device is charging then you can already do it: https://github.com/maxwroc/battery-state-card#charging-state-object

You can specify the other entity_id and it's state which indicates charging.

Then you follow the example here (second entity) and you can display some text when device is charging: https://github.com/maxwroc/battery-state-card#secondary-info

greendog99 commented 3 years ago

I'm trying to do this too -- have secondary info show a sensor value instead of just plain text -- but am not getting it to work:

entities:
  - entity: sensor.tesla_battery_level
    name: Tesla
    secondary_info: charging
    charging_state:
      entity_id: sensor.tesla_state
      state: charging
      secondary_info_text:
        entity_id: sensor.tesla_time_to_full_charge

This shows the following output:

ss-20210703-111615

So, I can show charging state, but can't show a different entity's value (e.g. "time to full charge") as the secondary text. Maybe I'm doing something, or maybe secondary_info_text only supports hardcoded text, not entities?

maxwroc commented 3 years ago

It is not possible to show the other sensor value as a secondary-info although if you want to show there the custom text which is based on that value it should be possible as per example here: https://github.com/maxwroc/battery-state-card#secondary-info

In your specific case you want to have two indications in the same time (icon and sparate one for secondary-info) which is not possible now.

Here is the example which should work for the secondary info but in the same time you won't be able to show chargin indication (lightning bolt) in the icon :(

type: custom:battery-state-card
entities:
  - entity: sensor.tesla_battery_level
    secondary_info: charging
    charging_state:
      entity_id: sensor.tesla_time_to_full_charge
      state: true
      secondary_info_text: "My Tesla in hungry :(" # override for "Charging" text