Script will not run through automation

Hi,

I’m trying to run the following automation. It works until it hits the script. It does not run and therefore blocks the automation from continuing.

I’ve built the script through the HA UI and can manually activate it. So that should work as intended.

- alias: livingroom_tv_scene_activation_hold
  trigger:
  - platform: event
    event_type: zwave_js_value_notification
    event_data:
      node_id: 9
      value: 22


  action:
  - service: light.turn_on
    entity_id: light.b06_floor_light
  - delay:
      seconds: 0.5
  - service: light.turn_off
    entity_id: light.b06_floor_light
  - delay:
      seconds: 0.5
  - service: light.turn_on
    entity_id: light.b06_floor_light

  - service: notify.pushover_presence
    data:
      title: House
      message: State to 'Away' in 5 minutes.
      data:
        sound: intermission

  - delay:
      minutes: 5

  - service: script.turn_on
    target:
      entity_id: script.1662926313110
  - service: input_select.select_option
    data:
      option: Away
    target:
      entity_id: input_select.house_presence_state

Can you share the script?

Is there anything reported in the Log when this occurs?

What’s reported in the automation’s trace?

alias: Motion Sensors Timer 'off' when 'Away'
sequence:
  - service: python_script.hass_entities
    data:
      action: set_state
      entity_id: binary_sensor.motion_sensor_main_hallway_timer
      state: "off"
  - service: python_script.hass_entities
    data:
      action: set_state
      entity_id: binary_sensor.motion_sensor_kitchen_timer
      state: "off"
  - service: python_script.hass_entities
    data:
      action: set_state
      entity_id: binary_sensor.motion_sensor_kitchen_lighttimer
      state: "off"
  - service: python_script.hass_entities
    data:
      action: set_state
      entity_id: binary_sensor.motion_sensor_attic_landing_timer
      state: "off"
mode: single
icon: mdi:motion-sensor-off

That it runs, untill the script. That keeps running.
“This node was not executed and so no further trace information is available.”

Trace timeline gives: Still running.

You’re waiting 5 minutes before checking the trace right? Your automation has a 5 minute delay before it tries to call the script. It sounds like the automation simply hasn’t gotten to that step yet based on that output.

No, I temporarily removed the delay to not have to wait. :grinning:

Any fresh idea’s?

Have you tried calling your script.turn_on from Developer tools > Services? Is it running properly from there?

And what about calling the script itself directly, instead of calling the script.turn_on service?
I mean, like this:

- alias: livingroom_tv_scene_activation_hold
  trigger:
  - platform: event
    event_type: zwave_js_value_notification
    event_data:
      node_id: 9
      value: 22


  action:
  - service: light.turn_on
    entity_id: light.b06_floor_light
  - delay:
      seconds: 0.5
  - service: light.turn_off
    entity_id: light.b06_floor_light
  - delay:
      seconds: 0.5
  - service: light.turn_on
    entity_id: light.b06_floor_light

  - service: notify.pushover_presence
    data:
      title: House
      message: State to 'Away' in 5 minutes.
      data:
        sound: intermission

  - delay:
      minutes: 5

  - service: script.1662926313110
  - service: input_select.select_option
    data:
      option: Away
    target:
      entity_id: input_select.house_presence_state

Oh. Duh, you’re using script.turn_on. Sorry I haven’t used that in so long I forgot the differences, I always just call my scripts directly like this:

service: script.1662926313110

From the doc on calling scripts:

When calling a script “directly” (e.g., script.NAME) the calling script will wait for the called script to finish. If any errors occur that cause the called script to abort, the calling script will be aborted as well.

When calling a script (or multiple scripts) via the script.turn_on service the calling script does not wait. It starts the scripts, in the order listed, and continues as soon as the last script is started. Any errors that occur in the called scripts that cause them to abort will not affect the calling script.

So if you want the automation to run the script and wait for it to finish before proceeding with the steps that follow you need to call it directly (not using script.turn_on). If you just want the script to run but the automation does not wait for it then use script.turn_on.

Now that being said, you’re saying the script does not run. Have you confirmed that by looking at the traces of the script or are you only looking at the traces of the automation?

Since the automation is kicking off the script to run in parallel it makes sense that it says the script didn’t run yet. The phrasing of that message is a bit odd I’ll admit. This node was not executed and so no further trace information is available. does not really say to me “the script was kicked off to run in parallel”. But still as long as the script is actually running at some point then its working fine.

1 Like

Both commands, turn_on and calling it directly run the script.

So, changing:

  - service: script.turn_on
    target:
      entity_id: script.1662926313110

to:

  - service: script.1662926313110

worked!

2 Likes