Sequence of on, off, on commands with 2 second delay

I have ceiling can light with a night light feature. But to activate the night light, you have to switch on the lamp, switch off, and then on again within 2 seconds. This activates the night light led. How can I configure this in hubitat? Basically if the lamp is already on, then it's just two commands, off command and on within 2 seconds. If the lamp is off, then 3 commands, on, off, on.

As per manual
-To transition to nightlight mode, toggle the wall switch off and back on within 2 seconds.
-To transition back to downlight mode, toggle the wall switch off and back on within 2 seconds

Forgot to mention. I plan on controlling these lights via a Z Wave paddle dimmer switch.

I'd use Rule Machine. Something like this...

Trigger: whatever event you want to start this (hopefully your Z-Wave switch sends button events with paddle taps?)

Actions to run:

IF (Switch is off) THEN
  On: Switch
  Wait for event: elapsed time --> 0:00:01
END-IF
Off: Switch
Wait for event: elapsed time --> 0:00:01
On: Switch

(I'm using one second between commands here since your description is "within two seconds" and this seems like a good compromise between going to fast and being too slow, but feel free to adjust according to your actual experience.)

Awesome! Tnx ! I’ll try this and let you know. If I need to call this from HomeKit via Homebridge, I guess I will need to creat a virtual switch with this macro which than is exposed in HomeKit . (It’s my first time with Hubitat, pardon my basic questions)

Finally got to this. Created a virtual button. The button works fine from hubitat to toggle the night light mode. I use homebridge to expose hubitat devices to homekit. For some reason while the hubitat virtual button is visible in homebridge, clicking it does nothing. My button controller has 9 buttons, in homebridge it shows 9 individual buttons. I'm assuming clicking button 1 will send command for button 1 press to the button controller. But noting happens. I also tried using the recently announced hubitat direct integration with homekit, but in this setup, the button is not even exposed or visible in homekit. Any advice or guidance on how can I expose a virtual button to function in homebridge or homekit.