Two outlets, to power device if either is on
You could use something like this:







simulate this circuit &ndash; Schematic created using CircuitLab

Of course, you could use whatever relay you want (even small voltage DC relay with adequate power supply).

How it works:

If powered from plug 2, power gets to the device via the NC switch of the relay. Relay is not powered. If powered from plug 1, relay is triggered and switches device's power to plug 1.