Node red start timer duration

In home assistant, I have an automation that sets a timer duration to the value of an input number and starts the timer. It works. How do I make the same automation in node red? I tried a yaml to json converter without success.

action:
  - service: timer.start
    entity_id: timer.occupancy_office
    data:
      duration: '{{ states(''input_number.occupancy_office_timer_duration'')|int * 60}}'
  - service: input_boolean.turn_on

Hi,
I have the same usecase and it is not possibile with the standard stop timer node in node-red afaik. I used this third party node for it:

You can pass a delay property to it, which will be the actual delay of the timer. This you can get with a current-state node from any input_number entity.

image

[{"id":"1e81b5b6.4c6f9a","type":"inject","z":"ffbd7f06.4a014","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":186,"y":1744,"wires":[["a6f14aa8.98c278"]]},{"id":"a6f14aa8.98c278","type":"api-call-service","z":"ffbd7f06.4a014","name":"","version":1,"debugenabled":false,"service_domain":"timer","service":"start","entityId":"timer.occupancy_office","data":"{ \"duration\": $number($entities(\"input_number.occupancy_office_timer_duration\").state) * 60}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":352,"y":1744,"wires":[[]]}]

or

[{"id":"1e81b5b6.4c6f9a","type":"inject","z":"ffbd7f06.4a014","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":186,"y":1744,"wires":[["a6f14aa8.98c278"]]},{"id":"a6f14aa8.98c278","type":"api-call-service","z":"ffbd7f06.4a014","name":"","version":1,"debugenabled":false,"service_domain":"timer","service":"start","entityId":"timer.occupancy_office","data":"{ \"duration\": \"{{ states(''input_number.occupancy_office_timer_duration'')|int * 60}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":true,"x":352,"y":1744,"wires":[[]]}]
3 Likes

@Kermit , does your approach no long work? I’m getting an API error when trying to use the lower example.

UPDATE: the upper example works fine… :slight_smile:

1 Like