{Problem}Bigtimer

No, it wasn't you that was boring me. I did go on to take my example further:

It doesn't quite work how I wanted it to but at least I got rid of the subflow & I added in the cron-plus node & a bit of feedback - which is the bit that isn't quite working correctly. Still, you get the idea.

Also, my CRON syntax, while correct for some versions of CRON, were not correct for cron-plus. Here is a more suitable function:

const dt = new Date(msg.payload)

msg.payload = [
    {
        'command': 'add',
        'name': msg.topic,
        'expression': `0 ${dt.getUTCMinutes()} ${dt.getUTCHours()} * * *`,
        'payload': msg.topic,
        'type': 'str',
    },
    {
        'command': 'status',
        'name': msg.topic,
    },
]

return msg

That will replace any previous cron entries with the matching topic name. So you can send both the start and end times to it. It will also output the status for the updated cron entry so that you can attach a flow to the output of cron-plus that can be fed back to your page or anywhere else. When cron-plus fires, you can also take a copy of the output and feed the next trigger time back to your webpage.

2 Likes