Calling script from automation through template

Until the next release that removes template magic you should be doing this:

action:
  - data_template:
      message: >-
        Dark Outside changed state to {{ states("binary_sensor.dark_outside") }} because of a combination of these values: {{ '\n' -}}
        - Sun Elevation is {{ state_attr("sun.sun","elevation") }} {{ '\n' -}}
        - OWM Cloud Coverage is {{ states("sensor.owm_cloud_coverage") }}
    service: notify.mainplatform
  - service_template: >-
      {% if (is_state("binary_sensor.dark_outside","on")) -%}
        script.driveway_lamp_high
      {%- else -%}
        script.driveway_lamp_off
      {%- endif %}
1 Like