Hello!
I'm struggling with comparing dates.
I would like a function or a node that checks today's date and compares it with a list of dates that i provide. If it matches, an output should go true.
I'm trying to setup my heating system so that it will turn on for 15min before I wake up only on my morning shifts.
Thanks! Amazing community! I love node red
If you do want to do it by comparing today's date with a list then the first problem is getting today's date allowing for your local timezone. You should be able to do that in a function node using const today = new Date().toLocaleDateString()
To check that out try a function node containing just
const today = new Date().toLocaleDateString()
msg.payload = today
return
Trigger that with an Inject node and feed it into a debug node to see what you get. You should get a string containing today's date, using your locale's date format, which you can then compare with your list of dates.
I use node-red-contrib-ical-events version 2.2.2, installed via palette.
The node "Trigger" will check for new events.
You need a iCal / ics / caldav URL or a filepath to ics.
See the docs at
Personally I use a CalDav server, check every 10 minutes for events with an offset of -6 hours.
AFAIR the biggest problem was to get the right name for the calendar in the calendar field.
I use Trigger "Match" for location (Filter property) and then the desired location.
BTW: I use it to get the date for the next garbage collection and then send a Telegram to the family chat.