There is a guide for that. See the Automation section of this Index
The Home Assistant Cookbook - Index.