rianadon / timer-bar-card

A progress bar display for Home Assistant timers
Other
340 stars 15 forks source link

n.fixed.replace is not a function #147

Open Opaque02 opened 2 months ago

Opaque02 commented 2 months ago

Describe the bug I am trying to use a timer with a sensor template entity I've made. The entity is to track the progress of media playing on a media player within HA, and has the following attributes: remaining: 174.864, duration: 183.22, friendly_name: Media Player Progress, with the remaining and duration in seconds

Your card configuration This is my yaml in my config.yaml to make the sensor:

template:
  - sensor:
      - name: Media Player Progress
        state: "{{ states('media_player.tv_google_cast') }}"
        attributes:
          remaining: >
            {% set pos = state_attr('media_player.tv_google_cast', 'media_position') %}
            {% set dur = state_attr('media_player.tv_google_cast', 'media_duration') %}
            {% if pos and dur %}
              {{ dur - pos }}
            {% else %}
              None
            {% endif %}
          duration: "{{ state_attr('media_player.tv_google_cast', 'media_duration') }}"

Here is my yaml in my card I'm trying to use:

type: custom:timer-bar-card
entities:
  - sensor.media_player_progress
state: playing
remain_time:
  attribute: remaining
  units: seconds
duration:
  attribute: duration
  units: seconds
debug: true

Debug information Here is a link to a screenshot of what the card is saying and doing with this code

rianadon commented 2 months ago

You probably meant to use active_state: playing? I should give a proper error message when these properties are mixed up.

Opaque02 commented 2 months ago

That did the trick, thanks! Now I'm getting another error about it being in the wrong format and needing to convert, but that's a different issue I think! Thanks so much!