maxwroc / battery-state-card

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

tap_action: support KString in navigation_path #724

Open flxtr opened 4 months ago

flxtr commented 4 months ago

Is your feature request related to a problem? Please describe.

I use HA-Battery-Notes to add Battery related meta data to my devices. It adds a sensor.*_battery_plus for battery powered devices among other things. I'm already showing some of this meta data as secondary info in the battery_state_card, which works really nice, thanks.

Another feature of Battery notes: in the device config, I can see a tapable Entity in the Diagnosis panel, to set replacement date to now. That's why I want configure a tap_action that navigates me to the device config. I tried to configure navigation_path: /config/devices/device/{attributes.device_id}, but KString is't supported and therefore device_id won't be replaced.

Describe the solution you'd like I'd like tap_action.navigation_path to support placeholders, so I can configure things like this:

tap_action:
  action: navigate
  navigation_path: /config/devices/device/{attributes.device_id}

Additional context My config (incl. currently broken placehodler navigation):

type: custom:battery-state-card
secondary_info: >-
  {attributes.battery_type_and_quantity} 🔃
  {attributes.battery_last_replaced|reltime()|equals(null, nie)}
filter:
  include:
    - name: entity_id
      value: '*_battery_plus'
  exclude:
    - name: entity_id
      value: binary_sensor.*
sort:
  by: state
collapse: 8
bulk_rename:
  - from: ' Battery'
  - from: ' level'
colors:
  steps:
    - '#ff0000'
    - '#ffff00'
    - '#00ff00'
  gradient: true
tap_action:
  action: navigate
  navigation_path: /config/devices/device/{attributes.device_id}

Battery replaced tapable in device config: Screenshot_20240427-131827~2