HouseOfCards 71 Posted January 2, 2023 Share Posted January 2, 2023 I've been trying to pull in media counts for each library into Home Assistant. I put in this... value_template: '{{ value_json ["MovieCount"] }} It does successfully create a sensor pulled from Emby, but it's totaling the items wrong. I think it's counting all "Video" files as "Movies", so my home video folder and films library go together, etc... This isn't what I need, and I've been breaking my brain looking at this trying to figure this out. https://swagger.emby.media/?staticview=true# Can anyone tell me what modifications to the code above would query a library count from a library called "Feature Films", for example? It would really help me out... Thanks, Steven Link to comment Share on other sites More sharing options...
Cheesegeezer 3087 Posted January 3, 2023 Share Posted January 3, 2023 12 hours ago, WORMUTHS said: I've been trying to pull in media counts for each library into Home Assistant. I put in this... value_template: '{{ value_json ["MovieCount"] }} It does successfully create a sensor pulled from Emby, but it's totaling the items wrong. I think it's counting all "Video" files as "Movies", so my home video folder and films library go together, etc... This isn't what I need, and I've been breaking my brain looking at this trying to figure this out. https://swagger.emby.media/?staticview=true# Can anyone tell me what modifications to the code above would query a library count from a library called "Feature Films", for example? It would really help me out... Thanks, Steven hi there you can set "includeItemTypes" to get what you need - "movie" episode, album, etc http://localhost:8096/emby/Items?Recursive=true&ParentId=5&IncludeItemTypes=movie&api_key={yourAPIKey} An it will then return all the movies in "mymovies" library including the total record count. 1 Link to comment Share on other sites More sharing options...
HouseOfCards 71 Posted January 3, 2023 Author Share Posted January 3, 2023 6 hours ago, Cheesegeezer said: An it will then return all the movies in "mymovies" library including the total record count. I was doing it in config.yaml like this... rest: - resource: http://192.168.2.50:8096/emby/Items/Counts?api_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX method: GET scan_interval: 3600 sensor: - name: "Emby Movie Count" value_template: '{{ value_json ["MovieCount"] }}' - name: "Emby TV Series Count" value_template: '{{ value_json ["SeriesCount"] }}' - name: "Emby TV Episode Count" value_template: '{{ value_json ["EpisodeCount"] }}' - name: "Emby Album Count" value_template: '{{ value_json ["AlbumCount"] }}' - name: "Emby Song Count" value_template: '{{ value_json ["SongCount"] }}' This creates sensors, but they have incorrect counts. I'm hoping to modify this so that it queries by library name. So in other words, we need to modify the value template to specify a library name. We still want the "MovieCount", but we want to specify the library "Feature Films" as the source to query... And "SongCount" from the library "Music Collection", etc... If that makes sense? There's a few of us messing with this here... https://emby.media/community/index.php?/topic/112013-official-emby-home-assitant-integration/ If we could figure this out, it would help a great deal. But we may be doing this all wrong at this point. This was the best we got so far, but the counts are incorrect... Steven Link to comment Share on other sites More sharing options...
samuelqwe 313 Posted January 3, 2023 Share Posted January 3, 2023 6 hours ago, WORMUTHS said: I was doing it in config.yaml like this... You would just have to change the "resource" part of the yaml with the API endpoint Cheese pointed out, then your sensor would point to the "TotalRecordCount" value of the JSON response. 1 Link to comment Share on other sites More sharing options...
HouseOfCards 71 Posted January 4, 2023 Author Share Posted January 4, 2023 11 minutes ago, samuelqwe said: You would just have to change the "resource" part of the yaml with the API endpoint Cheese pointed out, then your sensor would point to the "TotalRecordCount" value of the JSON response. I'll give it a try... Thanks all... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now