irritanterik / homey-http-request-actions

HTTP request actions for flows on Homey by Athom
16 stars 14 forks source link

JSON data to (better)logic Homey #27

Closed Patrick1610 closed 5 years ago

Patrick1610 commented 5 years ago

Hi,

I want to integrate Tautulli with Homey and control my lights by doing the following. On a certain watched percentage, I let Tautulli sent a POST (WatchedPlex) to Homey, this works fine. I let Tautulli sent the following JSON data with the post:

{remaining_duration} | The remaining duration (in minutes) of the stream.

I want Homey to save the remaining time as a variable (logic of better logic) so I can use that duration for my lights. I think this should be done with the A80 card. What should I fill in?

Thanks in advance!

irritanterik commented 5 years ago

Native Homey Logic is not yet supported so way to go for now is card A80.

What is the exact post request? If T30 then A80 If the json body is {remaining_duration: 50} the correct JSONpath expression would be $.remaining_duration

Patrick1610 commented 5 years ago

img_1dbf3d987615-1 img_0523 img_0524

Thanks for thinking with me!
I have now set it up like this, but the Better Logic value does not change at all with this setting either.

Also, when I run a test notification with just "5", the value does not change

I thought, the {remaining_duration} tag from tautulli is a placeholder and just becomes the number of minutes. With the started notification, I only see "Star Wars|, not "{Movie_title: Star Wars}".

irritanterik commented 5 years ago

{5} is not a valid JSON formatted body and can't be parsed successful with my app unfortunately. You could do a last try with JSONpath $[0]. That could extract a number from within straight brackets like [5].

Patrick1610 commented 5 years ago

Alright! I also see I can manually edit the JSON Body from within Tautulli.

Does that give me more possibilities? Can I make a JSON body that works, with the {remaining_duration} tag in it?

EDIT: added screenshots

screenshot 2019-02-22 at 14 16 03 screenshot 2019-02-22 at 14 16 16
Patrick1610 commented 5 years ago

Here is a screenshot of a standard JSON body that is used on a movie start event.

screenshot 2019-02-22 at 14 31 20
irritanterik commented 5 years ago

Try:

{
  "remaining_duration": {remaining_duration}
}
Patrick1610 commented 5 years ago

Thanks! I added that on the automatic 'Watched notification', and nothing happened. But.. When I sent the following as a test notification, it does work:

{ "remaining_duration": 5 }

So I guess the problem is with the output of the {remaining_duration} tag? Or could I try something else?

Patrick1610 commented 5 years ago

Also, is there any difference in using GET or POST for my usage? Currently I use POST (don't know why, but it works.. 👍 )

Patrick1610 commented 5 years ago

I got it! The following command works!

{ "remaining_duration": "{remaining_duration}" }

Thanks for helping, you're the best! Now the lights wil dim slowly on during the movie credits 👍

irritanterik commented 5 years ago

Great! Have fun!