Open MattFryer opened 9 months ago
Amazing thanks! When I have some time I’ll sit down and take a proper look at this but I’d be keen to add these
I'm excited to start using ABS and this home assistant integration looks great. I haven't read too far into the API documents so I'm not sure what's possible and what's not.
I think it would be really cool if you could call a Service to "Continue playing last audio book on XYZ media player".
On top of that I'm looking forward to using this kind of stuff with Voice commands in home assistant.
Okay folks, I did not know what I was doing so I have basically rewritten the integration from scratch to do it a bit better. I have push v0.1.1-pre which is a pre-release version to add some library sensing stuff.
To actually add dynamically created and removed library sensors was proving too difficult for my small non-pythonic brain so I have opted to add the details in an attribute on the Library sensor instead. I'm still going to clean it up and improve the attributes but this is what it looks like on that release:
The re-implementation does not support adding the integration from the UI (I hope to get to that) so for now it is from configuration.yaml
as follows:
audiobookshelf:
api_url: 'http(s)://<your ip>:<your port>'
api_key: <your key>
scan_interval: <optional refresh speed in seconds defaulting to 300 if not set>
Y'all are welcome to give it a go and let me know if there are any major problems but no stress if not. I'll post here again when I have something more complete.
Hi, Firstly, great work!
I thought I'd share the details of some other AudioBookShelf sensors I've added to HA as rest sensors, in case you wanted to add them to this integration also. Some of which I have found really useful, especial being able to track when a new podcast episode is available and when the size of my podcasts is getting too big and I should think about pruning them.
Using the api path
http(s)://[URL]/api/libraries/[LIBRARY_ID]/stats
gets you stats on a library as detailed below.The [LIBRARY_ID] is in the format "abcdef12-4567-890a-bcdef1234567". I originally found it by taking it from the URL when viewing the library in the AudioBookShelf UI so you could get users to add them as part of the config flow but ideally you can list them from the API using
http(s)://[URL]/api/libraries
which would obviously be better.Audiobooks Number of books -
value_json.totalItems
Number of authors -value_json.totalAuthors
Total Duration (hours) -( value_json.totalDuration / 60 / 60 ) | round(0)
Total Size (GB) -( value_json.totalSize / 1024 / 1024 / 1024 ) | round(2)
Podcasts Number of podcasts (not episodes) -
value_json.totalItems
Number of podcast episodes -value_json.numAudioTracks
Total Duration (hours) -( value_json.totalDuration / 60 / 60 ) | round(0)
Total Size (GB) -( value_json.totalSize / 1024 / 1024 / 1024 ) | round(2)
Hope that's useful! Matt