vincen 71 Posted August 28, 2024 Posted August 28, 2024 Hi I try to get a sensor in my Home-Assistant system (home-automation system) for my emby server. All integrations I have tried either don't report it or are buggy and instable. I'm trying to get that data through the API using a POST or REST request from HA to Emby server. Unhappy I can't find any command in the API documentation that reports that stat from server. Isn't there any direct way to get that data through the API ? or a JSON I could retrieve from Emby server. Thanks Vincèn
hthgihwaymonk 34 Posted August 29, 2024 Posted August 29, 2024 you'll want to do a GET of the /sessions endpoint and look at (count) playstate SWAGGER will help you sort through what you need from playstate 1 1
vincen 71 Posted September 1, 2024 Author Posted September 1, 2024 On 8/29/2024 at 6:03 PM, hthgihwaymonk said: you'll want to do a GET of the /sessions endpoint and look at (count) playstate SWAGGER will help you sort through what you need from playstate Thanks for the indication and I found out how to get datas needed but it's out of my competence to do the count of playstate in Home-Assistant unhappy
LuxTux 16 Posted July 10, 2025 Posted July 10, 2025 I managed to get the active emby sessions into Home Assistant - Create a API key in your emby admin page. - Put the yaml below in your configuration.yaml sensor: - platform: rest name: Emby Active Sessions unique_id: sensor.emby_active_sessions resource: "http://<embyserver>:<port>/emby/Sessions?ActiveWithinSeconds=60&api_key=<APIKEY>" value_template: "{{ value_json | length -1 }}" scan_interval: 30 2
vincen 71 Posted July 11, 2025 Author Posted July 11, 2025 16 hours ago, LuxTux said: I managed to get the active emby sessions into Home Assistant Thanks a lot @LuxTux works perfect
LuxTux 16 Posted July 11, 2025 Posted July 11, 2025 Actually i noticed that this is not reliable it keeps jumping between 1 and 0 every few calls. to fix this i've filtered the api session out of the result. i attempted this with the -1 in the vlaue template but this isnt working great. You will need the name you gave to the api key in emby; be aware its case sensitive. in the example below my api key is called "Home Assistant" sensor: - platform: rest name: Emby Active Sessions unique_id: sensor.emby_active_sessions resource: "http://<embyserver>:<port>/emby/Sessions?ActiveWithinSeconds=60&api_key=<APIKEY>" value_template: "{{ value_json | rejectattr('Client', 'equalto', 'Home Assistant')| list | length }}" scan_interval: 30 1
vincen 71 Posted July 12, 2025 Author Posted July 12, 2025 23 hours ago, LuxTux said: sensor: - platform: rest name: Emby Active Sessions unique_id: sensor.emby_active_sessions resource: "http://<embyserver>:<port>/emby/Sessions?ActiveWithinSeconds=60&api_key=<APIKEY>" value_template: "{{ value_json | rejectattr('Client', 'equalto', 'Home Assistant')| list | length }}" scan_interval: 30 Thanks a lot for the update and I confirm it works a lot better
vincen 71 Posted August 3, 2025 Author Posted August 3, 2025 On 7/12/2025 at 1:21 PM, vincen said: Thanks a lot for the update and I confirm it works a lot better Unhappy I have to correct my previous message, it works as bad as before I think it's still the same issue of ghost sessions in Emby server as it reports often more streams than really are or sometimes report some streams during hours while server is not streaming anything
LuxTux 16 Posted August 19, 2025 Posted August 19, 2025 Weird. any other processes that have api access maybe. e.g. the software that downloads your linux distos looking at the data returned, i noticed that only users that have an actual username and password have the an attribute username in the session info. so you could filter it maybe like this. sensor: - platform: rest name: Emby Active Sessions unique_id: sensor.emby_active_sessions resource: "http://<embyserver>:<port>/emby/Sessions?ActiveWithinSeconds=<LastActivitySecondsAgo>api_key=<APIKEY>" value_template: "{{ value_json | selectattr('UserName', 'defined') | list | length }}" scan_interval: 30 We could also filter on just the sessions that are currently playing or have paused something. that could look like this: sensor: - platform: rest name: Emby Active Sessions unique_id: sensor.emby_active_sessions resource: "http://<embyserver>:<port>/emby/Sessions?api_key=<APIKEY>" value_template: "{{ value_json | selectattr('NowPlayingItem', 'defined') | list | length }}" scan_interval: 30 1
vincen 71 Posted September 1, 2025 Author Posted September 1, 2025 On 8/19/2025 at 5:36 PM, LuxTux said: We could also filter on just the sessions that are currently playing or have paused something. that could look like this: @LuxTuxSorry for late answer and thanks for the suggestion, I'm going to try that one and see if it works better
lundblad 10 Posted October 6, 2025 Posted October 6, 2025 I use the Jellyfin integration (HACS) for my emby server in Home assistant. That gives me a sensor showing active users that works great and insta updates. And it also gives me all my media in home assistant under media tab! Will try the template sensor above now too
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