Script get stuck once in a while

Hi all,

I have the following script but it get stuck once in a while and i have to restart to return to normal. The script runs fine when it doesn’t get stuck.

Any idea of why? Thanks in advance.

image

heat_gas_on:
  mode: restart
  alias: heat_gas_on
  # variables:
    # warning_output: input_number.inverter_warning_output
  sequence:
  - choose:
    - conditions:
      - condition: template
        value_template: '{{ states(''sensor.inverter_1_load_power'') | float + states(''input_number.inverter_warning_output'') | float / 4 >= states(''input_number.inverter_warning_output'') | float or states(''sensor.inverter_2_load_power'') | float + states(''input_number.inverter_warning_output'') | float / 4 >= states(''input_number.inverter_warning_output'') | float or states(''sensor.battery_power'') | float <= states(''input_number.inverter_warning_output'') | float * -2 }}'
      sequence:
      - delay: 00:00:01
    - conditions:
      - condition: time
        after: '22:39:00'
        before: '23:00:10'
        weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
        - sat
        - sun
      sequence:
      - delay: 00:00:01
    - conditions:
      - condition: time
        after: '00:40:00'
        before: '01:00:10'
        weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
        - sat
        - sun
      sequence:
      - delay: 00:00:01
    default:
    - condition: or
      conditions:
      - condition: state
        entity_id: group.is_home_1st
        state: 'on'
      - condition: state
        entity_id: group.is_home_2nd
        state: 'on'
    - wait_template: '{{ is_state(''group.windows_1st'', ''off'') and is_state(''group.windows_2nd'', ''off'') and is_state(''group.doors_exterior'', ''off'') }}'
      timeout: '00:01:45'
      continue_on_timeout: false
    - data:
        hvac_mode: heat
        temperature: '{{ states(''sensor.tstat_main_heat_target_value'') }}'
      target:
        entity_id: climate.living_room_homekit
      service: climate.set_temperature
    - target:
        entity_id: input_boolean.hvac_by_automation
      service: input_boolean.turn_on
    - service: script.turn_on
      target:
        entity_id: script.heat_gas_on_turn_electric_heater_off

I can’t see any loops

Correct, most of them time the script runs fine. It just once in a while it get stuck at below part

    - data:
        hvac_mode: heat
        temperature: '{{ states(''sensor.tstat_main_heat_target_value'') }}'
      target:
        entity_id: climate.living_room_homekit
      service: climate.set_temperature

The wait_template just before the service call waits for up to one minute and forty-five seconds for its condition to become true. If the time expires but the condition remains false, the script’s execution ends (because continue_on_timeout is set to false). Your trace indicates running_script: false which means the script is no longer executing.

Are you saying the wait_template waits forever?

I don’t need it to wait forever. The issue is even I try to click cancel, it doesn’t do anything and I have to restart the system.

It looks like this is where the problem is, I just need to turn on the central furnace once the doors and windows all closed if they are open.

Let me try to do below

timeout: ‘00:01:45’
continue_on_timeout: false