Serial Relay Control
In my previous home, I had a rather flakey boiler ("Furnace" for our American readers), which had a control system which didn't work when it felt like it (usually in the winter, of course). None of the thermostats on the market really met all my criteria, nor did I feel like paying the price for them that was being asked, I decided to build my own.
By using a Linux based system I was able to do more complex control of the heating such as turn the boiler off when my mobile phone (and therefore, I) wasn't at the house. It also gave me the ability to make use of my existing temperature sensors which were already being logged to and controlled by my Linux server.
This worked well for a number of years and significantly reduced my heating bills - probably just about paid for itself :)
The instructions below show the code required to interface with a simple IO kit, available in the UK from http://www.quasarelectronics.co.uk/Item/3108-8-channel-serial-relay-controller-isolated-io-board-kit
Because the IO board has 8 outputs and also 4 inputs, I decided that I'd want to use it for control and sensing of multiple systems and that the best way to handle this was to have one piece of software controlling the device, with multiple other clients able to send messages (switching requests) to the server.
The purpose of the daemon is twofold; 1) To monitor the status of the inputs and trigger an action if there's a status change. 2) To listen on the network for requests to change the status of a relay and then action that request.
This is an example of a client, it can be easily called from other scripts and has the sole purpose of sending the UDP message to the client to trigger the actioning of the relays.