Hello all, this is my current working integration:
Configuration Code - Expand to see
#Ingenium Pass
- scan_interval: 30
resource: https://gateway.bibliocommons.com/v2/libraries/ottawa/bibs/S26C1082166/availability?locale=en-CA
method: GET
#Elmvale_Acres
sensor:
- unique_id: IngeniumPass_Elmvale_Acres_9
name: IngeniumPass_Elmvale_Acres_9
icon: mdi:card-account-details
json_attributes_path: "$.entities.bibItems.1082166|14|9.availability"
json_attributes:
- "status"
- "circulationType"
- "libraryStatus"
value_template: "{{ state_attr('sensor.IngeniumPass_Elmvale_Acres_9','status') }}"
- unique_id: IngeniumPass_Elmvale_Acres_6
name: IngeniumPass_Elmvale_Acres_6
icon: mdi:card-account-details
json_attributes_path: "$.entities.bibItems.1082166|14|6.availability"
json_attributes:
- "status"
- "circulationType"
- "libraryStatus"
value_template: "{{ state_attr('sensor.IngeniumPass_Elmvale_Acres_6','status') }}"
#St. Laurent
- unique_id: IngeniumPass_StLaurent_5
name: IngeniumPass_StLaurent_5
icon: mdi:card-account-details
json_attributes_path: "$.entities.bibItems.1082166|43|5.availability"
json_attributes:
- "status"
- "circulationType"
- "libraryStatus"
value_template: "{{ state_attr('sensor.IngeniumPass_StLaurent_5','status') }}"
- unique_id: IngeniumPass_StLaurent_4
name: IngeniumPass_StLaurent_4
icon: mdi:card-account-details
json_attributes_path: "$.entities.bibItems.1082166|43|4.availability"
json_attributes:
- "status"
- "circulationType"
- "libraryStatus"
value_template: "{{ state_attr('sensor.IngeniumPass_StLaurent_4','status') }}"
What’s happening here:
My Local library will update JSON file when an item is available per this format <ItemCode> | <LibraryLocationCode> | <ItemCopyID>
as stated in json_attributes_path.
Code details:
Currently i had to hardcode the itemNumber, location, and copy code to extact information if that copy is availabe in that location.
Issue:
As it happens sometimes Library get a new copy or loses its old copy(Lost), they they will get a new book and mark it with new ItemCopyID.
If this happens, I have to redo all my integrations.
Request:
Is there any way we can modify the “json_attributes_path: “$.entities.bibItems.1082166|43|5.availability””
codebit to Look for all availability data in 1082166|43|5, 1082166|43|4, 1082166|43|3, 1082166|43|2, etc…?