Proper way for local endpoint with variable payload to trigger rule machine rule if variable changes?

Hi,
I am using blue Iris license plate reader with a web hook to a hubitat local endpoint and pass the license plate as a variable to hubitat.
I would like to trigger different actions depending on which license plate is recognized and passed to hubitat.
What's the best way to do that?

What I have right now seems a bit convoluted.
I have created a local end point with a global habitat variable and added that as a web request in Blue Iris and that's working. 192.168.1.xx/apps/api/2xxx/trigger/setHubVariable=VAR-BI-LPR:&PLATE?access_token=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx
I created a hub variable in settings - variables "Var-BI-LPR".
Then I created a condition if VAR-B_-LPR changes, trigger local endpoint.
Then an if clause if license plate Car-A is recognized do action A. If license plate Car-B is recognized do action B.
Is there a better way to do this? Can I do this with a local variable instead of a hub variable? I have not found how to do the "if viable X changed" for a local variable.

Your required expression probably isn't doing much; it's a state that must be true in order for your rule to trigger, and "changed" isn't really a state (probably shouldn't be allowed in this context, perhaps a UI oddity).

I think what you really want to do is trigger on the variable changed (which is allowed and does make sense). Then, you need to find some way to set this variable. You could use another rule for that, but nowadays I'd probably have your external source trigger a Maker API endpoint instead, as IMHO, that's a bit more straightforward (though either can work).

If your rule triggers every time the endpoint is triggered to set the variable (I don't know off the top of my head if that happens...), you'll need something else, and a required expression could help with that, but I'd start there and see if it works!

Thank you!

So here is what I have now:
Rule 1: Endpoint Trigger to set variable
Rule 2: Monitor variable for change.

Any thoughts on if this is the right way or can I do this better?


I'm a little confused as I thought you had a single variable that stored the last plate read, but it looks like you might have three variables and are comparing them to some value that indicates current or maybe recent detection for that particular value. If that's the case, that should still be good, though then I'm not sure how your first rule to set what appears to be only a single variable works. (The redactions might make this harder to see.)

Your second rule is also written a bit unusually. Will only one if the conditions be true at a time? If so, you can use ELSE-IF instead of a simple conditional IF nested inside an ELSE (same logical outcome, fewer clicks and easier to read). Or are you trying to test for the three conditions independently? If so, you'll need separate IFs or IF THEN...END-IFs for each of them, as only exactly one "branch" inside your IF THEN ... END-IF above (or any you write) will execute.

That being said, if you have a way to test this (manually hitting the endpoint with whatever value?), you can see if it works as you expect, which might be the easiest way to get your answer if none of the above screams wrong to you. :slight_smile: If not, enable all logging for the rule and see if "Logs" can help you figure it out, or share more information (perhaps those plus some of the above) if not. Good luck!

Ahh, didn't know how to add "else if".
There is only one hub variable Var-BI-LPR that can have 3 values, LP CARA, CARB and CARC

ELSE-IF is in the menus where you added IF THEN in the first place. But if your rule works as-is,no reason to change!