I imagine that by OPT you "mean one time password".
Unless this is an "academic exercise", I would have expected to see two sketches
(a) one to generate a one time password (series) and send it to the device with the relay & keyboard
(b) to receive the password, store it, wait for a user to attempt to enter the password and then operate the relay (if successful).