pc-bridge
Systems programming
A small Rust program that lets my home automation system see and control my gaming PC.

I play most of my games from bed, streaming the PC across the room rather than sitting at it, so Home Assistant, which is the open source home automation platform I run the apartment on, needed some way to wake the machine, start things on it and put it back to sleep without me getting up. This is the agent that does it. Windows tells it directly when a game process starts, so nothing sits there polling and it costs almost nothing while idle, and it finds my Steam library by reading Steam's own binary catalogue file, which took a while to work out.
Every feature is off until you switch it on. Commands arriving over the network get rejected if they contain shell metacharacters, so a malicious message cannot smuggle in a second command, credentials live in the Windows credential store and never touch a config file, and updates are signed, so a tampered or older build refuses to install itself. I wanted that settled early, since this thing listens on the network and launches programs on my behalf.
Two releases shipped a download progress bar that lied, and I pulled both. Steam quietly shrinks its own total when you resume a download, so a download that was 68% finished reported 13%, and I had only ever tested against fresh installs where that never happens. The number now comes off a channel the Steam client itself uses to report to other devices, which gives the true totals, and nothing extra runs on the gaming PC to get it.

The Home Assistant half is a separate integration that models the PC as seven power states, because a machine that is booting is neither on nor off, and for those thirty seconds everything watching it does something stupid. It checks the machine is alive two independent ways, so a PC that answers the network but has no agent running is still distinguishable from one that is genuinely off, and it waits for three missed replies before believing anything, since one dropped reply under load is not a shutdown and a state that flickers will fire every automation watching it. I found that out the annoying way.
The trace scrolls in real time. Through booting the ping line is already up while the agent line is still down, and that gap is the whole reason the integration exists.





