How can I automate another service, after pushing a button that starts a shell command?

I have a button that runs a shell command. This is used to manually start/stop my robotic mower.
I have a command_line sensor that gets the status of the mower with a Rest API.

The sensor updates (by scan_interval) every 20 minutes, but when I start the mower, I want it to update after 15 seconds to make sure something actually happened.

Updating the sensor can be done by the homeassistant.update_entity service.
But how can I run this service 15 seconds after the press of the button / running of the shell command?

Instead of calling the shell command from the button action, call a script (scripts are services).

In the script, call your shell command, delay, update your sensor.

I didn’t know about scripts, but that worked just fine. Thanks!

1 Like