Trigger for

how could i transform this in node-red?

thank you

- alias: 'bagnetto off bulb'
  id: bagnetto_off_bulb
    # initial_state: 'on'
  trigger:
  - platform: state
    entity_id: light.bulb_bagnetto
    from: 'off'
    to: 'on'
    for:
      minutes: 30
  condition:
  - condition: state
    entity_id: binary_sensor.motion_sensor_158d0000e733ee
    state: 'off'
  action:
    - service: light.turn_off
      entity_id: light.bulb_bagnetto

Add a stop timer, or a delay node after the trigger, and then do a check state node to verify the trigger is still good.

OR

Use the Trigger: State node and add an output that sends a custom payload of STOP if light goes back off, before the delay node or stoptimer is finished. And use a delay or stoptimer after the state node

like this?

[{“id”:“8a2e704c.64f87”,“type”:“tab”,“label”:“Flow 2”,“disabled”:false,“info”:""},{“id”:“6013dca5.e37c84”,“type”:“switch”,“z”:“8a2e704c.64f87”,“name”:"",“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“on”,“vt”:“str”},{“t”:“eq”,“v”:“off”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:330,“y”:120,“wires”:[[“fb6ddbd1.b7bee8”],[]]},{“id”:“fb6ddbd1.b7bee8”,“type”:“stoptimer”,“z”:“8a2e704c.64f87”,“duration”:“30”,“units”:“Minute”,“payloadtype”:“num”,“payloadval”:“0”,“name”:"",“x”:560,“y”:120,“wires”:[[“89ef1d9c.0239a”],[]]},{“id”:“89ef1d9c.0239a”,“type”:“api-current-state”,“z”:“8a2e704c.64f87”,“name”:“Motion Sensor still on?”,“server”:“28bd13bd.8d60ec”,“version”:1,“outputs”:1,“halt_if”:"",“halt_if_type”:“str”,“halt_if_compare”:“is”,“override_topic”:true,“entity_id”:“binary_sensor.motion_sensor_158d0000e733ee”,“state_type”:“str”,“state_location”:“payload”,“override_payload”:“msg”,“entity_location”:“data”,“override_data”:“msg”,“blockInputOverrides”:false,“x”:460,“y”:240,“wires”:[[“998cbd53.4e5d3”]]},{“id”:“998cbd53.4e5d3”,“type”:“switch”,“z”:“8a2e704c.64f87”,“name”:"",“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“on”,“vt”:“str”},{“t”:“eq”,“v”:“off”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:730,“y”:240,“wires”:[[“fb6ddbd1.b7bee8”],[“f702d4de.763028”,“da15c037.36ac5”]]},{“id”:“3dd6a85c.2c2a58”,“type”:“server-state-changed”,“z”:“8a2e704c.64f87”,“name”:“light Bagnetto on”,“server”:“28bd13bd.8d60ec”,“version”:1,“entityidfilter”:“light.bulb_bagnetto”,“entityidfiltertype”:“substring”,“outputinitially”:false,“state_type”:“str”,“haltifstate”:"",“halt_if_type”:“str”,“halt_if_compare”:“is”,“outputs”:1,“output_only_on_state_change”:false,“x”:128,“y”:113,“wires”:[[“6013dca5.e37c84”]]},{“id”:“f702d4de.763028”,“type”:“api-call-service”,“z”:“8a2e704c.64f87”,“name”:“Luce Bagnetto off”,“server”:“28bd13bd.8d60ec”,“version”:1,“debugenabled”:false,“service_domain”:“light”,“service”:“turn_off”,“entityId”:“light.bulb_bagnetto”,“data”:"",“dataType”:“json”,“mergecontext”:"",“output_location”:“payload”,“output_location_type”:“msg”,“mustacheAltTags”:false,“x”:910,“y”:260,“wires”:[[]]},{“id”:“da15c037.36ac5”,“type”:“api-call-service”,“z”:“8a2e704c.64f87”,“name”:“Led Bagnetto off”,“server”:“28bd13bd.8d60ec”,“version”:1,“debugenabled”:false,“service_domain”:“light”,“service”:“turn_off”,“entityId”:“light.led_bagnetto”,“data”:"",“dataType”:“json”,“mergecontext”:"",“output_location”:“payload”,“output_location_type”:“msg”,“mustacheAltTags”:false,“x”:900,“y”:320,“wires”:[[]]},{“id”:“28bd13bd.8d60ec”,“type”:“server”,“z”:"",“name”:“Home Assistant”,“legacy”:false,“hassio”:true,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”,“connectionDelay”:true,“cacheJson”:true}]

Here’s what I came up with -

[{"id":"cecbb60b.5c47c8","type":"comment","z":"1663a5e8.75665a","name":"state trigger for when bulb goes from off to on","info":"","x":590,"y":280,"wires":[]},{"id":"df9b365e.cd57b8","type":"trigger-state","z":"1663a5e8.75665a","name":"bulb_bagnetto off -> on","server":"26956a45.92d866","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"light.bulb_bagnetto","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"78a7i05h2pt","targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"},{"id":"kwrzzjeoouo","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":530,"y":320,"wires":[["554ce6a2.5eca18"],[]]},{"id":"554ce6a2.5eca18","type":"stoptimer","z":"1663a5e8.75665a","duration":"30","units":"Minute","payloadtype":"num","payloadval":"0","name":"30min","x":790,"y":380,"wires":[["956c5cb.7f807a"],[]]},{"id":"9092d91.e929428","type":"comment","z":"1663a5e8.75665a","name":"Timer starts when bulb turns on.","info":"","x":870,"y":340,"wires":[]},{"id":"956c5cb.7f807a","type":"api-current-state","z":"1663a5e8.75665a","name":"Motion off?","server":"26956a45.92d866","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.motion_sensor_158d0000e733ee","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1170,"y":440,"wires":[["baf6e773.797348"],["554ce6a2.5eca18"]]},{"id":"a8a16765.fc1bd8","type":"comment","z":"1663a5e8.75665a","name":"Check if motion.","info":"","x":1140,"y":380,"wires":[]},{"id":"baf6e773.797348","type":"api-call-service","z":"1663a5e8.75665a","name":"Turn off light","server":"26956a45.92d866","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.bulb_bagnetto","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1450,"y":400,"wires":[[]]},{"id":"ea9dff06.cf741","type":"comment","z":"1663a5e8.75665a","name":"Turn off if not motion.","info":"","x":1480,"y":360,"wires":[]},{"id":"4439be70.9326","type":"comment","z":"1663a5e8.75665a","name":"If you want to check every 30 minutes, loop back.","info":"","x":920,"y":480,"wires":[]},{"id":"26956a45.92d866","type":"server","z":"","name":"Hass.io","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

it is very similar to what I had thought.
in my flow there is an extra condition. mine should work too. I try it and tell you
thanks for now