Search code examples
functiontimernode-redsuspend

Suspend Time Based on Holidays Node Red


I'm trying to suspend the eztimer node by an input of the holiday (Feiertage) - Node. The Holiday node sends every day at 00:01 a boolean value if today is a holiday or not. It's possible to suspend the timer by putting a message.suspend true or false. So I've already tried a function with transform the msg.payload to msg.payload.suspend but it was not working. Then I tried to use the change function to set msg.payload.suspend from msg.payload - but it's also not working. I always get from the time the input is not supported.

tested function node:

var test = msg.payload;
msg.payload.suspend = test;
return msg;

change node

Flow how it should look like


Solution

  • You need to use the "Move" verb in the change node not the "Set" (Festlegen) verb.

    And the function node should be:

    msg.payload = {
        suspended: true
    }
    return msg
    

    In the old version you are trying to set the suspend field on what is probably a number (assuming you are using an inject node to trigger it). You can't do this, so you need to replace it with an object.