So I’m currently doing this, which I don’t like as it hard codes the entity instead of relying on the ‘entity’ element.
- entity: sensor.christine_battery_level
card_mod:
style: |
:host {
{% set level = states(config.entity) | int %}
{% set charging = is_state("sensor.christine_charging", "charging") %}
I tried {{ state_attr('sensor.christine_battery_level', 'charging') }} in the Developer Template but it returns “none” while it should be returning “charging”.
So, what’s the proper way to get this ‘charging’ attribute knowing the attribute ‘sensor.christine_battery_level’?
I did this but I think it’s an overkill. Yours is much simpler as it doesn’t have to iterates through all the device’s attributes to find the good one.