Encode and decode SPDT switch over single wire
You could use two 24VDC relays as follows:



simulate this circuit &ndash; Schematic created using CircuitLab
The COM is wired through the NC contact on RLY3 to provide &quot;break before make&quot;. If you don't need that feature you can avoid using the NC contact.