Jump to content

Webhook with IFTTT and my Dlink smartplugs


Recommended Posts

Posted

I recently found out about the webhook plugin, and that with IFTTT i should be able to turn my dlink plugs on/off when i start/pause/stop a movie.

Im not very good at this kind of stuff, but I dont understand how I should do this properly.

I created the Webhook URL like this; https://maker.ifttt.com/trigger/playback.start/json/with/key/XXX and added trigger event "playback.start" to turn lights off, so far so good, it works.

The problem is when I try to add pause etc. https://maker.ifttt.com/trigger/playback.pause/json/with/key/XXX and a trigger to turn lights on. Even tho i specify "playback.pause" as trigger both of these events triger. So my lights turn on, off, on agan etc.

I tried creating a https://maker.ifttt.com/trigger/PLAYBACK/json/with/key/XXX url and then using this url for both events, with different event triggers, but then nothing happens. 

Posted
Quote

The problem is when I try to add pause etc. https://maker.ifttt.com/trigger/playback.pause/json/with/key/XXX and a trigger to turn lights on. Even tho i specify "playback.pause" as trigger both of these events triger. So my lights turn on, off, on agan etc.

Hi, what do you mean by "both"? What is the other event that triggers at the same time as pause?

Posted
1 hour ago, Luke said:

Hi, what do you mean by "both"? What is the other event that triggers at the same time as pause?

I only have these two, so I would guess it is the first one "playback.start". When I start the movie the lights go out, when i pause it they go back on, then back off again right away, without me doing anything

GrimReaper
Posted

Don't have dlink lights, but tested on my Hue setup.

And I can see where's the issue. I can reproduce BUT it is not on Emby's side but IFTTT's  webhooks service.

As far as Emby goes, all triggers are sent as single events (Play/Pause/Unpause/Stop). However, IFTTT does NOT parse JSON payload unless one has IFTTT Pro+ and can add a filter in the applet in which they would parse JSON :

Parsing JSON body with filter code – IFTTT Help Center

Instead, any playback event triggers all webhooks, regardless whether it is playback.start, playback.pause, playback.unpause or playback.stop.

In OP's case, as long as there's only playback.start trigger, it works as it is single webhook. Once playback.pause webhook is added, any playback event (Play/Pause/Resume/Stop) triggers both of them, and depending whether applet is set to Turn On, Turn Off or Toggle On/Off the lights, they are all executed in sequence (and not always in the same order):

image.thumb.png.cb94f21c81e15f7b35b11ee1bd263bdd.png

 

Hence lights going Off/On or vice versa.

The only partial workaround I've found with Hue is to create an applet with Toggle lights On/Off event and single webhook but that is highly depending on initial state of the lights (they should be On), so Play turns them Off and Pause turns them back On and Resume turns them back Off etc. 

Posted
42 minutes ago, GrimReaper said:

Don't have dlink lights, but tested on my Hue setup.

And I can see where's the issue. I can reproduce BUT it is not on Emby's side but IFTTT's  webhooks service.

As far as Emby goes, all triggers are sent as single events (Play/Pause/Unpause/Stop). However, IFTTT does NOT parse JSON payload unless one has IFTTT Pro+ and can add a filter in the applet in which they would parse JSON :

Parsing JSON body with filter code – IFTTT Help Center

Instead, any playback event triggers all webhooks, regardless whether it is playback.start, playback.pause, playback.unpause or playback.stop.

In OP's case, as long as there's only playback.start trigger, it works as it is single webhook. Once playback.pause webhook is added, any playback event (Play/Pause/Resume/Stop) triggers both of them, and depending whether applet is set to Turn On, Turn Off or Toggle On/Off the lights, they are all executed in sequence (and not always in the same order):

image.thumb.png.cb94f21c81e15f7b35b11ee1bd263bdd.png

 

Hence lights going Off/On or vice versa.

The only partial workaround I've found with Hue is to create an applet with Toggle lights On/Off event and single webhook but that is highly depending on initial state of the lights (they should be On), so Play turns them Off and Pause turns them back On and Resume turns them back Off etc. 

It looks like he gave start and pause two different urls in IFTTT. Are you saying that having unique urls for different events does not help?

GrimReaper
Posted (edited)
21 minutes ago, Luke said:

It looks like he gave start and pause two different urls in IFTTT

Exactly, as did I:

image.png.3afac6a120955de6407876b0db88ba15.png

 

21 minutes ago, Luke said:

Are you saying that having unique urls for different events does not help?

Yep, it makes no difference as IFTTT listens only to webhook received, doesn't discern type nor does parse JSON. Since ALL playback events are sent to BOTH webhooks, IFTTT triggers ALL (both, in this case) applets. The only thing that could be done from Emby's side is to have separated playback events (checkbox next to each event under general Playback events in webhook setup), so separate triggers could be sent to separate webhooks:

image.png.39f9144cf6b4bf17aef2b9db5cb83ac8.png

Edited by GrimReaper
Posted

OK yes that's doable.

  • Like 1
  • 2 weeks later...
Posted
On 10/1/2022 at 3:51 PM, GrimReaper said:

Exactly, as did I:

image.png.3afac6a120955de6407876b0db88ba15.png

 

Yep, it makes no difference as IFTTT listens only to webhook received, doesn't discern type nor does parse JSON. Since ALL playback events are sent to BOTH webhooks, IFTTT triggers ALL (both, in this case) applets. The only thing that could be done from Emby's side is to have separated playback events (checkbox next to each event under general Playback events in webhook setup), so separate triggers could be sent to separate webhooks:

image.png.39f9144cf6b4bf17aef2b9db5cb83ac8.png

In the next update to the webhooks plugin you'll be able to do exactly this, and pick specific sub-events so that you can setup one at a time if needed.

  • Like 1

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