Best approach - automation for x number of seconds

Recently moved over from Samsung Smartthings and much preferring HA.

I have a question about the best approach to do something.

I have a raspberry pi which controls a device, by calling a rest endpoint with one of 3 commands. e.g. http://host/device/on, http://host/device/off, http://host/device/cancel

I would like an automation that runs at a certain time that calls the “on” endpoint, waits for a number of seconds and then calls the “off” endpoint.

I would also like to be able create a button group to use this too and ideally use it via voice input too.

Any suggestion on how to do this would be great.

Thanks in advance.
Jonathan

Are you looking for help setting up the Rest commands or with the structure of the scripts/automations?

Thanks for your reply. I’ve already set up the rest_commands… it was mainly the setup of the script / automation… i did actually create a script with a delay in the middle. Seems to work but not sure its the best approach.

kitchen_blinds_on:
sequence:
- service: rest_command.kitchen_blinds_up
- delay: 5
- service: rest_command.kitchen_blinds_cancel