Issue Running Home Assistant Script Outside the App (Widget, Control Center, Shortcut on iPhone)

I’m encountering an issue when trying to run a script outside the Home Assistant app. I’ve created a simple script to turn on or off the dining room light. The script works perfectly fine when run within the Home Assistant app, but I’m having trouble when attempting to trigger it outside the app. Here’s what I tried:

  1. Added a widget on the desktop with the script and tried to run it.

  2. Added a button in the control center linked to the script.

  3. Created a shortcut with the script and ran it via the Shortcuts app.

Unfortunately, none of these methods worked. I also noticed that none of them generated any logs in Home Assistant, so I can’t pinpoint where the problem might be.

When running the script via the shortcut, I receive an error indicating that it didn’t finish executing in time. I’ve attached a screenshot of the error message below.

Has anyone else experienced this issue, or does anyone have suggestions on how to troubleshoot this further? Any help would be greatly appreciated. Thank you!

alias: "Meal light "
sequence:
  - action: light.toggle
    metadata: {}
    data: {}
    target:
      device_id: 198d161390376cf7db9e4dba0f0a5054
  - choose:
      - conditions:
          - condition: state
            state: "on"
            entity_id: light.dinning_light_mss510x_main_channel
        sequence:
          - action: light.turn_off
            metadata: {}
            data: {}
            target:
              device_id: cefee030501d4e3b4029c9c20c12bdb9
      - conditions:
          - condition: state
            state: "off"
            entity_id: light.dinning_light_mss510x_main_channel
          - condition: or
            conditions:
              - condition: sun
                after: sunset
              - condition: state
                state: snowing
                entity_id: weather.forecast_home
              - condition: state
                entity_id: weather.forecast_home
                state: cloudy
              - condition: state
                entity_id: weather.forecast_home
                state: rainy
        sequence:
          - action: light.turn_on
            metadata: {}
            data: {}
            target:
              device_id: cefee030501d4e3b4029c9c20c12bdb9
description: Switch lights for meal time
icon: mdi:silverware

You need specific home assistant widget for it to work.

Finally, I got it solved. There are two ways to fix this issue:

  1. As @WallyR suggested, I created an action that runs the script. You can then either add the action widget to the Home Screen or create a shortcut that performs this action, and add this shortcut to Control Center if you want to add it to the Control Center.

  2. This is actually a bug (I guess) when you change the script name after creation. To fix this, simply delete the script and recreate it. After reloading, you can run the script either from the script widget on the Home Screen or by adding the script button to the Control Center.

Hope this helps anyone facing the same problem!