GithubHelp home page GithubHelp logo

Comments (3)

AitorDB avatar AitorDB commented on May 29, 2024 1

Thank you so much! Sadly the code in this card it's a bit different to what you would usually do with yaml, but good to see other solutions the community is using!

from home-assistant-sun-card.

ChristophHoltmann avatar ChristophHoltmann commented on May 29, 2024

I really like your sun-card.

Here is some code I found/wrote some time ago with the help of the community. Maybe it could help you:

# Sunrise/set
time_to_sun_rise_set:
  friendly_name: Sunrise/set remaining time phrase
  value_template: >-
    {% set rise_set = state_attr('sun.sun', 'next_rising') 
      if is_state('sun.sun', 'below_horizon') 
      else state_attr('sun.sun', 'next_setting') 
    %}
    {% set rise_set_time = as_timestamp(rise_set) - now().timestamp() 
      if rise_set != None
      else None
    %}

    {%- macro get_time_string(tstring, number) %}
      {%- if number > 0 %}
      {%- set ret = '{} {} ' if number == 1 else '{} {}s ' %}
        {{- ret.format(number, tstring) }}
      {%- else %}
        {{- '' }}
      {%- endif %}
    {%- endmacro %}
    {%- macro get_phrase(time) %}
      {%- if time != None %}
        {%- set minutes = get_time_string('minute', ((time % 3600) / 60) | int ) %}
        {%- set hours = get_time_string('hour', ((time % 86400) / 3600) | int ) %}
        {%- set days = get_time_string('day', (time / 86400) | int ) %}
        {%- set ret = days + hours + minutes %}
        {{- ret.strip() }}
      {%- endif %}
    {%- endmacro %}

    {{ get_phrase(rise_set_time) }}

from home-assistant-sun-card.

AitorDB avatar AitorDB commented on May 29, 2024

Currently on progress here #36

from home-assistant-sun-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.