Script not executing

I have a switch defined in my configuration.yaml, with on/off commands defined which work well when I switch the device on/off from the HA web page.
I have written a script to power cycle the switch, but when I activate the script (e.g. from the HA web page) nothing happens - the switch is not power cycled.
Any idea why this script does nothing:

power_cycle_study_cam:
  alias: Power cycle study camera
  sequence:
  - service: switch.turn_off
    data:
      entity_id: switch.study_cam
  - delay:
      seconds: 3
  - service: switch.turn_on
    data:
      entity_id: switch.study_cam

get rid of the “data:” heading and decrease the indent of “entity_id: switch.study_cam” by two spaces. I know the documentation shows to use “data:” but I’ve only ever used it for lights which have additional data such as brightness, color, etc.

power_cycle_study_cam:
  alias: Power cycle study camera
  sequence:
    - service: switch.turn_off
      entity_id: switch.study_cam
    - delay:
        seconds: 3
    - service: switch.turn_on
      entity_id: switch.study_cam

Thanks. So it now looks like this, but still doesn’t do anything:

power_cycle_study_cam:
  alias: Power cycle study camera
  sequence:
  - service: switch.turn_off
    entity_id: switch.study_cam
  - delay:
      seconds: 3
  - service: switch.turn_on
    entity_id: switch.study_cam

???

The yaml validates so it’s not a formatting issue. Is that the name of the switch as seen on the services tab from the frontend? I’m assuming you reloaded scripts or rebooted HA after making the changes?

Yes that’s how the switch is listed on the States page of the web GUI. I stopped/started HA after modifying scrpts.yaml

is there anything in the HA log that shows an error or that the script actually fired?

Hmmm…strange…there is a message saying “Command failed: curl -u …”

I also get that same message when I turn the switch on/off directly from the HA GUI (rather than running the script), but when I turn off the switch directly, rather than via the script, the command does actually work.

Maybe the error handling for the script is preventing the curl command from executing, whereas firing off the same curl command from the Switch panel on the GUI doesn’t?

The curl command is:

curl -u "[email protected]:password" -X POST -H "Content-Type: application/json" -d "{\"id\":mydeviceid}" https://mihome4u.co.uk/api/v1/subdevices/power_on