Jump to content


Photo

WebHooks


  • Please log in to reply
28 replies to this topic

#1 randomevents OFFLINE  

randomevents

    Advanced Member

  • Members
  • 291 posts
  • Local time: 10:31 AM

Posted 26 November 2017 - 12:21 PM

WebHooks broadcaster, I originally started by upgrading the gaps in this excellent plugin -: https://emby.media/c...ebhooks-plugin/ , but found that there was no reason to stay with the Plex format after some forum and PM requests.

 

This version is playback events and items added (other events to come shortly), and you can use the tokens listed in the settings to create your own message, for example the current playback tokens ({Event}, {ServerID}, {ServerName}, {UserID}, {UserName}, {AppName}, {DeviceID}, {DeviceName}, {DeviceIP}, {ItemType}, {ItemName}, {ItemNameParent}, {ItemNameGrandparent}, {ItemID}, {ItemRunTimeTicks}, {ItemIndex}, {ItemParentIndex}, {ItemCriticRating}, {ItemCommunityRating}, {ItemPremiereDate}, {ItemDateAdded}, {ItemYear}, {ItemBitrate}, {ItemGenre}, {SessionID}, {SessionPlaybackPositionTicks}, {TimeStamp}) might be used to create {"event": {Event}, "user":{UserName}, "item":{ItemName}, "date":{TimeStamp}} as a valid JSON string.

 

Some items of note, {SessionPlaybackPositionTicks} will give you the the correct ticks on stop events, and I added some handlers to take care of the weird stop\pause\resume messages on next\previous track commands for anyone who is aware of that. With the proper ticks being broadcasted, one benefit is that you no longer need to call the media server for progress updates and can calculate them in your app.

 

Question: Should I add Emby's internal flag for isPlackbackCompleted (true or false depending on server settings)?

 

https://github.com/r...bHooks/releases

 

2017-11-27 -: 2.0.0.1 Small update to add option to remove quotes from token generation. Useful for crafting statements.


Edited by randomevents, 27 November 2017 - 10:29 PM.

  • NeauxGeaux likes this

#2 NeauxGeaux OFFLINE  

NeauxGeaux

    Advanced Member

  • Members
  • 49 posts
  • Local time: 09:31 AM

Posted 27 November 2017 - 11:30 PM

This is fantastic! Thank you for making these updates. Absolutely going to love using this!



#3 randomevents OFFLINE  

randomevents

    Advanced Member

  • Members
  • 291 posts
  • Local time: 10:31 AM

Posted 27 November 2017 - 11:35 PM

@NeauxGeaux

 

An example of a string you showed me last week -:

 

{"text" : "Recently Added!! Vice Principals: S2E9 - The Union of the Wizard & The Warrior", "bot_id" : "XXXXXX"}

 

Check "Remove Quotes From Text Tokens"

{"text" : "Recently Added!! {ItemNameGrandparent}: S{ItemParentIndex}E{ItemIndex} - {ItemName}", "bot_id" : "XXXXXX"}



#4 NeauxGeaux OFFLINE  

NeauxGeaux

    Advanced Member

  • Members
  • 49 posts
  • Local time: 09:31 AM

Posted 28 November 2017 - 11:06 AM

Just tested and can confirm this works perfectly! Thanks for adding the check for to remove quotes.

 

Edit:

 

@randomevents

 

One thing I'm running into is this is running before any meta data for the "Item Added" is generated. So, for example, I copied every variable in your string, and this is the translation I'm receiving:

Item Added Tokens -: {Event}, {ServerID}, {ServerName}, {ItemType}, {ItemName}, {ItemNameParent}, {ItemNameGrandparent}, {ItemID}, {ItemRunTimeTicks}, {ItemIndex}, {ItemParentIndex}, {ItemCriticRating}, {ItemCommunityRating}, {ItemPremiereDate}, {ItemDateAdded}, {ItemYear}, {ItemBitrate}, {ItemGenre}, {TimeStamp}

Translates to:

 

Added, 30fb9b8569f2418ba900fbd0051e8e78, MyServer, movies, American.Assassin.2017.1080p, Movies, root, 878af7d4-8f13-f367-2ad9-13eaab0d926d, 0, 0, 0, 0, 0, , 11/28/2017 15:22:53, 2017, 0, , 2017-11-28 09:22:53.939

I did not run a test for TV Shows, but I assume it would render a similar result.

 

I did, however, test the Playback events and all that works perfectly; grabbing the correct meta data for that item.


Edited by NeauxGeaux, 28 November 2017 - 11:31 AM.


#5 D3lta3 OFFLINE  

D3lta3

    Newbie

  • Members
  • 5 posts
  • Local time: 03:31 PM

Posted 12 November 2018 - 08:22 AM

Hi All,

 

I've been trying to install this plugin so I can hook up Emby to HASSIO, but unfortunately it won't work. I'm seeing error-messages in the log:

2018-11-12 06:23:53.524 Error App: Error creating Emby.WebHooks.WebHooks
	*** Error Report ***
	Version: 3.5.3.0
	Command line: C:\Users\******\AppData\Roaming\Emby-Server\system\EmbyServer.dll
	Operating system: Microsoft Windows NT 6.2.9200.0
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: True
	Processor count: 8
	Program data path: C:\Users\******\AppData\Roaming\Emby-Server\programdata
	Application directory: C:\Users\******\AppData\Roaming\Emby-Server\system
	System.TypeLoadException: Could not load type 'MediaBrowser.Controller.Sync.ISyncManager' from assembly 'MediaBrowser.Controller, Version=3.5.3.0, Culture=neutral, PublicKeyToken=null'.
	   at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
	   at System.Reflection.RuntimeConstructorInfo.get_Signature()
	   at System.Reflection.RuntimeConstructorInfo.GetParametersNoCopy()
	   at System.Reflection.RuntimeConstructorInfo.GetParameters()
	   at SimpleInjector.Advanced.AdvancedExtensions.Verify(IDependencyInjectionBehavior behavior, ConstructorInfo constructor)
	   at SimpleInjector.ContainerOptions.IsConstructableType(Type implementationType, String& errorMessage)
	   at SimpleInjector.Container.TryBuildInstanceProducerForConcreteUnregisteredType(Type type, InjectionConsumerInfo context)
	   at SimpleInjector.Container.GetInstanceProducerForType(Type serviceType, InjectionConsumerInfo consumer, Func`1 buildInstanceProducer)
	   at SimpleInjector.Container.GetInstanceForRootType(Type serviceType)
	   at SimpleInjector.Container.GetInstance(Type serviceType)
	   at Emby.Server.Implementations.ApplicationHost.CreateInstanceSafe(Tuple`2 typeInfo)
	System.TypeLoadException
	   at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
	   at System.Reflection.RuntimeConstructorInfo.get_Signature()
	   at System.Reflection.RuntimeConstructorInfo.GetParametersNoCopy()
	   at System.Reflection.RuntimeConstructorInfo.GetParameters()
	   at SimpleInjector.Advanced.AdvancedExtensions.Verify(IDependencyInjectionBehavior behavior, ConstructorInfo constructor)
	   at SimpleInjector.ContainerOptions.IsConstructableType(Type implementationType, String& errorMessage)
	   at SimpleInjector.Container.TryBuildInstanceProducerForConcreteUnregisteredType(Type type, InjectionConsumerInfo context)
	   at SimpleInjector.Container.GetInstanceProducerForType(Type serviceType, InjectionConsumerInfo consumer, Func`1 buildInstanceProducer)
	   at SimpleInjector.Container.GetInstanceForRootType(Type serviceType)
	   at SimpleInjector.Container.GetInstance(Type serviceType)
	   at Emby.Server.Implementations.ApplicationHost.CreateInstanceSafe(Tuple`2 typeInfo)

Hoping somebody here can point me in the right direction.


Edited by D3lta3, 12 November 2018 - 08:23 AM.


#6 hstamas OFFLINE  

hstamas

    Advanced Member

  • Members
  • 631 posts
  • Local time: 10:31 AM

Posted 30 November 2018 - 03:04 PM

Hi all. I was wondering if someone could help me with what I suspect is just a syntax error Im having trying to get this plugin to trigger an IFTTT event?

 

I set up IFTTT webhooks service to trigger a Philips Hue scene. All works fine when I test it on IFTTT. When I copy and past the webhook URL into the URL section of the plugin and start a movie nothing happens.

 

This is the URL that IFTTT is providing me which I copied and pasted into the URL section of the plugin:

 

https://maker.ifttt.com/trigger/{event}/with/key/xxxxxxxxxxxxxx

 

Ive tried all combinations of filling in that {event} place holder with no luck so far. I assume I replace that with the event name I have set up in IFTTT? In this case its called "play".

 

Also in the plugin it indicates putting in the URL and also the port? Ive tried putting in my local port number which did nothing.

 

Any help would be greatly appreciated .



#7 pir8radio OFFLINE  

pir8radio

    NGINX

  • Members
  • 3522 posts
  • Local time: 09:31 AM
  • LocationChicago

Posted 24 May 2019 - 09:25 PM

Sooo  I'm trying to get this to work... anyone have a step by step?  some examples please, does it even work still?

 

I would like to send a trigger when a specific device plays a movie..   The plugin 1, looks like it doesnt work,  and 2. looks like it tries to send for every users play....   So if i have 1000 users playing movies, then it sends a webhook for every one?

2019-05-24 20:11:09.021 Error App: Error creating Emby.WebHooks.WebHooks
	*** Error Report ***
	Version: 4.2.0.8
	Command line: C:\Users\nam\AppData\Roaming\Emby-Server\System\EmbyServer.dll -noautorunwebapp
	Operating system: Microsoft Windows NT 6.2.9200.0
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: True
	Runtime: file:///C:/Users/nam/AppData/Roaming/Emby-Server/System/System.Private.CoreLib.dll
	Processor count: 40
	Program data path: C:\Users\nam\AppData\Roaming\Emby-Server
	Application directory: C:\Users\nam\AppData\Roaming\Emby-Server\System
	System.TypeLoadException: System.TypeLoadException: Could not load type 'MediaBrowser.Controller.Sync.ISyncManager' from assembly 'MediaBrowser.Controller, Version=4.2.0.8, Culture=neutral, PublicKeyToken=null'.
	   at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
	   at System.Reflection.RuntimeConstructorInfo.get_Signature()
	   at System.Reflection.RuntimeConstructorInfo.GetParametersNoCopy()
	   at System.Reflection.RuntimeConstructorInfo.GetParameters()
	   at SimpleInjector.Advanced.AdvancedExtensions.Verify(IDependencyInjectionBehavior behavior, ConstructorInfo constructor)
	   at SimpleInjector.ContainerOptions.IsConstructableType(Type implementationType, String& errorMessage)
	   at SimpleInjector.Container.TryBuildInstanceProducerForConcreteUnregisteredType(Type type, InjectionConsumerInfo context)
	   at SimpleInjector.Container.GetInstanceProducerForType(Type serviceType, InjectionConsumerInfo consumer, Func`1 buildInstanceProducer)
	   at SimpleInjector.Container.GetInstanceForRootType(Type serviceType)
	   at SimpleInjector.Container.GetInstance(Type serviceType)
	   at Emby.Server.Implementations.ApplicationHost.CreateInstanceSafe(Tuple`2 typeInfo)
	Source: System.Private.CoreLib
	TargetSite: Void GetSignature(Void*, Int32, System.RuntimeFieldHandleInternal, System.IRuntimeMethodInfo, System.RuntimeType)
	

Edited by pir8radio, 24 May 2019 - 11:45 PM.


#8 PhyberApex OFFLINE  

PhyberApex

    Advanced Member

  • Members
  • 77 posts
  • Local time: 04:31 PM

Posted 17 July 2019 - 07:27 PM

Bit of a late reply but I got an up and running version over at my github here.

 

No release in github as of yet but should be working alright if you compile it yourself. Will probably release something within the next few days / weeks.

 

~Cheers


  • jibenito likes this

#9 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 156874 posts
  • Local time: 10:31 AM

Posted 22 October 2019 - 01:53 PM

There will be a new webhooks plugin with the upcoming Emby Server 4.3:

 

https://emby.media/c...ebhooks-plugin/


  • jibenito likes this

#10 Xorp OFFLINE  

Xorp

    Advanced Member

  • Members
  • 136 posts
  • Local time: 10:31 AM

Posted 05 January 2020 - 11:39 PM

There will be a new webhooks plugin with the upcoming Emby Server 4.3:

 

https://emby.media/c...ebhooks-plugin/

 

Anyone get this working with Home Assistant yet?

 

My Home Assistant instance is ready to receive Webhook POSTs but Emby might not be formating it correctly?

 

If I send a test POST from Postman, I get the desired automation (turning off the lights), but Emby's webhook test fails.

 

This is the payload of Postman's test which works:

POST http://10.0.0.212:8123/api/webhook/light1 HTTP/1.1
User-Agent: PostmanRuntime/7.21.0
Accept: */*
Cache-Control: no-cache
Postman-Token: a97a4a83-202c-486d-b5ec-8f0ba8bdda42
Host: 10.0.0.212:8123
Accept-Encoding: gzip, deflate
Content-Length: 0
Connection: keep-alive

And the payload Emby's test:

POST http://10.0.0.212:8123/api/webhook/light1 HTTP/1.1
Host: 10.0.0.212:8123
User-Agent: Emby Server/4.3.1.0
Accept-Encoding: deflate
Content-Type: multipart/form-data; boundary="686df1f0-cc64-4525-b3a3-567ffa4732f1"
Content-Length: 267

--686df1f0-cc64-4525-b3a3-567ffa4732f1
Content-Type: application/json; charset=utf-8
Content-Disposition: form-data

{"Event":"system.webhooktest","Server":{"Name":"Emby Server","Id":"6372a9c3d4f54e8b9f784ae086a6496b"}}
--686df1f0-cc64-4525-b3a3-567ffa4732f1--

Home Assistant gives this error from Emby POSTs

Error processing webhook light1
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/webhook/__init__.py", line 77, in async_handle_webhook
    response = await webhook["handler"](hass, webhook_id, request)
  File "/usr/src/homeassistant/homeassistant/components/automation/webhook.py", line 33, in _handle_webhook
    result["data"] = await request.post()
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_request.py", line 645, in post
    out.add(field.name, value)
TypeError: MultiDict keys should be either str or subclasses of str

Edited by Xorp, 05 January 2020 - 11:40 PM.


#11 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 156874 posts
  • Local time: 10:31 AM

Posted 05 January 2020 - 11:58 PM

Right you'll to setup something to receive the webhooks such as ifttt or zapier, and then send a request to your home assistant.

#12 Xorp OFFLINE  

Xorp

    Advanced Member

  • Members
  • 136 posts
  • Local time: 10:31 AM

Posted 07 January 2020 - 02:04 AM

Aw dang, I was hoping to cut out the middleware and send events directly from Emby to Home Assistant, and do automations based on those events.



#13 AMMJ93 OFFLINE  

AMMJ93

    Member

  • Members
  • 10 posts

Posted 16 February 2020 - 12:06 PM

How about different webhook per type of event? Different webhook on stop than on play for example. More control

#14 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 156874 posts
  • Local time: 10:31 AM

Posted 16 February 2020 - 12:37 PM

I suppose that's possible. Currently you can sort of do that by setting up multiple using one for each category.

#15 AMMJ93 OFFLINE  

AMMJ93

    Member

  • Members
  • 10 posts

Posted 16 February 2020 - 04:49 PM

No, you can do on Playback events and then it will trigger on Play + Stop + Pause etc. It would be nice to have Play > do this, Stop > do something else

#16 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 156874 posts
  • Local time: 10:31 AM

Posted 17 February 2020 - 11:34 PM

It's possible for the future. Thanks.

#17 seanbuff OFFLINE  

seanbuff

    Advanced Member

  • Members
  • 282 posts
  • Local time: 12:31 AM
  • LocationSydney, Australia

Posted 17 February 2020 - 11:46 PM

Yes, I would also like to be able to split out the playback events - this would really help with home automation



#18 JustEric78 OFFLINE  

JustEric78

    Advanced Member

  • Members
  • 128 posts
  • Local time: 09:31 AM
  • LocationDallas, TX.

Posted 18 February 2020 - 04:31 PM

If it helps this request move forward I would love play and pause etc. broken out similar to how the Hue plugin works. I went through setting up Webhooks to get some automation for my Lutron lighting when I hit the same limitation I would imagine most others did. I would even be happy to pay for this plugin and I am sure others feel the same. 



#19 AMMJ93 OFFLINE  

AMMJ93

    Member

  • Members
  • 10 posts

Posted 18 February 2020 - 05:28 PM

Given how the events are now (playback.start, playback.stop) it should be relatively easy to distinct between them

#20 JustEric78 OFFLINE  

JustEric78

    Advanced Member

  • Members
  • 128 posts
  • Local time: 09:31 AM
  • LocationDallas, TX.

Posted 18 February 2020 - 06:53 PM

Unfortunately webhooks doesn't allow for those variables unless I'm missing something? I was able to get this working well with Zapier but if you have more then one variable it wants you to pay $20/mo. I would imagine setting it up like the Hue plugin would be difficult and lots of users would get use out of it that aren't developers.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users