Noobie Function question

If you have not yet invested "heavily" in your relays, maybe looking in a different direction sometimes help

Such relay boards mentioned are so cheap and can be controlled directly from NR, no need for Arduino and complex buffer coding

Then interacting with HA would be so simple, just use MQTT between NR and HA