rianadon / timer-bar-card

A progress bar display for Home Assistant timers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

n.fixed.replace is not a function

Opaque02 opened this issue · comments

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

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

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!