KVM Switch¶
The Switch resource manages multi-port KVM switching and EDID profiles.
Get state¶
state = await kvm.switch.get_state()
print(f"Active port: {state.active}")
for port_id, port in state.ports.items():
print(f"Port {port_id}: {port.name}")
Switch active port¶
EDID management¶
List EDID profiles¶
edids = await kvm.switch.get_edids()
for edid in edids:
print(f"ID: {edid.id}, Description: {edid.description}")
Create an EDID profile¶
await kvm.switch.create_edid(
"custom-1080p",
data="00ffffffffffff...", # hex-encoded EDID data
description="Custom 1080p profile",
)
Assign EDID to a port¶
Remove an EDID profile¶
Full example¶
import asyncio
from aiopikvm import PiKVM
async def main():
async with PiKVM("https://pikvm.local", user="admin", passwd="admin") as kvm:
# List available ports
state = await kvm.switch.get_state()
print(f"Current: {state.active}")
for port_id, port in state.ports.items():
marker = " (active)" if port_id == state.active else ""
print(f" {port_id}: {port.name}{marker}")
# Switch to another port
await kvm.switch.set_active("port2")
asyncio.run(main())