Advertisement
JLindvig

Bibliotek_card

Feb 27th, 2023 (edited)
733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.10 KB | None | 0 0
  1. type: markdown
  2. title: Bibliotekslån
  3. content: >-
  4.   {% set library = 'sensor.faaborg_midtfyn_bibliotekerne_jacob_lindvig_henriksen' %}
  5.   {% set user_loans = 'sensor.bibliotekslan_jacob_lindvig_henriksen' %}
  6.   {% set chars = 32 %}
  7.   {% set img_size = 64 %}
  8.   {% set days_to_return = states(library) | int(0) %}
  9.  
  10.   {% set alert = 'success' %} {% if days_to_return <= 2 %}
  11.     {% set alert = 'error' %}
  12.   {% elif days_to_return <= 7 %}
  13.     {% set alert = 'warning' %}
  14.   {% elif days_to_return <= 14 %}
  15.     {% set alert = 'warning' %}
  16.   {% endif %}
  17.  
  18.   <ha-alert alert-type="{{alert}}">Du har <b>{{state_attr(library, 'loans')}}
  19.   bøger</b>, der skal afleveres på {{state_attr(library, 'pickup_library')}} om
  20.   <b>{{ days_to_return }} dage!</b>
  21.   | Cover | Titel | Dato |
  22.   | :---  | :---  | ----:|
  23.  
  24.   | {% for loan in state_attr(user_loans, 'loans') %}
  25.     {% if loan.cover != "" %}<img src="{{loan.cover}}" width="{{img_size}}" height="{{img_size}}"></img>{% else %}<br/>{% endif %}|{{loan.title|truncate(chars,True)}}|{{ loan.expire_date | as_timestamp | timestamp_custom("%d/%m")}}{%- endfor %}|
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement