This is the way it worked for me. Because there is no documentation for writing plugins (or ill cant find one), ill just published this. So i dont know whats the preferred way :)

If you have a link to a smarthome.py-howto for Plugins i will improve this plugin and the next will be of better quality :)

Another thing ill couldnt figure out was the usage of the lib.connection.Client library. Thats why ill use the plain sockets. But you didnt comment the plain sockets so i think this will be okay :)