Action in automation not working in automation but runs manually

I have an issue I can't figure out, I have an action in an automation:

action: switch.turn_on
metadata: {}
target:
  entity_id: switch.openeo_charger_charger_switch
data: {}

When I run it manually it works, however when it runs as part of the automation script it doesn't work. I can't see any errors (although I am not sure where I should really look to find conclusive proof :sweat_smile: - clicking Traces seems to show it ran). I know it is not giving an error as I have put a notification via email either side of it and both emails get sent, it just isn't throwing the switch when the automation runs.

I don't know what I have got wrong here :face_holding_back_tears:

Closely double check the entity id is correct.

If it is then share the automation trace.

It is correct, if I run it manually it will run. Here is the trace

{
  "trace": {
    "last_step": "action/0/choose/0/sequence/2",
    "run_id": "751ccaacfac317ba4c77ea6b06a9d223",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2026-06-15T10:25:00.236866+00:00",
      "finish": "2026-06-15T10:25:00.884031+00:00"
    },
    "domain": "automation",
    "item_id": "1780153517223",
    "trigger": "time set in input_datetime.ev_charger_start_time",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2026-06-15T10:25:00.236949+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.ev_charger_overnight_schedule",
              "state": "on",
              "attributes": {
                "id": "1780153517223",
                "last_triggered": "2026-06-15T10:18:28.084798+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "EV Charger - Overnight Schedule"
              },
              "last_changed": "2026-06-15T10:23:45.027428+00:00",
              "last_reported": "2026-06-15T10:23:45.027428+00:00",
              "last_updated": "2026-06-15T10:23:45.027428+00:00",
              "context": {
                "id": "01KV5CY0W341XEZF14649TD173",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "id": "StartTime",
              "idx": "0",
              "alias": null,
              "platform": "time",
              "now": "2026-06-15T11:25:00.236656+01:00",
              "description": "time set in input_datetime.ev_charger_start_time",
              "entity_id": "input_datetime.ev_charger_start_time"
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2026-06-15T10:25:00.237565+00:00",
          "changed_variables": {
            "context": {
              "id": "01KV5D0AACEH1GVXW5FNQDNMKS",
              "parent_id": null,
              "user_id": null
            }
          },
          "result": {
            "choice": 0
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2026-06-15T10:25:00.237815+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2026-06-15T10:25:00.237873+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/0/sequence/0": [
        {
          "path": "action/0/choose/0/sequence/0",
          "timestamp": "2026-06-15T10:25:00.238078+00:00",
          "result": {
            "params": {
              "domain": "number",
              "service": "set_value",
              "service_data": {
                "value": 32,
                "entity_id": [
                  "number.openeo_charger_current_limit"
                ]
              },
              "target": {
                "entity_id": [
                  "number.openeo_charger_current_limit"
                ]
              }
            },
            "running_script": false
          }
        }
      ],
      "action/0/choose/0/sequence/1": [
        {
          "path": "action/0/choose/0/sequence/1",
          "timestamp": "2026-06-15T10:25:00.243571+00:00",
          "result": {
            "params": {
              "domain": "notify",
              "service": "haemail",
              "service_data": {
                "message": "Starting Charge",
                "target": "[email protected]"
              },
              "target": {}
            },
            "running_script": false
          }
        }
      ],
      "action/0/choose/0/sequence/2": [
        {
          "path": "action/0/choose/0/sequence/2",
          "timestamp": "2026-06-15T10:25:00.874437+00:00",
          "result": {
            "params": {
              "domain": "switch",
              "service": "turn_on",
              "service_data": {},
              "target": {
                "entity_id": [
                  "switch.openeo_charger_charger_switch"
                ]
              }
            },
            "running_script": false
          }
        }
      ]
    },
    "config": {
      "id": "1780153517223",
      "alias": "EV Charger - Overnight Schedule",
      "description": "",
      "triggers": [
        {
          "trigger": "time",
          "at": "input_datetime.ev_charger_start_time",
          "id": "StartTime"
        },
        {
          "trigger": "time",
          "at": "input_datetime.ev_charger_stop_time",
          "id": "EndTime"
        }
      ],
      "conditions": [],
      "actions": [
        {
          "choose": [
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": [
                    "StartTime"
                  ]
                }
              ],
              "sequence": [
                {
                  "action": "number.set_value",
                  "metadata": {},
                  "target": {
                    "entity_id": "number.openeo_charger_current_limit"
                  },
                  "data": {
                    "value": "{{ states('input_number.ha_scheduled_charge_current') | float }}"
                  },
                  "alias": "Set Charger to Scheduled Current Amount"
                },
                {
                  "action": "notify.haemail",
                  "metadata": {},
                  "data": {
                    "message": "Starting Charge",
                    "target": "[email protected]"
                  }
                },
                {
                  "action": "switch.turn_on",
                  "metadata": {},
                  "target": {
                    "entity_id": "switch.openeo_charger_charger_switch"
                  },
                  "data": {},
                  "continue_on_error": true
                }
              ]
            },
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": [
                    "EndTime"
                  ]
                }
              ],
              "sequence": [
                {
                  "alias": "If EV Full Charger mode set, wait until car finishes charging",
                  "if": [
                    {
                      "condition": "state",
                      "entity_id": "input_boolean.ev_full_charge",
                      "state": [
                        "on"
                      ]
                    }
                  ],
                  "then": [
                    {
                      "if": [
                        {
                          "condition": "state",
                          "entity_id": "sensor.openeo_charger_charger_state",
                          "state": [
                            "charging"
                          ]
                        }
                      ],
                      "then": [
                        {
                          "wait_for_trigger": [
                            {
                              "trigger": "state",
                              "entity_id": [
                                "sensor.openeo_charger_charger_state"
                              ],
                              "from": [
                                "charging"
                              ]
                            }
                          ],
                          "alias": "Wait for charger to stop charging"
                        }
                      ],
                      "alias": "Is the charger still charging?",
                      "enabled": true
                    },
                    {
                      "type": "turn_off",
                      "device_id": "2e337b7bb5db48ded190fcf59747bb78",
                      "entity_id": "4e435b5affb1c900493a88f4015f78d2",
                      "domain": "switch"
                    },
                    {
                      "action": "input_boolean.turn_off",
                      "metadata": {},
                      "target": {
                        "entity_id": "input_boolean.ev_full_charge"
                      },
                      "data": {}
                    }
                  ],
                  "else": [
                    {
                      "type": "turn_off",
                      "device_id": "2e337b7bb5db48ded190fcf59747bb78",
                      "entity_id": "4e435b5affb1c900493a88f4015f78d2",
                      "domain": "switch"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01KV5D0AACEH1GVXW5FNQDNMKS",
      "parent_id": null,
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "EV Charger - Overnight Schedule",
      "message": "triggered by time set in input_datetime.ev_charger_start_time",
      "source": "time set in input_datetime.ev_charger_start_time",
      "entity_id": "automation.ev_charger_overnight_schedule",
      "context_id": "01KV5D0AACEH1GVXW5FNQDNMKS",
      "domain": "automation",
      "when": 1781519100.2370398
    }
  ]
}

If by "it" you mean you are running just that one action then there must be a fault with your choose logic. Unfortunately I'm on my mobile at the moment and it is too difficult to to decipher on a small screen. Try sharing the full automation yaml.

If you are in the automation editor, click the run, and it works, but won't trigger 'in the wild', then the problem is with the trigger you designed. Clicking 'run' ignores your triggers and just runs it. Is this sound like what is happening?

As Tom sai the automation YAML might be helpful.

According to the trace, it triggered at Starttime so it chose the first choice in the choose where it set the number entity to 32, sent an email and set the switch entity to on.

You said it works when you run it manually. However, you'll need to explain how that's possible because your automation's actions is designed to do nothing unless explicitly triggered by either of its two triggers.

It contains a choose with two choices that check if trigger.id is the start or end time. When you execute the automation manually, trigger.id has no value. So neither of the choose choices would be selected.