Install the integration either manually or via HACS by adding this repo as a custom repo Add the Danske Biblioteker integration by following the config flow in settings/integrations in your Home Assistant instance Login to your library account with you username and password
After installing from hacs, setup can be started from this link:
lovelace-auto-entities
lovelace-template-entity-row
Reservations available for pickup:
type: custom:auto-entities
card:
type: entities
title: Bøger klar til afhentning
filter:
template: >-
{% set data = namespace(books=[]) %} {% for sensor in states.sensor %}
{% if 'type' in sensor.attributes.keys() and sensor.attributes.type == 'library_reservation' and sensor.attributes.data|length > 0 %}
{% set data.books = data.books + sensor.attributes.data %}
{% endif %}
{% endfor %}
{% set BOOKS = data.books %}
{% set READY_FOR_PICKUP = BOOKS|rejectattr('pickup_deadline','none') %} {%-
for book in READY_FOR_PICKUP|sort(attribute='days_left_for_pickup') -%}
{%- set IMAGE = book.image_url -%}
{%- set AUTHOR = book.author -%}
{%- set STATE = 'Afhent senest: ' ~ book.pickup_deadline if book.pickup_deadline else book.number_in_queue -%}
{{
{
'type': 'custom:template-entity-row',
'state': STATE,
'name': book.title|truncate(67,true,'…'),
'secondary': AUTHOR,
'icon': 'mdi:book-open-page-variant',
'image': IMAGE,
}
}},
{%- endfor %}
sort:
reverse: false
Reservered items:
type: custom:auto-entities
card:
type: entities
title: Reserverede biblioteksbøger
filter:
template: |-
{% set data = namespace(books=[]) %} {% for sensor in states.sensor %}
{% if 'type' in sensor.attributes.keys() and sensor.attributes.type == 'library_reservation' and sensor.attributes.data|length > 0 %}
{% set data.books = data.books + sensor.attributes.data %}
{% endif %}
{% endfor %}
{% set BOOKS = data.books %}
{% set IN_QUEUE = BOOKS|selectattr('pickup_deadline','none') %}
{%- for book in IN_QUEUE|sort(attribute='days_left_for_pickup') -%}
{%- set IMAGE = book.image_url -%}
{%- set AUTHOR = book.author -%}
{%- set STATE = 'Afhent senest: ' ~ book.pickup_deadline if book.pickup_deadline else book.number_in_queue -%}
{{
{
'type': 'custom:template-entity-row',
'state': STATE,
'name': book.title|truncate(67,true,'…'),
'secondary': AUTHOR,
'icon': 'mdi:book-open-page-variant',
'image': IMAGE,
}
}},
{%- endfor %}
sort:
reverse: false
Loaned items:
type: custom:auto-entities
card:
type: entities
title: Lånte biblioteksbøger
filter:
template: |-
{% set data = namespace(books=[]) %}
{% for sensor in states.sensor %}
{% if 'type' in sensor.attributes.keys() and sensor.attributes.type == 'library_loan' and sensor.attributes.data|length > 0 %}
{% set data.books = data.books + sensor.attributes.data %}
{% endif %}
{% endfor %}
{% set BOOKS = data.books|list %}
{%- for book in BOOKS|sort(attribute='due_date') -%}
{%- set DUEDATE = as_datetime(book.due_date) -%}
{%- set IMAGE = book.image_url -%}
{%- set AUTHOR = book.author -%}
{{
{
'type': 'custom:template-entity-row',
'state': time_until(DUEDATE),
'name': book.title|truncate(67,true,'…'),
'secondary': AUTHOR,
'icon': 'mdi:book-open-page-variant',
'image': IMAGE,
}
}},
{%- endfor %}
sort:
reverse: false
Card ideas and template by Reddit user u/AnAmbushOfTigers