Datetime Functions (specifically timezone) and interaction of multiple Workflows - excuse this train of thought post ;-)


I have a situation where I need to start/stop pumps based on calendars with varying start/stop and cool down periods depending on the day of the week, and (public holidays).

The Time Range node is great at first glance, but is limited to timerange for set days. In addition to I would need many to deal with different timeranges for different days.

I have addressed this with a Data Table that has Day of Week, start, stop, cool down times for each,plus specific calendar days with the same info. I am not lucky , this first project is in NSW so do have to deal with DST.

This makes it easy for mere mortals to see and manage the calendar. The Time Range widget isn;t a date management tool, and would need investigation of many nodes and versioning/pushing new agent workflow.

First thing I noticed is Edgeworkflow is returning everything in UTC.
But the Data Tables are in Local time (meaningful for the end user).
There is no out of the box functionality for Localtime in a workflow. (Easy to fix but messy) without being able to call other workflows means no DRY.

Second the Data Tables are not local, so I need to store them as a JSON object somewhere (workflow storage) locally. Then if they don’t exist perform a HTTP get on a WebHook to retrieve and store.

I can trigger the edge workflow to update the tables based on a command.

But on startup I need to check for existence and fetch. Which is all do-able.

But a few things this highlights.

Complex edge workflows at the moment require a lot of moving parts, so it’s difficult to encapsulate functionality due to missing ability to call workflows and create functions in workflows.

Edge workflows make sense understanding local time (ie where they are, not where the device is viewed from). Day light savings need to be dealt with too.

I will finish on, Edge workflows are great :wink: Saves my writing lots of new python agents, that other staff don’t understand (not programmers) and they can publish to the device, without giving people openvpn access. A big win.

Cheers and thanks for the great work.

Thanks for all the input! We have had a couple people ask us for more comprehensive “time manipulation” abilities in workflows (both for cloud and edge workflows), so we are at least thinking about help on that front.

At the moment, there is one potential avenue that might help you a bit. One thing that I don’t think is covered explicitly in the documentation is the fact that the “Function Node” is much more powerful on the Edge than in the Cloud - since it is your device, we allow much more unrestricted access in the function node. This means that require is actually available and allowed - and the moment JS library is already in the edge agent. This means you can require('moment') inside a function node and manipulate date/time as much as you need. Not nearly as nice as a dedicated node with a nice UI, but it might help get you some of what you need (especially with timezones).

I had seen moment.js but as you said not documented so assumed like cloud workflow it wasn’t available.

It would be good to know what is available in the edge agent, and how one might extend them in a supportable manner.




I just got caught out with Day light savings in NSW, (We don’t have it in Western Australia).

Any way, seeing as you have moment.js in the Edge Agent, could you add moment-timezone ?



Requiring moment works because it happens to be a dependency of the edge agent. Unfortunately, moment-timezone is not a dependency and we don’t anticipate it becoming one any time soon.

You have two options for getting it into your copy of the edge agent …

  1. You could use the Run Executable Node to run npm install moment-timezone, and then you’d have access to it in the Function Node the same way you’re using moment now. The downside here is the module will only be installed in the container, and you would have to run this command every time the container starts up. As you’ve noted in another post, we don’t have an easy way of determining that event within an edge workflow right now.
  2. You could build your own Docker image using our edge agent as the base image, and adding in the commands to install moment-timezone.