Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n.fixed.replace is not a function #147

Open
Opaque02 opened this issue Apr 25, 2024 · 2 comments
Open

n.fixed.replace is not a function #147

Opaque02 opened this issue Apr 25, 2024 · 2 comments

Comments

@Opaque02
Copy link

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
Copy link
Owner

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

@Opaque02
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants