I would like to use IFTTT to trigger an automation.
In the past I’ve used scripts for this, but the automation I’m building requires a number of ‘or’ conditions, and HA throws up errors that I can’t use conditions in scripts (the documentation here disagrees, but at any rate… I get the errors)
My next thought was to use IFTTT to trigger an event (as described in this post) but that’s where I’m stuck. Can I make custom “events” and trigger them using IFTTT?
First, you absolutely CAN use a condition in a script. They are used somewhat differently than they are in automations however.
If you wanted to create a custom event, you would have to go to the developer tools, but I think that’s barking up the wrong tree.
IF you absolutely need the conditions that are supported in a trigger, you could write a trigger that initiates the script if all the conditions are met. Then, you could trigger that automation using IFTTT with an API call to /api/services/automation/trigger
Hm, perhaps you can help me understand better, then? If conditions in scripts are just as possible as in automations, I’d prefer to do things that way because that’s what I’m most familiar with.
I have a physical toggle switch (no on/off, just toggle) that controls a few lights in a room via ifttt - but the problem is if one light is on and the other is off, “toggle” will just turn one off and the other on. I want the script to instruct home assistant to turn the lights off if one or more are already on, and on if they are all off.
Friendly folks in gitter suggested I use two automations that both use the same trigger to get this “if/then, else” logic. Since I am using IFTTT to toggle scripts instead of automations, I set it up like this.
The idea is that IFTTT will trigger toggle_living_room_lights_0, which will in turn toggle the other two scripts. Depending on the state of the lights in the room, one of the two scripts will fail to meet the conditions and stop. The other will carry out the desired action.
But this setup gives me errors in the log saying scripts can’t use conditions.
However, I would do this all with one script instead.
You can use a service_template to determine which service to call. There’s a good example of it here:
Wow, the example for service_template is exactly what I needed. I’m still learning the proper syntax for templating (not a computer languages person - is it a specific language? Have no idea what function the specific ==s and {} have) but am anxious to teach myself more slowly - examples like this for learning practical usage are invaluable!