Jump to content

Giving Webhooks Some Attention


Luke

Recommended Posts

MrMackey

@LukeI could even with the help of chatgpt unfortunately not create a template condition in Home Assistant with which I successfully pass only the requests from a particular device. Can you help me there?

Link to comment
Share on other sites

MrMackey

At the moment I do it exactly like this but, If you change profile on Emby, or turn off, and turn back on later, HomeAssistant keeps the "Idle" state and no longer detects the switch to Play, Stop, etc....
The only way to get the correct state is to restart the HA Core.
Therefore I would rather do it with webhooks.

Link to comment
Share on other sites

seanbuff
2 hours ago, MrMackey said:

HomeAssistant keeps the "Idle" state and no longer detects the switch to Play, Stop, etc....

That doesn't sound right. Previous HA versions had this problem but that should no longer be an issue with current HA release.

When was the last time you tried this tied to your "Emby" media player entity?

  • Thanks 1
Link to comment
Share on other sites

MrMackey

Thanks for the information, I use the Home Asistant entity all the time.

The last time it occurred was about 3-4 weeks ago.

It would be great if the bug was fixed, I'll keep an eye on it and see if it happens again with the current version.

Link to comment
Share on other sites

Spaceboy

ive been using this for around a year i think. never had a problem yet

Link to comment
Share on other sites

MrMackey

I was just able to reproduce the problem again, maybe someone else can confirm it.
When I restart Home Assistant while my server with Emby is offline and then I start the Emby server and watch a movie, the "Emby" media player entity does not work.
Only when I restart Home Assistant again while my server with Emby is on, it works.
Home Assistant version is 2023.5.2

Link to comment
Share on other sites

seanbuff
48 minutes ago, MrMackey said:

When I restart Home Assistant while my server with Emby is offline

Maybe because my servers are never really offline is the reason I haven't experienced this problem.

Sounds like the Emby integration on the HA side needs a more resilient heartbeat check (which is unofficially developed by a third party) - probably best asking the question in the HA forums.

  • Like 1
Link to comment
Share on other sites

MrMackey

To come back to my question how to search in Home assistant In a condition for the device name in the webhook I found after hours with chat gtp a solution :)
In this case nvidia-shield-living-room is my device name:

{{ trigger.data['data'] is match('.*nvidia-shield-living-room.*') }}

As I understand it, the code only looks for the word "nvidia-shield-living-room".  

Unfortunately I didn't manage to filter it so far that really the DeviceName has to be like that.

Edited by MrMackey
Link to comment
Share on other sites

45 minutes ago, MrMackey said:

To come back to my question how to search in Home assistant In a condition for the device name in the webhook I found after hours with chat gtp a solution :)
In this case nvidia-shield-living-room is my device name:

{{ trigger.data['data'] is match('.*nvidia-shield-living-room.*') }}

As I understand it, the code only looks for the word "nvidia-shield-living-room".  

Unfortunately I didn't manage to filter it so far that really the DeviceName has to be like that.

Are you sure the device name has dashes like that?

Link to comment
Share on other sites

MrMackey

Yes I called it that.

Screenshot2023-05-08030641.png.c3a5006d7acc95803a80a3028119ce03.png

In the webhook it is also like this:

"DeviceName":"nvidia-shield-living-room"

 

  • Thanks 1
Link to comment
Share on other sites

MrMackey

After I had a little time to experiment again. I think this solution does exactly what I wanted to achieve.

 

{{ 'DeviceName":"nvidia-shield-living-room' in trigger.data['data'].decode('utf-8') }}

 

  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...
svyaznoy362
30.03.2023 в 21:32, svyaznoy362 сказал:

Перед обновлением

 

{
  "Title": "Новая Подземка на Emby Server",
  что он использовал сюжетную линию фильма «<a href=\"/film/18511/\" class=\"all\">На последней дыхании</a>» ( 1960).</li><li>Первоначально пару главных героев должны были играть <a href=\"/name/4913/\" class=\"all\">Стинг</a> и <a href=\ " /name/15595/\" class=\"all\">Шарлотта Рэмплинг</a>. Отказ звезд вынудил <a href=\"/name/24505/\" class=\"all\">Люка Бессона</a> взять на эти роли <a href=\"/name/86847/\" class=\ "all\">Изабель Аджани</a> и <a href=\"/name/3347/\" class=\"all\">Кристофера Ламберта</a>.</li><li> Сценарий фильма был плод «коллективного творчества» пяти друзей <a href=\"/name/24505/\" class=\"all\">Люка Бессона</a>, включая самого режиссера. Прикосновение к исполнению главной роли — Фреда.Образец, созданный <a href=\"/name/3347/\" class=\"all\">Ламбертом</a>, совместл в себе черты «Маленького Принца и Безумного Макса», отсюда и мотивация его поступков. На память о будущем главного героя блондинистую панк-прическу и одержимость музыкой.</li><li>Полный хронометраж фильма был на 40 минут больше, но продюсеры задумали укоротить для проката время показа фильма. На художественной картине ткани, как представляется, это не происходит, но некоторые сюжетные линии естественным образом меняются или недостаточно раскрываются.</li></ul>", Прикосновение к исполнению главной роли — роль Фреда. Образец, созданный <a href=\" /name/3347/\" class=\"all\">Ламбертом</a>,На память о будущем главного героя блондинистую панк-прическу и одержимость музыкой.</li><li>Полный хронометраж фильма был на 40 минут больше, но продюсеры задумали укоротить для проката время показа фильма. На художественной картине ткани, как представляется, это не происходит, но некоторые сюжетные линии естественным образом меняются или недостаточно раскрываются.</li></ul>", Прикосновение к исполнению главной роли — роль Фреда. Образец, созданный <a href=\" /name/3347/\" class=\"all\">Ламбертом</a>, совместл в себе черты «Маленького Принца и Безумного Макса», отсюда и мотивация его поступков.На память о будущем главного героя блондинистую панк-прическу и одержимость музыкой.</li><li>Полный хронометраж фильма был на 40 минут больше, но продюсеры задумали укоротить для проката время показа фильма. На художественной картине ткани, как видно, это не происходит, но некоторые сюжетные линии естественно изменёнными или недостаточно раскрываемыми.</li></ul>", совместл в себе черты «Маленького Принца и Безумного Макса», отсюда и мотивация его поступков. На память о будущем главного героя блондинистую панк-прическу и одержимость музыкой.</li><li>Полный хронометраж фильма был на 40 минут больше, но продюсеры задумали укоротить для проката время показа фильма.На художественной картине ткани, как видно, это не происходит, но некоторые сюжетные линии естественно изменёнными или недостаточно раскрываемыми.</li></ul>", совместл в себе черты «Маленького Принца и Безумного Макса», отсюда и мотивация его поступков. На память о будущем главного героя блондинистую панк-прическу и одержимость музыкой.</li><li>Полный хронометраж фильма был на 40 минут больше, но продюсеры задумали укоротить для проката время показа фильма . непроисходит, но некоторые сюжетные линии обычно изменёнными или недостаточно раскрытыми.</li></ul>",
  «Дата»: «2023-03-27T09:16:47.1341078Z»,
  «Событие»: «library.new»,
  «Элемент»: {
    «Имя»:«Подземка»,
    «OriginalTitle»: «Метро»,
    «Идентификатор сервера»: «e9ef940b2d214a18991f98683144c466»,
    «Id»: «680866»,
    «DateCreated»: «2023-03-27T09:13:59.5180000Z»,
    «Контейнер»: «mkv»,
    "SortName": "Подземка",
    "PremiereDate" : "1985-04-10T00:00:00.0000000Z",
    "Внешние URL": [
      {
        "Имя": "IMDb",
        "Url": "https://www .imdb.com/title/tt0090095"
      },
      {
        "Имя": "КинопоискРу",
        "Url": "https://www.kinopoisk.ru/film/14305/"
      },
      {
        "Имя": "TheMovieDb",
        "Url": "https://www.themoviedb.org/movie/10656"
      },
      {
        "Name": "TheTVDB",
        "Url": "https://thetvdb.com/dereferrer/movie/4524"
      },
      {
        "Name": "Trakt",
        "Url": "https://trakt. tv/search/tmdb/10656?id_type=movie"
      }
    ],
    "CriticRating" : 56,
    "Путь": "/volume1/GDRIVE/362/Film/3D/MKV/Subway.1985 (kp-14305) (14.4G ).mkv",
    "r",

что он использовал сюжетную линию фильма «<a href=\"/film/18511/\" class=\"all\">На последней Официальной дыхании</a>» (1960).</li><li>изначально пару главных героев должны были играть <a href=\"/name/4913/\" class=\"all\">Стинг</a> и <a href=\ "/name/15595/\" class=\ "all\">Шарлотта Рэмплинг</a>.Отказ звезд вынудил <a href=\"/name/24505/\" class=\"all\">Люка Бессона</a> взять на эти роли <a href=\"/name/86847/\" class=\ "all\">Изабель Аджани</a> и <a href=\"/name/3347/\" class=\"all\">Кристофера Ламберта</a>.</li><li>Сценарий фильма был «плодколлективного творчества» пяти друзей <a href=\"/name/24505/\" class=\"all\"> Люка Бессона</a>, включая самого режиссера. Прикосновение к исполнению главной роли — Фреда. Образец, созданный <a href=\"/name/3347/\" class=\"all\">Ламбертом</a>, совместл в себе черты «Маленького Принца и Безумного Макса», отсюда и мотивация его поступков.На память о будущем главного героя блондинистую панк-прическу и одержимость музыкой.</li><li>Полный хронометраж фильма был на 40 минут больше, но продюсеры задумали укоротить для проката время показа фильма. На художественной картине ткани, как представляется, это не происходит, но некоторые сюжетные линии естественным образом меняются или недостаточно раскрываются.</li></ul>", Прикосновение к исполнению главной роли — роль Фреда. Образец, созданный <a href=\" /name/3347/\" class=\"all\">Ламбертом</a>, совместл в себе черты «Маленького Принца и Безумного Макса», отсюда и мотивация его поступков.На память о будущем главного героя блондинистую панк-прическу и одержимость музыкой.</li><li>Полный хронометраж фильма был на 40 минут больше, но продюсеры задумали укоротить для проката время показа фильма. На художественной картине ткани, как представляется, это не происходит, но некоторые сюжетные линии естественным образом меняются или недостаточно раскрываются.</li></ul>", Прикосновение к исполнению главной роли — роль Фреда. Образец, созданный <a href=\" /name/3347/\" class=\"all\">Ламбертом</a>, совместл в себе черты «Маленького Принца и Безумного Макса», отсюда и мотивация его поступков.На память о будущем главного героя блондинистую панк-прическу и одержимость музыкой.</li><li>Полный хронометраж фильма был на 40 минут больше, но продюсеры задумали укоротить для проката время показа фильма. На художественной картине ткани, как видно, это не происходит, но некоторые сюжетные линии естественно изменёнными или недостаточно раскрываемыми.</li></ul>", совместл в себе черты «Маленького Принца и Безумного Макса», отсюда и мотивация его поступков. На память о будущем главного героя блондинистую панк-прическу и одержимость музыкой.</li><li>Полный хронометраж фильма был на 40 минут больше, но продюсеры задумали укоротить для проката время показа фильма.На художественной картине ткани, как видно, это не происходит, но некоторые сюжетные линии естественно изменёнными или недостаточно раскрываемыми.</li></ul>", совместл в себе черты «Маленького Принца и Безумного Макса», отсюда и мотивация его поступков. На память о будущем главного героя блондинистую панк-прическу и одержимость музыкой.</li><li>Полный хронометраж фильма был на 40 минут больше, но продюсеры задумали укоротить для проката время показа фильма . непроисходит, но некоторые сюжетные линии закономерно изменёнными или недостаточно выявленными.</li></ul>",
    «Тэглайны»: [
      «Андерграундная история, в которой переплетаются жизни»
    ],
    «Жанры»:[
      «триллер»
    ],
    «Рейтинг отзывов»: 6.5,
    «RunTimeTicks»: 61404800000,
    «Размер»: 15419566433,
    «Имя файла»: «Метро. 1985 (kp-14305) (14.4G).mkv",
    "Битрейт": 20089069,
    "ProductionYear": 1985,
    "RemoteTrailers": [
      {
        "Url": "https://www.youtube.com/watch?v =PdOigVX4b7I"
      }
    ],
    "ProviderIds": {
      "КинопоискРу": "14305",
      "Imdb": "tt0090095",
      "Tmdb": "10656",
      "Tvdb": "4524"
    },
    "IsFolder":



      {
        "Имя": "Гомон",
        "Идентификатор": 408207
      },
      {
        "Имя": "Les Films du Loup",
        "Id": 602833
      },
      {
        "Имя": "TSF Productions",
        "Id": 680897
      },
      {
        "Name": "TF1 Films Production",
        "Id": 402271
      }
    ],
    "GenreItems": [
      {
        "Имя": "триллер",
        "Id": 729
      }
    ],
    «TagItems»: [],
    «PrimaryImageAspectRatio»: 0,6666666666666666,
    «ImageTags»: {
      «Primary»: «7ea89f4a7b46cc0d18b746e8a34e6abf»
    },
    «BackdropImageTags»: [
      «aed4a721529e72345ee0d545b06 7762f»
    ],
    «MediaType»: «Видео»,
    «Ширина» : 1920,
    «Высота»: 816
  },
  « Сервер»: {
    «Имя»: «Xpenology362»,
    «Идентификатор»: «e9ef940b2d214a18991f98683144c466»,
    «Версия»: «4.8.0.26»
  }
}

Опять тоже самое с версией 4.8.0.34 , не могу сделать фото

 

You made changes, had to edit the script, now the problem is solved

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

  • 3 months later...

@roaku @BillOatman @rechigo @GrimReaper @ryzilla @Loefamily @johnnycash @adminExitium

For those hoping to use WebHooks with Discord, I've pushed an update to the plugin catalog for the WebHooks plugin to allow you to configure the request content type, which you can now set to either application/json or multipart form data. This should make it a little more Discord-friendly.

The update is targeting the 4.8 beta server so you'll need that to test it. Please try it out and report your experience. Thanks.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

vaise

Anything special instructions here - as I just added my known working webhook and it fails the test.

I only started using the custom discord plugin a few days ago too.....

Edited by vaise
Link to comment
Share on other sites

8 minutes ago, vaise said:

Anything special instructions here - as I just added my known working webhook and it fails the test.

I only started using the custom discord plugin a few days ago too.....

If you're using the dedicated plugin then you probably don't need to have webhooks sending data to discord as well.

Webhook users have requested the ability to use plain application/json requests instead of multi-part requests, so that's what I added and put an option in the dialog.

Link to comment
Share on other sites

vaise
3 minutes ago, Luke said:

If you're using the dedicated plugin then you probably don't need to have webhooks sending data to discord as well.

Webhook users have requested the ability to use plain application/json requests instead of multi-part requests, so that's what I added and put an option in the dialog.

No worries.

I was just testing it out, I’d prefer to use stock emby stuff where possible and if this is working, I will remove the discord plugin.  But the webhooks update is failing the test.  I’m pasting in the same url that works on discord plug-in and copied straight from discord server.

Link to comment
Share on other sites

18 minutes ago, vaise said:

No worries.

I was just testing it out, I’d prefer to use stock emby stuff where possible and if this is working, I will remove the discord plugin.  But the webhooks update is failing the test.  I’m pasting in the same url that works on discord plug-in and copied straight from discord server.

I don't even know if that's supposed to be possible or not. The discord plugin doesn't send the same thing that webhooks sends, so maybe they need different urls.

Or maybe you have to do some work on the discord side to interpret the data. The format of the Emby webhook json is our owns, so I would imagine you'd have to tell Discord how to understand it.

Link to comment
Share on other sites

vaise
4 minutes ago, Luke said:

I don't even know if that's supposed to be possible or not. The discord plugin doesn't send the same thing that webhooks sends, so maybe they need different urls.

Or maybe you have to do some work on the discord side to interpret the data. The format of the Emby webhook json is our owns, so I would imagine you'd have to tell Discord how to understand it.

Ok, if that’s it then the discord plugin is def required then.  All others apps are just a copy/past in from discord and just work (every app that sends a message).  I don’t have the skills to do anything with discord.

Link to comment
Share on other sites

7 minutes ago, vaise said:

Ok, if that’s it then the discord plugin is def required then.  All others apps are just a copy/past in from discord and just work (every app that sends a message).  I don’t have the skills to do anything with discord.

They probably built something tailored for discord. The emby webhooks is generalized. The receiver needs to know how to work with the data.

Link to comment
Share on other sites

  • 4 weeks later...
On 11/28/2022 at 7:41 PM, Luke said:

OK yes in some cases it still may get sent sooner than it should. We'll look into it. Thanks.

Hello @Luke,

I played with webhooks last week and the issue with too early webhook sending / missing informations is still preset in the current stable. Have you planned an update with version 4.8?

Thanks in advance

Link to comment
Share on other sites

3 hours ago, dual-o said:

Hello @Luke,

I played with webhooks last week and the issue with too early webhook sending / missing informations is still preset in the current stable. Have you planned an update with version 4.8?

Thanks in advance

Hi, this should be improved in the 4.8 release. Thanks.

  • Like 1
Link to comment
Share on other sites

mbfubu456

Hi @Luke

I am new to Emby but I love it, great work!

In order to get notifications of new item added to a specific library, I use webhook with Notifiarr/Discord and I do get notifications but not only for the library folder (say “Movies 4K”) I specified in the webhook settings but from all my library folders (for example “Series”, “Series 4K”, “Movies SD” etc.). In the webhook settings, I check the “Library/New Media Added” box and I specifically limit the library events to a specific folder but no joy.

Is it a known issue that will be addressed in a future update? If not, could you take a look at it please?

Thank you!

(Sorry if I needed to create a new topic but it seems logical to post this here)

Link to comment
Share on other sites

18 minutes ago, mbfubu456 said:

Hi @Luke

I am new to Emby but I love it, great work!

In order to get notifications of new item added to a specific library, I use webhook with Notifiarr/Discord and I do get notifications but not only for the library folder (say “Movies 4K”) I specified in the webhook settings but from all my library folders (for example “Series”, “Series 4K”, “Movies SD” etc.). In the webhook settings, I check the “Library/New Media Added” box and I specifically limit the library events to a specific folder but no joy.

Is it a known issue that will be addressed in a future update? If not, could you take a look at it please?

Thank you!

(Sorry if I needed to create a new topic but it seems logical to post this here)

HI, yes this is resolved in the upcoming 4.8 server release. Workaround in the meantime is to not use the library filter.

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