Ian76
September 22, 2025, 6:42pm
1
We are currently automating various functions on PiKVMv4’s via API. Can I extend this functionality to the PiKVM Switch as well for downstream automation for devices that reside off of the switch?
The switch is controllable via the REST API just like the other functions of the PiKVM.
@exposed_http("POST", "/switch/set_active_prev")
async def __set_active_prev_handler(self, _: Request) -> Response:
await self.__switch.set_active_prev()
return make_json_response()
@exposed_http("POST", "/switch/set_active_next")
async def __set_active_next_handler(self, _: Request) -> Response:
await self.__switch.set_active_next()
return make_json_response()
@exposed_http("POST", "/switch/set_active")
async def __set_active_port_handler(self, req: Request) -> Response:
port = valid_float_f0(req.query.get("port"))
await self.__switch.set_active_port(port)
return make_json_response()
@exposed_http("POST", "/switch/set_beacon")
async def __set_beacon_handler(self, req: Request) -> Response:
on = valid_bool(req.query.get("state"))
if "port" in req.query:
port = valid_float_f0(req.query.get("port"))