Need some help converting an automation

Hi,

I’ve been moving my automations from YAML to Node-Red the last day or so (very nice to use) but with the DIY site down; i’m having some issues getting info on how the messages are passed from one to another. One automation i’m trying to convert is for a timer I have on a fan. I can get the number from the slider and see the payload; but i’m not sure how to parse it in Node-red to have that number be set as a delay.

This is the working yaml automation; would someone be able to walk me through it for node-red? For some reason I can’t see how to link the time to delay as a vairable.

Also on a side note; is there usually a slight delay between Node-red automations and yaml ones? Running this on HASS.IO all from a Pi3 so not sure if it is the pie struggling or just the way it is.

Thanks,

- id: man_cave_fan_timer
  alias: 'Man Cave Fan Timer'
  trigger:
    - platform: state
      entity_id: input_boolean.fantimer
      from: 'off'
      to: 'on'
  action:
    - service: homeassistant.turn_on
      entity_id: switch.man_cave_fan   
    - delay: '00:{{ states.input_number.mancavefantimer.state | int }}:00'
    - service: homeassistant.turn_off
      entity_id: switch.man_cave_fan
    - service: input_boolean.turn_off
      entity_id: input_boolean.fantimer

I’m sorry I have no idea how to help, just wanted to say I LOVE your Man Cave Fan Timer entity name :slight_smile:

I think thats Pi, I run nodered on docker HA and no noticable lag but I went straight nodered for the most part so dont have a ton of history of yaml to nodered for my setup.

haha, thanks @lolouk44,

I ended up solving this myself so leaving this here for anyone else who may need it. Had to use a template to convert the msg.payload to msg.delay, and then used the delay node and selected “set delay from msg.delay”. Only issue I had at first was my timer is in minutes but when sending a msg.delay it goes in milliseconds. Created a function node to convert the milliseconds to minutes by multiplying the payload by 60000.

Here is the code in the function node

msg.payload *= 60000;
return msg;

And template. Note: I have the property flag set to msg.delay

 {{payload}}

And the sequence