{"action":"created","issue":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/1671","repository_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware","labels_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/1671/labels{/name}","comments_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/1671/comments","events_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/1671/events","html_url":"https://github.com/nodemcu/nodemcu-firmware/issues/1671","id":195857245,"number":1671,"title":"FR: cron module","user":{"login":"djphoenix","id":1833493,"avatar_url":"https://avatars.githubusercontent.com/u/1833493?v=3","gravatar_id":"","url":"https://api.github.com/users/djphoenix","html_url":"https://github.com/djphoenix","followers_url":"https://api.github.com/users/djphoenix/followers","following_url":"https://api.github.com/users/djphoenix/following{/other_user}","gists_url":"https://api.github.com/users/djphoenix/gists{/gist_id}","starred_url":"https://api.github.com/users/djphoenix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djphoenix/subscriptions","organizations_url":"https://api.github.com/users/djphoenix/orgs","repos_url":"https://api.github.com/users/djphoenix/repos","events_url":"https://api.github.com/users/djphoenix/events{/privacy}","received_events_url":"https://api.github.com/users/djphoenix/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-15T16:53:25Z","updated_at":"2016-12-15T20:01:00Z","closed_at":null,"body":"As proposal to resolve #1670 \r\n\r\n### Missing feature\r\nCron-like module (with possibility to run repeatable tasks).\r\n\r\n### Justification\r\nThis is very important feature for IoT devices that runs some scheduled tasks (e.g. light controllers with daytime-related switching or dimming).\r\n\r\n### Workarounds\r\nManual handle (e.g. minutely) wallclock-time and compare parts with template. Very complex at all.\r\n\r\nMy propose is to include parser (based on `ets_timer` and `gmtime`) in module and parse schedule list in C-level.\r\n\r\n### API proposal\r\n```lua\r\n-- Every day at 09:00\r\nlocal task_on = cron.schedule('* 9 * * *', function() light.switch(true) end)\r\n-- Every day at 22:00\r\nlocal task_off = cron.schedule('* 22 * * *', function() light.switch(false) end)\r\n-- Remove task\r\ntask_on:unschedule()\r\n-- Re-schedules task to 21:00\r\ntask_off:schedule('* 21 * * *')\r\n-- Replaces task handler\r\ntask_off:handler(function() light.dim(20) end)\r\n```\r\n\r\nDiscussion is welcome."},"comment":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/comments/267428569","html_url":"https://github.com/nodemcu/nodemcu-firmware/issues/1671#issuecomment-267428569","issue_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/1671","id":267428569,"user":{"login":"marcelstoer","id":624195,"avatar_url":"https://avatars.githubusercontent.com/u/624195?v=3","gravatar_id":"","url":"https://api.github.com/users/marcelstoer","html_url":"https://github.com/marcelstoer","followers_url":"https://api.github.com/users/marcelstoer/followers","following_url":"https://api.github.com/users/marcelstoer/following{/other_user}","gists_url":"https://api.github.com/users/marcelstoer/gists{/gist_id}","starred_url":"https://api.github.com/users/marcelstoer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcelstoer/subscriptions","organizations_url":"https://api.github.com/users/marcelstoer/orgs","repos_url":"https://api.github.com/users/marcelstoer/repos","events_url":"https://api.github.com/users/marcelstoer/events{/privacy}","received_events_url":"https://api.github.com/users/marcelstoer/received_events","type":"User","site_admin":false},"created_at":"2016-12-15T20:01:00Z","updated_at":"2016-12-15T20:01:00Z","body":"Sure, would be really nice to have.\r\n\r\n> My propose is to include parser (based on `ets_timer` and `gmtime`)\r\n\r\nYou mean _this_ `ets_timer` https://github.com/pvvx/EspLua/blob/master/app/main/ets_timer.c? Brings back some [bad memories](https://github.com/pvvx/EspLua/issues/2) 😞 \r\n\r\nWould you base this module on SNTP or rtctime?"}}
{"actor":{"display_login":"marcelstoer"}}