ChipChop Support Forum
Log in
Log out
Join the forum
My Details
REPLIES: 2
VIEWS: 230
BACK
REPLY TO THIS POST
pixie dust
06 Feb 2024
Actions question
hey G,

In actions, you can add more targets to the same trigger and I think I get when I could use that but what's the actual logic there? Let say that the first target fails would that break the other targets in the chain?

I've read the api page few times and all I can see is a nasty message about getting account suspended if you make a mistake.

The one and only tiny sentence that mentions anywhere multiple targets is, I quote:

"This allows you to create reasonably complex logic, consider it as a pattern: if » then » then » then"

um, see my problem, what's "then, then then"?
Gizmo
07 Feb 2024

Don't worry about breaking things, ChipChop will slurp your device through the wires (breadboard and all) and sell it on FleeBay to cover the cost of damages...it's a new thing, works like a charm, where do you think I find the money to run all of this 🤟😱😇🤣

No, seriously, the account suspension can happen but it's genuinely not a malicious thing and it's for your own protection. I have once made a tiny slip-up in the code and fired over 3000 requests to the Alexa gateway in the time it took my brain to register the mistake and get my fingers back to the keyboard to kill the program. The gateway was kind enough to issue me slap on the wrist and a small time penalty so ChipChop will do the same.

Ok, Actions logic answer:

1. The "then -> then -> then" simply mans that each target rule will be executed one after another regardless if one fails (i.e. device not connected etc...)
The target rules are in no way chained so it's:

not like this

    if( target 1 == ?){

    }else if (target 2 == ?){

    }else if (target 3 == ?){

    }
    .....

and not like this

    if( target 1 != ?){
        return
    }

    if( target 2 != ?){
        return
    }

    ....

2. There is only one IF that evaluates the target rule and it obeys the If Different? logic. What that means is that the rule will not fire if the target component is already in the state you want to set it to.

What I mean is that if you say Target Light ON and the light is already ON the rule will be ignored. You have to reset the target's state to something different (i.e. OFF) before the rule can set it again to ON.

something like this

    if( target1.state != new_state && target1.is_connected){
        target1.state = new_state
        target1.sendCommand(new state)
    }

    ...... same for all targets

3. If the device is not available at the time, ChipChop will memorise the command so next time the device comes on-line and sends a heartbeat it will receive the cached command with the timestamp when it was issued. You can then decide inside the device code if it's too old and should you act on it.

4. The order of execution is as it's on the screen and there is currently no way to have some secondary IF check on the targets to stop the chain of events

Hope that explains it better but if you are still unsure just ask again with some (most likely) convoluted example and I will try to my best to explain.



pixie dust
07 Feb 2024

Got it. esp also chained to the radiator so no slurping possible...ha ha!