Jump to content

Add "RunTimeTicks" to the JSON POST request in Webhooks Plugin


JGWNet

Recommended Posts

Webhooks works great using Sequematic and IFTTT together with Alexa triggers, but it needs to be able to work with Cinema Intros as well.  Currently the lights go off and back on after every trailer and bumper that plays.  If the variable "RunTimeTicks" is added to the JSON POST request, then in Sequematic I can add a "check variable value" to identify if the movie is less than 5 mins.  Less than 5 mins would help indicate that this movie is a trailer or bumper video.  With that I can tell Sequematic to stop the sequence if the movie is less than 5 mins.  I think this would be a solve all for anyone struggling with getting the perfect cinema experience.

Link to comment
Share on other sites

BillOatman
47 minutes ago, JGWNet said:

Webhooks works great using Sequematic and IFTTT together with Alexa triggers, but it needs to be able to work with Cinema Intros as well.  Currently the lights go off and back on after every trailer and bumper that plays.  If the variable "RunTimeTicks" is added to the JSON POST request, then in Sequematic I can add a "check variable value" to identify if the movie is less than 5 mins.  Less than 5 mins would help indicate that this movie is a trailer or bumper video.  With that I can tell Sequematic to stop the sequence if the movie is less than 5 mins.  I think this would be a solve all for anyone struggling with getting the perfect cinema experience.

Or better still, a indication of if whats being played is a bumper or a feature. That way you wouldn't need to rely on time.

Edited by BillOatman
Link to comment
Share on other sites

In the Sequematic service, I see all the data in the logs, which includes "RunTimeTicks".  When I try to set a check variable for that value, It does not seem to read it. 

Link to comment
Share on other sites

If you are familiar with Sequematic, you can set a query based on a variable value "If, Then, Else".  I attached a snip as an example.  The variable {RunTimeTicks} does not capture like {Events}.  The value in {Events} triggers an IFTTT response based on playback.stop or playback.start, which works great.  I want to be able to abort the sequence if the value of {RunTimeTicks} is less than 10min or 6000000000milliseconds.  Unfortunately this does not work.

 

image.png.6762809e987563f37d93fc72d98f64be.png

 

Here is the sequence log which shows that the check against {RunTimeTicks} passed, but it is not under the values displayed in the actual data payload.

image.png.73dee6f8111ac81efdf84b9a4d12fe64.png

 

Here is the payload file....

 

image.png.c75cb8c2624ad575cfc7df635f4c5da3.png

Link to comment
Share on other sites

BillOatman
23 minutes ago, ebr said:

Hi.  It looks like it did work but maybe the precision is off by one factor...?

Agreed .  The unit of measure is ticks, not milliseconds.

public const long TicksPerSecond = 10000000;
ticks = seconds * TicksPerSecond

Ticks per minute 600,000,000

Edited by BillOatman
Link to comment
Share on other sites

The funny part is that I can put anything into that variable, for example; {ThisVariableDoesNotWork} below '6000000000' and it gives me the same result.  I looked at the coding in "Emby.Webhooks.dll" and it appears that only (playback.stop, playback.start, playback.pause, playback.unpause, and playback.scrobble) are the only variables that are past through to Sequematic.  Maybe it has something to do with what Sequematic listens for?

Link to comment
Share on other sites

BillOatman

Based on the json payload you pasted above it sure looks to me like the Emby webhook is behaving properly.  

I assume you looked here. Particularly :

Quote

When processing, the JSON is flattened and the parent keys are joined together using a hyphen. Considering the example JSON below:

{
    "Student": {
        "FirstName":"Harry",
        "Surname":"Potter"
    },
    "School":"Hogwarts",
    "House":"Gryffindor"
}

You can access the student's last name in your sequence using {Student-Surname}.

Looks like a pretty cool way to easily use the Emby webhooks. Particularly since it will hook right into IFTTT.

So your flow is:

Emby Server => Sequematic => IFTTT => light bulb in your house :)

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

Sometimes I just need a little nudge to go down the right path.  This looks promising for sure.  I will test it and let you all know what the end result is.  Thanks!  :)

 

Link to comment
Share on other sites

Folks, we have a WINNER!!!  Turns out that I just needed to format the variable name correctly.  The correct format is {Item-RunTimeTicks}.  I was able to identify this with reading the link BillOatman sent me.  Thank you so much!!!  So I kept the Sequematic settings on Schema 3 and just altered the variable to the correct setting, and voila, the lights stay off during the trailers and bumpers!  They come back on when stopping or pausing the main movie only!  Attached is the sucessful log.... This was when I stopped the main movie.

image.png.7aeb950cb81c9b89e64ead918904f92a.png

Link to comment
Share on other sites

BillOatman
4 hours ago, JGWNet said:

Folks, we have a WINNER!!!  Turns out that I just needed to format the variable name correctly.  The correct format is {Item-RunTimeTicks}.  I was able to identify this with reading the link BillOatman sent me.  Thank you so much!!!  So I kept the Sequematic settings on Schema 3 and just altered the variable to the correct setting, and voila, the lights stay off during the trailers and bumpers!  They come back on when stopping or pausing the main movie only!  Attached is the sucessful log.... This was when I stopped the main movie.

image.png.7aeb950cb81c9b89e64ead918904f92a.png

Can you post your custom Sequematic webhook minus your IFTTT link :)  It might help others :)

Link to comment
Share on other sites

This tutorial is for Home automation with the Emby Webhooks plugin using Sequematic.com custom sequence and IFTTT.com applets communicating directly to Amazon Alexa app.  This works with Cinema Intros and Vantage Point plugins to prevent your lights from turning on after trailers or bumpers. 

1.  Register for a free account with Sequematic.com and IFTTT.com.  (If you do not have an Alexa account setup yet, you will need to do that as well)

2.  Sign into your Alexa app and go to (More>Skills & Games).  Select the search spyglass and type IFTTT.  (enable this skill with IFTTT credentials)

3.  After the skill is enabled, you will be asked to search for new devises from that skill. (Make sure you select this)  It will find devises IFTTTrigger-1 through 3 and add them to your devise list.

4.  Log into your new IFTTT.com account and select "Create".

 

image.png.5a6a9e49260c81c105e01fa58b0f52ac.png

 

5. Select "If This" and add your criteria. Do a search for "Webhooks"  and add it.

 

image.png.529e51b7eb14ff549311015f28ee4d2c.png

6.  Select "Receive a web request".

 

image.png.9eafe34853c32dd5aea1cdac88fa4c1b.png

7.  Enter a name for your event.  (Remember that this will be the same name use to call the event from Sequematic.com later)

 

image.png.015d8f7757b26e5d8cd3450eb38962be.png

8.  After you complete this step, now select "Then That" and enter your criteria. (You will be selecting "Alexa Action by mkZense")  Here you will able to link it to your Amazon account.

 

image.png.d75bc2e96d601c5738906fc97d2c34db.png

9.  Select "sendAlexaActionbyMKzense"

 

image.png.9e07decbb51bbed8f5977587aac2b4f3.png

10.  Select the trigger you want to assign it to.

 

image.png.cd7fd9909732b9faf28daef1382ef134.png

11.   When finished select "Continue" and then "Finish".  You have successfully setup your first trigger.  These triggers can be used in your Alexa app you create "Routines".  Please refer to the Alexa app help to receive information on how to create routines, for I will not cover this in the tutorial.

12.  In IFTTT.com, Select you account icon>My Services>Webhooks>Documentation.  There you will find your confidential key.  Copy and save this.  You will need it for later when you set up your Sequematic.com account.

13. Log into Sequematic.com, select "Setting" and paste your IFTTT confidential key into the IFTTT key box, select your time zone and select save.

14.  Now it is time to create your sequence.  Go back to the dashboard and select, new sequence and give it a name.

15.  Select "add step" and "Custom webhook"

image.png.63af91e0fb0865670a199fa22d1c61a1.png

16.  Be sure to select "Schema 3", or none of this will work.

 

image.thumb.png.f02a9e2f91fd0b601824dad9cf617abc.png

17.  Select "Save".  After you hit save, Sequematic will generate an https link that you will cut and past into your Webhooks plugin in Emby.

image.png.249cf5e338734aebeb843f3ce15f3d73.png

18.  Continue to create your sequence by now selecting "Add step", now you will choose "Variables" > "Check variable values".

 

image.thumb.png.3b6667ea8ca0969b457cb57b3da82128.png

19.  This first variable you want to check is "playback.start".  You will use one of your ITFFF triggers for this process.  The finished product should look like this...

image.thumb.png.f63df46328e8c6b9239ed6f6d5231718.png

20.  Now select "Add step" under the previous and choose Webhook>"Call IFTTT".  If you save your IFTTT key  it should automatically populate.

image.png.0ed261a2cf18f20263eb4fc163a85bcf.png

 

21.  The IFTTT Event name will be the name of the event you saved within IFTTT.com service.  "Save and continue to the next step".

22.  From here you will continue to create additional steps to complete the sequence by imputing the data into the "Else" fields.

23.  It is important to have the {Item-RunTimeTicks} variable checked after the {Event} playback.start variable, or this will not work correctly.  After that you can create a variable check for playback.stop, playback.pause, playback.unpause, and playback.scrobble.  Below is the entire sequence for my setup.  This configuration works with "Cinema Intros" as well as "Vantage Point" plugins for a real cinematic experience.

image.thumb.png.25e27e94646e81c24c587d053924e47e.png

Finally - It is important to make sure that your variable name is imputed in the following fashion....

{Event}  -  This is for checking the playback status

{Item-RunTimeTicks}  - If set to "below 6000000000" it will check to see if the video is less than 10 minutes.

Enjoy!!!

 

 

  • Thanks 1
Link to comment
Share on other sites

BillOatman

@JGWNetWow, very detailed, thank you!.  So Alexa is in the mix too.  Previously I had this as the flow 

Quote

Emby Server => Sequematic => IFTTT => light bulb in your house

When in reality it's

Quote

Emby Server => Sequematic => IFTTT => Alexa => light bulb in your house

Do you need the Alexa and IFTTT pieces?  Sequematic claims to support Philips Hue directly.  Unless you are using something other than Hue?

image.png.d4d083d1ba0d9fe930359630886ce404.png

Though getting Alexa to announce "The feature film is about to begin, please silence all electronic devices" on the playback start event would be fun.
That would really irritate my wife and kids :)

Link to comment
Share on other sites

1 hour ago, BillOatman said:

@JGWNetWow, very detailed, thank you!.  So Alexa is in the mix too.  Previously I had this as the flow 

When in reality it's

Do you need the Alexa and IFTTT pieces?  Sequematic claims to support Philips Hue directly.  Unless you are using something other than Hue?

image.png.d4d083d1ba0d9fe930359630886ce404.png

Though getting Alexa to announce "The feature film is about to begin, please silence all electronic devices" on the playback start event would be fun.
That would really irritate my wife and kids :)

This can be setup on almost anything that will take a IFTTT trigger, but under your situation you can bypass and go direct to Phillips Hue.

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