Help converting Lights with Motion and Condition from HA automation to Node Red

Good morning everyone. The HA automation is working just fine, no issues at all i am just moving everything to Node Red.

I am trying to convert the below HA automation to Node Red. The part that i am not able to make work is the condition that the light switch MUST have been off for 1 second before it can run again. I can not for the life of me figure out how to add that condition in a Node Red flow. Any suggestions/help would be greatly appreciated! If i didnt provide enough information i apologize and i can provide anything you might need just let me know.

- id: '1590600465824'
  alias: Kitchen Light ON With Motion
  description: ''
  trigger:
  - entity_id: binary_sensor.presence_9
    platform: state
    to: 'on'
  condition:
  - condition: device
    device_id: ac4944e272d746ca9dfe3fbab818241f
    domain: switch
    entity_id: switch.kitchen_light
    for:
      hours: 0
      minutes: 0
      seconds: 1
    type: is_off
  - after: 06:00
    before: '20:00'
    condition: time
  action:
  - data: {}
    entity_id: switch.kitchen_light
    service: switch.turn_on

you can check if the light is off with current state node but not quite sure why you need to be off for exactly 1 second off? you will have 1 second of darkness when you are moving around.

I need the pause from on->off-> On because our kitchen lighting system has a night light feature. The feature activates by toggling the switch on/of/on within 2 seconds. The problem is when I build the flow in node red there are certain situations where the lights will turn off and at that perfect time someone walks back in the kitchen and the lights turn on resulting in the night lights turning on instead of the regular lights. It doesn’t happen all the time (the timing has to be just right) but it does happen at least once a day. This is really annoying.

From what i understand current state does not show history so the flow would not know how long the switch has been off. If that is not correct please let me know.

When i do everything with HA automations I can add the condition stating that the light switch has to have been off for at least 1 second before turning back on. This works exactly how i want it to.

never have thought it…

there is a timelastchanged message in the current state node’s output in miliseconds. you can use it maybe.

image

That could be a solution! I will play with that and see what i can come up with. Thanks for the information!!!