circle-sensor-card icon indicating copy to clipboard operation
circle-sensor-card copied to clipboard

[Feature Request] Template value for max

Open clandestine-avocado opened this issue 4 years ago • 1 comments

This card is great, and would be perfect for countdown timers like next_timer for Alexa if we could pass a templated state value into the max field.

For example, if I set a 5 minute timer, I could set an input_text or input_number with the timers initial (and static) value of 5. Then, as the timer value decreases for the whatever entity is set, the card would start as a full circle, and dynamically decease relative to the templated max value. Of course I have no idea how to build these great cards, just an idea - no idea how difficult this would be to implement!

clandestine-avocado avatar Mar 17 '21 21:03 clandestine-avocado

Just as workaround, you can create template sensor which will use whatever data as input.

Create new template sensor with attribute values which can be used to define current / max data, example below are input data from entity sensor.lg_drayer_remain_time and sensor.lg_drayer_initial_time

template:
  - sensor:
      - name: "Custom Drayer Time"
        state: >
          {{ states('sensor.lg_drayer') }}
        attributes:
          remaining_time: >
            {% set mins_hours = states('sensor.lg_drayer_remain_time').split(':') %}
            {% set mins = mins_hours[0] | int * 60 + mins_hours[1] | int %}
            {{ mins }} 
          initial_time: >
            {% set mins_hours = states('sensor.lg_drayer_initial_time').split(':') %}
            {% set mins = mins_hours[0] | int * 60 + mins_hours[1] | int %}
            {{ mins }}

and then assign to

  - entity: sensor.custom_drayer_time
    type: custom:circle-sensor-card
    attribute: remaining_time
    attribute_max: initial_time

salvq avatar Dec 05 '21 22:12 salvq