@pbw a gateway's function is to act as a gateway between the nodes and a controller. I don't think you will have all of the needed memory available to add logic to the gateway and you will make your solution very static. You can implemented your own lightway controller, just have a look at the Serial API. But controllers like Domoticz are lightweight and the already over a browser based interface. And most of them are easy to setup creating a much more versatile and dynamic solution.