Move logic into alarm template.