ruleset town_crier { meta { name "times" use module io.picolabs.plan.apps alias app shares time } global { time = function(_headers){ app:html_page("manage times", "", <<
ent:id = #{ent:id.encode()}
#{schedule:list().map(function(v){ <<#{v.encode()}>>}).join("")} >>, _headers) } } rule start { select when town_crier factory_reset if ent:id.isnull() then noop() fired { ent:time_installed := time:now() schedule time event "top_of_the_hour" repeat << 0 * * * * >> attributes { } setting(id) ent:id := id.typeof()=="Map" => id{"id"} | id } } rule hearTheCry { select when time top_of_the_hour fired { ent:time_last_hour := time:now() } } }