Jump to content

Official emby home assistant integration


skank

Recommended Posts

Junglejim
On 02/01/2023 at 10:52, seanbuff said:

I had a quick play with this, and while it's not part of the default integration. You can still pull that data using a rest sensor in HA that consumes the LibraryService endpoint of your Emby Servers API.

The code would look something like this:

# Emby Media Counts
rest:
  - resource: http://<Emby IP>:8096/emby/Items/Counts?api_key=<Your_API_Key>
    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"] }}'    


Once you have the individual sensors, the output in the UI would be:

image.png.813a5d8c41bb6de07da0eedd2ab42667.png


I currently have mine polling Emby every hour, so I imagine after some amount of time I'll have enough data to populate a graph to visualize this over a longer time-frame.
(just as an example)
image.png.a631ed1d36a54a93c76151d902fd1131.png

Hi @seanbuff, thanks for the sensors code. My TV Shows/Episodes numbers are spot on, Movies are +9 but I think that's due to the Top-Picks plugin (I can live with that)..

Screenshot_2023-01-20_20-55-55.png.d5676f331304fefcdf63921c0ab39151.png

My question is what card/code are you using to display the sensor info? I'd like to add this to my Emby dashboard. :)

image.png.813a5d8c41bb6de07da0eedd2ab42667.png.30be9c59d127f88916b0e5babf65ec4b.png

Still a noob with this at the mo but I can't seem to get the card like this. :)

Edit: Got it sorted with some digging around in the add cards section. Thanks for the sensors code! I like to have a go with Home Assistant every few weeks, there is so much to learn with this app and the possibilities are endless. 👍

Screenshot_2023-01-20_21-57-11.png.936b7a3c7fe159899a6fe6a70b8fe4ca.png

 

Edited by Junglejim
  • Like 1
Link to comment
Share on other sites

Junglejim

Ok this is me done for a couple of weeks. :)  Got my Emby dash to a nice level..

Screenshot_2023-01-21_17-11-56.thumb.png.c38b35c0aca058954b8de928eb8979ed.png

Could not get the template code working for active users but that's for another day (just have a workaround from the overview at the mo). ;)

  • Like 5
Link to comment
Share on other sites

seanbuff
5 minutes ago, Junglejim said:

Got my Emby dash to a nice level..

Looks good mate, well done.

  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...
On 1/21/2023 at 7:51 AM, Junglejim said:

Ok this is me done for a couple of weeks. :)  Got my Emby dash to a nice level..

Screenshot_2023-01-21_17-11-56.thumb.png.c38b35c0aca058954b8de928eb8979ed.png

Could not get the template code working for active users but that's for another day (just have a workaround from the overview at the mo). ;)

ok im gonna try this as well 

+ automations to dim lights (got that now)
+ automation through push notification in HA when media is added (and what media) , anyone have an automation for this yet?

  • Like 1
Link to comment
Share on other sites

Junglejim
16 hours ago, skank said:

ok im gonna try this as well 

+ automations to dim lights (got that now)
+ automation through push notification in HA when media is added (and what media) , anyone have an automation for this yet?

Yeah mate give it a go, I haven't got to automation's yet but I have my Lifx light's all setup and ready to go.

Link to comment
Share on other sites

On 1/1/2023 at 10:45 PM, Spaceboy said:

ok - nice. spent some time on this and have it all implemented. starting to get the hang of yaml a bit more and using custome components.

as i was reading on templates i noticed that apparently you are using the old style format. if you are interested (not sure its needed yet) the new style to get the same as what you have is

# Active Emby Users
template:

    - sensor:
    - name: "emby_users_watching"
      state:
        "{{ states.media_player
           |  selectattr ( 'state' , 'eq' , 'playing' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.living_room_tv' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.bedroom_speaker_2' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.unnamed_room' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.bathroom' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.bedroom' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.living_room' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.sonos_roam' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.shield' )
          |  rejectattr ( 'entity_id' ,  'eq' ,  'media_player.mogo_pro' )
          |  list
           |  count
         }}"

and my emby page looks like this

image.thumb.png.56a1250588f3c10771f290e9011a6932.png

one odd thing i notice is that when using the mini media player card for the playing devices it doesnt fit properly into the wrapper card. not sure why that is or its not evident from your pics. perhaps the theme you are using doesnt have that problem - i havent looked at themes at all other than to make it dark.

i'm also using the emby integration in a couple of automations, nothing different than what has already been described here tbh. i have an automation that checks if the sun has gone down and if so dims my living room lights when i'm playing anything on the living room tv. And toggles adaptive lighting back on when it stops.

would also be interested to hear from others on how they are using the emby integration. i'm happy to be "inspired" by other people :D

I'm stuck with your template code, it contains some spaces so i cant copy it.

Anyone have correct code?
The one i'm using now that aint working is:

[code]

# Active Emby Users
template:
  - sensor:
  - name: "emby_users_watching"
    state:
     "{{ states.media_player
       | selectattr('state', 'eq', 'playing' )
       | rejectattr('entity_id', 'eq', 'media_player.badkamer' )
       | rejectattr('entity_id', 'eq', 'media_player.bureau' )
       | rejectattr('entity_id', 'eq', 'media_player.keuken' )
       | rejectattr('entity_id', 'eq', 'media_player.woonkamer_mini' )
       | rejectattr('entity_id', 'eq', 'media_player.living_tv' )
       | list
       | count
     }}"

[/code]

Link to comment
Share on other sites

Junglejim
14 minutes ago, skank said:

I'm stuck with your template code, it contains some spaces so i cant copy it.

Anyone have correct code?
The one i'm using now that aint working is:

[code]

# Active Emby Users
template:
  - sensor:
  - name: "emby_users_watching"
    state:
     "{{ states.media_player
       | selectattr('state', 'eq', 'playing' )
       | rejectattr('entity_id', 'eq', 'media_player.badkamer' )
       | rejectattr('entity_id', 'eq', 'media_player.bureau' )
       | rejectattr('entity_id', 'eq', 'media_player.keuken' )
       | rejectattr('entity_id', 'eq', 'media_player.woonkamer_mini' )
       | rejectattr('entity_id', 'eq', 'media_player.living_tv' )
       | list
       | count
     }}"

[/code]

Yea I tried to copy & paste that code but it always threw a syntax error. Will give it another go at some point. ;)

I haven't touched automation's yet but plan to in the future, still get a bit to read up on as far as that's concerned.

Link to comment
Share on other sites

Spaceboy
19 minutes ago, skank said:

I'm stuck with your template code, it contains some spaces so i cant copy it.

Anyone have correct code?
The one i'm using now that aint working is:

[code]

# Active Emby Users
template:
  - sensor:
  - name: "emby_users_watching"
    state:
     "{{ states.media_player
       | selectattr('state', 'eq', 'playing' )
       | rejectattr('entity_id', 'eq', 'media_player.badkamer' )
       | rejectattr('entity_id', 'eq', 'media_player.bureau' )
       | rejectattr('entity_id', 'eq', 'media_player.keuken' )
       | rejectattr('entity_id', 'eq', 'media_player.woonkamer_mini' )
       | rejectattr('entity_id', 'eq', 'media_player.living_tv' )
       | list
       | count
     }}"

[/code]

where are you entering this? you know it needs to go in your config.yaml? then you refer to the template in the lovelace card

Link to comment
Share on other sites

Spaceboy
20 minutes ago, skank said:

@seanbuffcan you help with  "automation through push notification in HA when media is added (and what media) , anyone have an automation for this yet?"

so are you trying to get a notification come up on your phone from HA? i have some other notifications that alert my iphone on certain events

Link to comment
Share on other sites

6 minutes ago, Spaceboy said:

where are you entering this? you know it needs to go in your config.yaml? then you refer to the template in the lovelace card

I've split up my config into packages

normally it starts with

 

sensor:
  - platform: ....

Link to comment
Share on other sites

15 minutes ago, Spaceboy said:

so are you trying to get a notification come up on your phone from HA? i have some other notifications that alert my iphone on certain events

Yes

But then with what is added from emby

I already use notifications from HA for other stuff too (android)

Link to comment
Share on other sites

Spaceboy
1 hour ago, skank said:

I've split up my config into packages

normally it starts with

 

sensor:
  - platform: ....

attach your config.yaml as a text file with personal information obfuscated

1 hour ago, skank said:

Yes

But then with what is added from emby

I already use notifications from HA for other stuff too (android)

ok, so you need to set up a webhook in emby for new media added and have that be the trigger for the automation in HA (you already know how to configure the event for the trigger)

Link to comment
Share on other sites

seanbuff
15 hours ago, skank said:

@seanbuffcan you help with  "automation through push notification in HA when media is added (and what media) , anyone have an automation for this yet?"

I spent a bit of time on this and unfortunately wasn't happy with the end result.

I'm encountering the same issue described here with Webhooks, in that they are being passed as form-data and not as a proper JSON response.

Meaning, I can get the notification to pop and show the raw data, but i'm not able to pull out specific data like "Title" easily like I would be able to with JSON. So I gave up.

If @Luke ever gets around to adding an option to send Webhooks with a content-header of application/json then i'll revisit this.

Link to comment
Share on other sites

On 2/1/2023 at 12:08 PM, Spaceboy said:

attach your config.yaml as a text file with personal information obfuscated

ok, so you need to set up a webhook in emby for new media added and have that be the trigger for the automation in HA (you already know how to configure the event for the trigger)

The sensor is working now, now the automation

Link to comment
Share on other sites

10 hours ago, seanbuff said:

I spent a bit of time on this and unfortunately wasn't happy with the end result.

I'm encountering the same issue described here with Webhooks, in that they are being passed as form-data and not as a proper JSON response.

Meaning, I can get the notification to pop and show the raw data, but i'm not able to pull out specific data like "Title" easily like I would be able to with JSON. So I gave up.

If @Luke ever gets around to adding an option to send Webhooks with a content-header of application/json then i'll revisit this.

Hey

Thx for replying
Pity it aint working as expected. Yes the title should be in the message/notification.

What did u get working then with the raw data?

Link to comment
Share on other sites

I now know again, why i stopped using it.

FYI i use emby server on my unraid machine (not 24/24 on) , i use HA on raspberry pi 24/24 on (but not able to host the emby server)
When i shut down my server, all info about emby on HA is gone..

:(

https://i.ibb.co/t8KhR4Z/app.jpg

 

Could there be developed something, so that all the data/info is on the HA side? Would love to see that...

Edited by skank
Link to comment
Share on other sites

4 hours ago, coreyjohnson75 said:

what do you mean it is gone? Like HA forgets what you configured? Or you lose the history?

Just look at the picture i posted... its empty

No it doesnt lose configuration cause when i turn on my server it auto-populates again

Link to comment
Share on other sites

seanbuff
14 hours ago, skank said:

When i shut down my server, all info about emby on HA is gone..

But why would you ever shutdown Emby??? 😝

 

16 hours ago, skank said:

Pity it aint working as expected. Yes the title should be in the message/notification.

What did u get working then with the raw data?

The default minimized notification is okay, but when you expand it - it's not so good.

image.png.6d9a6c50b4ce17c6e5cf621b6fb7a5b1.png

Link to comment
Share on other sites

Junglejim
8 hours ago, seanbuff said:

But why would you ever shutdown Emby??? 😝

Yeah I totally agree with that. 😜

I run Emby & HA plus many more containers in dockers on my NAS (OMV) which is 24/7.

I just stumbled onto a OMV intergration that I'm going to play with.. (graphs etc..)

Screenshot_2023-02-03_22-45-22.png.d40805c09292fbcb446d3a2dfb902f2f.png

 

Link to comment
Share on other sites

Junglejim

Some slow progress, I had a play with my OMV sensors. Just used the basic cards for the moment but it looking ok I guess, needs some more love but that's for another day.

Screenshot_2023-02-10_20-48-53.thumb.png.222173c112f18a6495dd05c8ea3b005f.png

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...