Skip to content

Home Assistant Integration to show current loans and reservations from danish libraries

License

Notifications You must be signed in to change notification settings

PTST/DanskeBiblioteker-HomeAssistant

Repository files navigation

DanskeBiblioteker-HomeAssistant

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:

Spported libraries:

  • Albertslund
  • Allerød
  • Ballerup
  • Billund
  • Bornholm
  • Brøndby
  • Brønderslev
  • Býarbókasavnið
  • DBC bibliotek (100450)
  • DBC Testbibliotek
  • Dragør
  • Egedal
  • Esbjerg
  • Favrskov
  • Faxe
  • Fredensborg
  • Fredericia
  • Frederiksberg
  • Frederikshavn
  • Frederikssund
  • Furesø
  • Faaborg-Midtfyn Bibliotekerne
  • Gentofte
  • Gladsaxe
  • Glostrup
  • Greve
  • Gribskov
  • Guldborgsund
  • Haderslev
  • Halsnæs
  • Hedensted
  • Helsingør
  • Herlev
  • Herning
  • Hillerød
  • Hjørring
  • Holbæk
  • Holstebro
  • Horsens
  • Hvidovre
  • Høje-Taastrup
  • Hørsholm
  • Ikast-Brande
  • Ishøj
  • Jammerbugt
  • Kalundborg Biblioteker
  • Kalaallit Nunaat
  • Kerteminde
  • Kolding
  • København
  • Køge
  • Lejre Bibliotek & Arkiv
  • Lemvig
  • Lolland
  • Lyngby-Taarbæk
  • Læsø
  • Mariagerfjord
  • Middelfart
  • Morsø
  • Norddjurs Biblioteker
  • Nyborg
  • Næstved
  • Odder
  • Odsherred
  • Randers
  • Rebild
  • Ringkøbing-Skjern
  • Ringsted
  • Roskilde
  • Rudersdal
  • Rødovre
  • Samsø
  • Silkeborg
  • Skanderborg
  • Skive
  • Slagelse
  • Solrød
  • Sorø
  • Stevns
  • Struer
  • Syddjurs
  • Sydslesvig
  • Sønderborg
  • Thisted
  • Tønder
  • Tårnby
  • Vallensbæk
  • Varde
  • Vejen
  • Vejle
  • Vesthimmerlands
  • Viborg
  • Vordingborg
  • Ærø
  • Aabenraa
  • Aalborg
  • Aarhus

Example cards

Requirements:

lovelace-auto-entities
lovelace-template-entity-row

Reservations available for pickup:
image

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:
image

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:
image

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

About

Home Assistant Integration to show current loans and reservations from danish libraries

Topics

Resources

License

Stars

Watchers

Forks

Languages