Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best Practices with HttpTrigger
In the past, I have set up a separate httptrigger for everything I wanted to control.

I'm now adding a bunch of Httptrigger commands (~150). So I decided to paramater(ize) so all my http commands are sent to one web address (plus parameters). I only need a single HTTPtrigger action which then passes the parameters to a Global Act which parses the parameters and takes action.

I'm now wondering if I am creating bottlenecks by only using one HTTP trigger action and one Global Act.

1. Assuming multiple people send HTTPtriggers at the same time, would I be better having more HTTP trigger actions? 

2. Should I break up my (~150) actions into multiple Global Acts? If so, how many commands would be a good number for a single Global Act?

Or does it not matter?

Thanks, Richard
My Other web server is Dropbox.
What you generally want to avoid is running some huge action, 90% of which is irrelevant to any given invocation. The optimal way to parameterize global actions is when you can do a simple substitution. So, it's one thing to have a single one that handles on for every light, if all you need is to pass the light name and the command becomes:

Devices::FieldWrite(MyLights.LGHT#[parametergoeshere], True, True)

So all you need to do is put the light name passed into a field write, and it works for all lights. That's a big win scenario for parameterization. For that, it's not worth having a global actions. Just do that in the trigger action.

Beyond that, if you have one that does a fairly specific job, something like sending the required IR commands to select a TV channel. That I'd just make a separate trigger command. There again, unless I had to use this logic from multiple places, I wouldn't bother with a global action if it comes out to be a handful of commands. If it comes out 25 commands, then I'd probably break it out on the chance it might be needed from more than one place later.

If, OTOH, you end up with fifty If statements to find the handful of actual commands that are required for any one invocation, then that's not a good use of parameterization.

The trigger driver will run incoming actions sequentially. So whoever gets in first goes first, and the next one has to wait. That's why it would be best to have one instance of the driver per room or remote control input. That way they can run their own independent commands without conflict. It's fine if you invoke two commands and they run back to back and the first one takes 5 seconds to complete. You are there waiting for whatever you invoked to complete. But if someone is in another room and gets delayed by 5 seconds, it will seem unresponsive to them, since they don't know why it's happening.

I guess to really give specific advice I'd have to have some idea what actual separate jobs are being done now by this conglomerated action.
Dean Roddey
Explorans limites defectum
This is exactly what I needed to know. Thanks for the great explanation.

I wrote this for my own benefit, but am adding it in case it could help anyone else.

HTTPtrigger Strategy

I want to avoid bottlenecks with multiple simultaneous calls on any single action. So I don't want to load all my commands into a single httptrigger action or global action. But I also don't want to tediously replicate commands every time I update actions that are duplicated in multiple locations. Therefore my strategy is to write an httptrigger for each A-V Room. Put the commands in the httptrigger action, but use variables in the action for everything that changes from room to room. Then, when I update or modify, I can simply replace the commands for each room with the updated commands, while keeping the necessary variables.
My Other web server is Dropbox.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Best Practices for PlayWav RichardU 20 7,151 02-21-2018, 08:22 AM
Last Post: RichardU
  HTTPtrigger RichardU 4 1,844 01-05-2018, 08:45 PM
Last Post: RichardU
  Best practices for reusing multiple layers? pbohannon 6 2,987 06-10-2014, 06:35 AM
Last Post: Dean Roddey
  Whole Home Audio best practices Bal 15 4,124 02-28-2013, 10:36 AM
Last Post: Bal
  Good Practices Question (for driver's development) rocker 5 2,027 08-04-2009, 12:12 AM
Last Post: Dean Roddey
  Portable and reusable templates - good practices rocker 2 1,486 06-04-2009, 09:01 AM
Last Post: rocker
  Best practices for CQC + whole house audio? js19707 9 3,944 05-23-2009, 07:03 PM
Last Post: kayemsi

Forum Jump:

Users browsing this thread: 1 Guest(s)