Added code to store switching on and off of the relays into the database