How to change relay status when turn on/off

I’m not sure I fully understand your question, but I think that if you create a virtual device with the [App] Virtual Devices you can use flows to create the required behaviour for the virtual device.