Creating Add Calendar Events to Local Calendar in HA Using Node Red

Hi All,

I am hoping someone might be able to help me with a flow I want to implement.

Here is the scenario:

My garbage is normally collected every Tuesday, but if a holiday falls on a Monday, or Tuesday, garbage is collected on Wednesday.

I have the Holidays addon installed in Home Assistant, with a Holiday helper called ‘Observed Holidays for Garage Collection’ that has specific holidays that garbage is not collected in it.

The state of the Holiday helper returns how many days until the next observed Holiday. (Example: ‘17’ *17 days until Memorial Day)

I also have a local calendar called “Garbage Collection”, that is empty.

What I would like to do is create a flow in Node Red that

  1. Runs every Wednesday at 12:00am
  2. Checks if the upcoming Monday or Tuesday is a Holiday, by checking if the Holiday Helper state has a value of 6 or 7 (6 days from Wednesday would mean that upcoming Monday is a observed holiday, and 7 days from Wednesday would mean that upcoming Tuesday is a observed holiday)
  3. If the value is not a 6 or 7, create a Calendar event in Home Assistant for Garbage Collection for upcoming Tuesday (Normal Garbage Collection day)
  4. If the value is a 6 or 7, create a Calendar event in Home Assistant for Garbage Collection for upcoming Wednesday (Holiday Garbage Collection day)

I have basically already created a ‘Injector’ node to trigger the automation on Wednesdays at 12am that calls one ‘Current State’ node that checks the Holiday Helper state to see if has a value of 6, and another to check if the value is 7.

What I am having an issue with is steps 3 and 4 from above. How do I create an add Calendar Event in my ‘Garbage Collection’ local calendar? And how do I determine what date a Tuesday or Wednesday may fall on?

Any help would be greatly appreciated

As you know the time that the flow runs, you can just add 6 or 7 days to the time.

Not sure how you set the HA calendar , but you can use moment in the change node and some HA nodes accept JSONata to.

Maybe this example will give you some insparation

[{"id":"492ced198b087d18","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"6","payloadType":"num","x":170,"y":1580,"wires":[["72413ce2c0bb905c"]]},{"id":"72413ce2c0bb905c","type":"switch","z":"b9860b4b9de8c8da","name":"","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"6","vt":"num","v2":"7","v2t":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":330,"y":1600,"wires":[["ceb2e38bd3e5e6eb"],["7a6b1a26470d8c4d"]]},{"id":"098641393298e40d","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"7","payloadType":"num","x":170,"y":1620,"wires":[["72413ce2c0bb905c"]]},{"id":"4e5f8405924e4ce4","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"5","payloadType":"num","x":170,"y":1660,"wires":[["72413ce2c0bb905c"]]},{"id":"ceb2e38bd3e5e6eb","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$moment().add(7, \"days\").tz(\"Europe/London\").format()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":1580,"wires":[["404d48aea04129ae"]]},{"id":"7a6b1a26470d8c4d","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$moment().add(6, \"days\").tz(\"Europe/London\").format()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":1620,"wires":[["404d48aea04129ae"]]},{"id":"404d48aea04129ae","type":"debug","z":"b9860b4b9de8c8da","name":"debug 291","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":710,"y":1600,"wires":[]}]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.