#Using the output of a script in an automation condition

1 messages · Page 1 of 1 (latest)

edgy dust
#

In my calendar, I set the location of (some) appointments to either a lat/lon combination, or to a zone (like: zone.shop). I have a script that calculates the distance between that location and my location, to see if the car's heater should be turned on or not, depending on the distance to travel.

How can I call that script when running the automation, and use its output as a condition? Like: If the distance is more than 40 miles, turn on the air conditioning 1 hour before the appointment, else 15 minutes.

fathom hinge
#

Scripts can return values that can be used in conditions via templates

edgy dust
#

How can I call my script 'before' checking condition(s)?

#

(or call it 'in-line' in the condition?)

fathom hinge
#

You need to do it in the action section

#

Then put a condition after to check the response

#

Or choose or if/then

edgy dust
#

Hmmm, so it can't go in the conditions section. Ok, that would be a nice addition 🙂 Thanks for the pointer!

fathom hinge
#

It's basically the same thing

edgy dust
#

Something like this?

#
  distance: "{{ script.distance(trigger.description, chrinsig.location).distance }}"
#

Does not seem to work 🙁

fathom hinge
#

Not close

#

Make the script return a result as shown in the link. Call the script in the action with a response_variable. Use that variable in a condition