Push logic away from the server and into the device.
The automation should live with the programs it manages.