Jump to content

Official emby home assistant integration


skank

Recommended Posts

Junglejim

Finally got around to the "Active Emby Users" sensor and it works really well. Thanks @seanbuff 👍🍻

Screenshot_2023-02-25_18-17-26.thumb.png.6f99df84e549de9b6f0adfc9f012ecd5.png

Edit: Had to play some more.. :) Saturday night and had a few.. ;)

Some OMV Love..

Screenshot_2023-02-25_18-58-20.thumb.png.8b23d74269973cde69d6ca31485e23dc.png

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

  • 2 months later...
skank
On 2/3/2023 at 4:52 AM, seanbuff said:

But why would you ever shutdown Emby??? 😝

 

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

image.png.6d9a6c50b4ce17c6e5cf621b6fb7a5b1.png

Hi @seanbufftheres no way to only show the minimized version?

Pity this still aint possible..

Do you have it explained somewhere how to set this up?

Link to comment
Share on other sites

  • 4 weeks later...
seanbuff
On 16/05/2023 at 21:47, skank said:

Do you have it explained somewhere how to set this up?

Apologies for the delay in getting back to this.

I'll assume you have some basic knowledge of how to create an automation within HA for this purpose.

Firstly you need to create your unique webhook URL that Emby will send new media notifications to.
 

Create Home Assistant Automation

In HA, create a blank Automation. Add a Trigger of type 'Webhook'

image.png.3f2ac0283c7fb683506f9b39585c1c6c.png image.png.293ab2f10f76c2958cdb3851421a0e1a.png

A unique ID will be generated, to which you can prefix some easy to identify words:

image.png.0f3888461dbaf882ac4beda6bfefbf1d.png

Once added, be sure to click the 'Copy' icon at the end of that text box to save for later use

image.png.7740f6e5f2362802423a0c2bcf8baa32.png

Now for the 'Action', scroll down and click 'Add Action' and select 'Call Service'

image.png.c430bff10faab6f76e09d304c7c754ef.png

Assuming you have the HA app installed on your phone, you should see it pop up when you start typing "notify"

image.png.e64a81cf0af832ce363868fc00a282b2.png

Select the target device you would like the notifications received on.

Now we need to switch the editor to YAML mode in order to enter the custom data. Go ahead and use the image.png.2328bd995298aaba9f459e69c7456310.png menu to switch from Visual to YAML

image.png.849e78ba9e80bd10fbfd45e6af8b3b49.png

This is the code I landed on to receive the notifications the screenshot you quoted

service: notify.mobile_app_my_pixel_5
data:
  message: "{{ (trigger.data | string)[45:] }}"
  title: New Emby content has been added

You can play around with the [45:] value to trim or add characters to the notification body.

Save your Automation and name it something like "NOTIFY: Emby New Media"

Now that we're done with the HA component, we need to head over to Emby and setup the webhook that will initiate the automation trigger.
 

Add Emby Webhook

Within Emby, go to 'Webhooks' and click '+ Add Webhook'

Give it a meaningful name, and in the URL field, paste the webhook trigger that we copied from HA exactly as-is, it should contain the URL portion to your own HA instance (which could be an IP or hostname depending on your config)

For the 'Events' - click on Library > New Media Added

image.png.107a642c40b8501ee15393e25c737afd.png

Finally click 'Send Test Webhook' to see if you get a notification on your chosen mobile device target using the HA companion app.

Save it and there you have it.

Have a play with it and let me know if you have any questions.

  • Like 2
Link to comment
Share on other sites

skank

Thx !!!! workign as a charm when i test it.

Will see how it goes now when new media added.
I've set it to 25 instead of 45

 

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

Edited by skank
  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...
Oxide
On 29/09/2022 at 04:59, seanbuff said:

image.png.adb5444300ecce219d74a38448f6b336.png

Does anyone know if it's possible to display the username instead of the device name?

Link to comment
Share on other sites

Junglejim
On 20/06/2023 at 03:26, Oxide said:

Does anyone know if it's possible to display the username instead of the device name?

Hi mate, I'm not sure you can with the sensor.

The only thing I can think of is to edit the device name in the emby servers "Devices" page to reflect the user of that device..

Screenshot_2023-06-21_19-02-46.png.8e12d6ef2b14faaf94ee70fd385970f7.png

I could change this to Junglejim. 

 

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

skank
On 6/10/2023 at 3:19 PM, skank said:

Thx !!!! workign as a charm when i test it.

Will see how it goes now when new media added.
I've set it to 25 instead of 45

 

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

@seanbuffit doesnt seem to trigger :(

Although i added media, i couldnt get anything

heres my code

[code]

alias: "New media added to emby"
  trigger:
  - platform: webhook
    allowed_methods:
      - POST
      - PUT
    local_only: true
    webhook_id: emby-nieuwe-media-xxxxxxxxxxxxxxx
  condition: []
  action:
  - service: notify.mobile_devices
    data:
     message: "{{ (trigger.data | string)[25:] }}"
     title: Nieuwe film of serie toegevoegd aan server!

[/code]

 

where xxx is the right webhook

any idea? i've set also: limit library events to "each" so it should trigger right

Edited by skank
Link to comment
Share on other sites

seanbuff
10 minutes ago, skank said:

Although i added media, i couldnt get anything

And if you hit the "Send Test Webhook" button? What happens? That would test the link between Emby and HA.

Link to comment
Share on other sites

skank
49 minutes ago, seanbuff said:

And if you hit the "Send Test Webhook" button? What happens? That would test the link between Emby and HA.

yeah then i get a message

Link to comment
Share on other sites

Oxide
6 hours ago, Junglejim said:

Hi mate, I'm not sure you can with the sensor.

The only thing I can think of is to edit the device name in the emby servers "Devices" page to reflect the user of that device..

Screenshot_2023-06-21_19-02-46.png.8e12d6ef2b14faaf94ee70fd385970f7.png

I could change this to Junglejim. 

 

Thanks, I found editing the entities in HA did the trick, it also remove the Emby prefix :)

  • Like 2
Link to comment
Share on other sites

seanbuff
7 minutes ago, skank said:

i guess not? pity

Apologies, I've been away this week.. I had since disabled mine but will check on it in the next day or so and report back.

Link to comment
Share on other sites

skank
1 minute ago, seanbuff said:

Apologies, I've been away this week.. I had since disabled mine but will check on it in the next day or so and report back.

Hi

ok no problem mate, thx for looking

Link to comment
Share on other sites

skank

IT would even rock if we could get a message saying which movie added + the cover added to it.

But i guess its a bridge too far 😛

Link to comment
Share on other sites

seanbuff
14 hours ago, skank said:

IT would even rock if we could get a message saying which movie added + the cover added to it.

That sorta thing would be best served by native notifications to the Emby mobile app itself, once Luke ever gets around to implementing.

 

On 21/06/2023 at 22:22, skank said:

it doesnt seem to trigger :(

Although i added media, i couldnt get anything

I have re-enabled mine and it's working just fine. Your YAML code looks okay, except you changing 45 to 25, by doing that you are prefixing text (garbage) to the start of the notification - i suggest you leave it at '45' to make it cleaner 

Also, your call service says "- service: notify.mobile_devices" -- what is that? is that a single phone or a group? Have you tried just selecting a single device?

Have you also tried not limiting to any particular library, and just leaving as "Any" ?

image.png.07f615476f8638b282086c746e3ddb6b.png

Link to comment
Share on other sites

skank
On 7/2/2023 at 1:43 AM, seanbuff said:

That sorta thing would be best served by native notifications to the Emby mobile app itself, once Luke ever gets around to implementing.

 

I have re-enabled mine and it's working just fine. Your YAML code looks okay, except you changing 45 to 25, by doing that you are prefixing text (garbage) to the start of the notification - i suggest you leave it at '45' to make it cleaner 

Also, your call service says "- service: notify.mobile_devices" -- what is that? is that a single phone or a group? Have you tried just selecting a single device?

Have you also tried not limiting to any particular library, and just leaving as "Any" ?

image.png.07f615476f8638b282086c746e3ddb6b.png

Hi

I changed the automation from 25 to 45 like you said, will see if that fixes it.

the notify.mobile_devices is a group indeed.

But when i test, all is working fine, it seems somehow when media is added, it doesnt trigger...

 

I didnt limit it to any particular library, it is set like you mentioned to "any"

Link to comment
Share on other sites

seanbuff
1 hour ago, skank said:

Any further ideas?

Have you tried notifying just a single device instead of a group?

Copy my steps exactly to get it working first before trying other things 🙂

Link to comment
Share on other sites

skank
3 hours ago, seanbuff said:

Have you tried notifying just a single device instead of a group?

Copy my steps exactly to get it working first before trying other things 🙂

Tried both...

Still the same... it doesnt work.

I added new movie, but no message.

When i test the webhook (and so the automation) , i do get the message.

Its completely the same automation is you said. Even settings in emby is completely the same

Link to comment
Share on other sites

seanbuff
On 09/07/2023 at 01:06, skank said:

Still the same... it doesnt work.

Do you have a log file you can provide that covers the time you add new media to Emby?

You should see the httpclient module issue a POST towards your Home Assistant instance, do you see that?

Info HttpClient: POST http://homeassistant:8123/api/webhook/emby-new-media-adkq5cmZgNizmfW3XXXXXXXXX

If you're not seeing that, then Emby is not even notifying HA.

Link to comment
Share on other sites

skank
On 7/10/2023 at 1:37 AM, seanbuff said:

Do you have a log file you can provide that covers the time you add new media to Emby?

You should see the httpclient module issue a POST towards your Home Assistant instance, do you see that?

Info HttpClient: POST http://homeassistant:8123/api/webhook/emby-new-media-adkq5cmZgNizmfW3XXXXXXXXX

If you're not seeing that, then Emby is not even notifying HA.

Mmm i will check, hopefully i can look a couple of days back in the log?

What if im not seeing it? Can i fix it then somehow

And in which log i need to search? I see 4 logs

Edited by skank
Link to comment
Share on other sites

skank

update:

yes i found it

-08 14:03:43.550 Info HttpClient: POST http://192.168.10.6:8123/api/webhook/Emby-nieuwe-media-B2rpQzr9MvsdSDVvc4556

 

Edit 2: strange thing though, the code i see there, is different than the code i set up in emby as webhook (and in home assistant automation)

I changed the code in home assistant now to B2rpQzr9MvsdSDVvc4556

Will see if it triggers now although its set up in emby webhook differently

 

edit 3: after my change, i added another movie to emby, then i looked back into the new logs, and there i couldnt find the line " Info HttpClient: POST http://192.168.10.6:8123/api/webhook/Emby-nieuwe-....."

 

:(

Edited by skank
Link to comment
Share on other sites

seanbuff
13 hours ago, skank said:

strange thing though, the code i see there, is different than the code i set up in emby as webhook

Sounds pretty confusing. 😵‍💫

There should be no way Emby is sending to an ID you never gave it. If I were you I would start again, clean from scratch, including getting HA to generate a new webhook ID for you (not edit it yourself) and then delete and create a brand new webhook on the Emby side using the new URL.

Give that a shot and see how you go -- at least you know what you're looking for now. Good luck.

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...