Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type: markdown
- title: Bibliotekslån
- content: >-
- {# CHANGE BELOW #}
- {% set headers = ['', 'Titel', 'Type', 'Afleveres'] %}
- {% set trim = 32 %}
- {% set userStr = '### USER (X lån)' %}
- {% set dateStr = 'om X DAYS (DATE)' %}
- {% set dateFormat = '%-d/%-m' %}
- {# PRIVATE #}
- {% set ts_now = now() | as_timestamp %}
- {% set libraryUsers = states.sensor | selectattr('attributes.loans', 'defined') | selectattr('attributes.loans_overdue', 'undefined') | list %}
- {# CARD BEGIN #}
- ---
- {%- for libObj in libraryUsers -%}
- {%- set libAttr = libObj.attributes %}
- {%- set amount = libAttr.loans | length %}
- {%- if amount > 0 %}
- {{ userStr.replace('USER', libAttr.user).replace('X', amount~'') }}
- |{{ headers | join(' | ') }}|
- |--:|:--|:--|--:|
- {%- for loan in libAttr.loans %}
- {%- set days = (loan.expire_date | as_timestamp - ts_now) | timestamp_custom('%-d' ) | int(0) %}
- {%- set returnStr = dateStr.replace('X', days~'' ).replace('DAYS', 'dag'~('e' if days > 1 else '')).replace('DATE', loan.expire_date | as_timestamp | timestamp_custom(dateFormat)) %}
- |{{ loop.index }}|{{ loan.title | truncate(trim, true) }}|{% if loan.type != '' %}({{ loan.type }}){% endif %}|{{ returnStr }}|
- {%- endfor %}
- {% endif %}
- ---
- {% endfor %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement