Giter Site home page Giter Site logo

Comments (7)

Hootie81 avatar Hootie81 commented on July 28, 2024 2

I have found a solution

change

{{ state_attr('sensor.washer', 'remain_time') }}

to

{{ as_timestamp(strptime(state_attr('sensor.washer', 'remain_time'), '%H:%M:%S')) | timestamp_custom('%-H:%M') }}

from lg-washer-dryer-card.

ChrisRomp avatar ChrisRomp commented on July 28, 2024 1

This was my solution, but I think I might like @Hootie81's option better.

    washer_time_display:
       friendly_name: "Washer Time Display"
       value_template: >
         {% if is_state('sensor.washer_run_state', '-') %}
         {% elif is_state('sensor.washer_run_state', 'Standby') %}
           -:--
         {% else %}
           {{ state_attr('sensor.washer', 'remain_time').split(':')[0] + ':' + state_attr('sensor.washer', 'remain_time').split(':')[1] }}
         {% endif %}
    
    dryer_time_display:
       friendly_name: "Dryer Time Display"
       value_template: >
          {% if is_state('sensor.dryer_run_state', '-') %}
          {% elif is_state('sensor.dryer_run_state', 'Standby') %}
            -:--
          {% else %}
            {{ state_attr('sensor.dryer', 'remain_time').split(':')[0] + ':' + state_attr('sensor.dryer', 'remain_time').split(':')[1] }}
          {% endif %}

from lg-washer-dryer-card.

phrz avatar phrz commented on July 28, 2024 1

Hey y'all! I actually got this wrong, I had a tweak on my local version that was not in the repo, but it was getting this timestamp parsing wrong as well—it was stripping the hour, which was misleading when the run time was >1h.

I've changed it to strip the seconds, not the hour. This is also better because it reflects accurately how the time display on my washer/dryer actually looks. No leading zero because the hardware doesn't do that either.

I chose not to do strptime as recommended above, because this is not a time, but a duration, and as shown above, that added timezone complexity etc., because it's not what strptime is meant for.

Basically: it should be fixed now with 6e1bfb1. Let me know if you try it out! I'll keep this open in case anyone comes back on this.

from lg-washer-dryer-card.

ChrisRomp avatar ChrisRomp commented on July 28, 2024

Since my dryer is currently running, can confirm this works:

    dryer_time_display:
       friendly_name: "Dryer Time Display"
       value_template: >
          {% if is_state('sensor.dryer_run_state', '-') %}
          {% elif is_state('sensor.dryer_run_state', 'Standby') %}
            -:--
          {% else %}
            {{ as_timestamp(strptime(state_attr('sensor.dryer', 'remain_time'), '%H:%M:%S')) | timestamp_custom('%-H:%M') }}
          {% endif %}

from lg-washer-dryer-card.

rpanizzon avatar rpanizzon commented on July 28, 2024

To overcome possible issues with timezones I use:

      {{ as_timestamp(strptime(state_attr('sensor.washer', 'remain_time'), '%H:%M:%S')) | timestamp_custom('%H:%M',local=false) }}

from lg-washer-dryer-card.

phrz avatar phrz commented on July 28, 2024

I cannot reproduce this issue (no seconds on my end). Closing but this is useful reference for anyone with this issue. If I can reproduce this, I will modify the configuration to strip seconds.

from lg-washer-dryer-card.

rpanizzon avatar rpanizzon commented on July 28, 2024

from lg-washer-dryer-card.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.