And for the record, I've fixed a node ID for this sensor and it works locally, turning the lights on/off through the relay, even when the gateway is not reachable (out of range).
I will open another thread to check what are the possible issues with this behavior.