Last week I finished fitting all light-switches in my house with PLCBUS micromodules, so I decided to continue working on the software that eventually will control those modules.
I use LAMP (Linux, Apache, MySQL, PHP) and Perl and intend to build my home-automation system with this software.
I want to be able to control PLCBUS devices from within any application that is running on my system, being it a scheduler, event-handler or a web-based application for manual control. The easiest way of realising this is a central hub that collects all messages, transmits them to the PLCBUS interface and returns a status to the calling process.
For this I implemented a UDP server that continuously monitors a socket for incoming messages. When it receives a message it will process it and return the status.
For example, sending the command 'AB,ON' will turn micromodule A11 on (I use HEX values for the unit codes). These kind of commands can be send easily from a web-page, of from a another script / program.
Attached you will find the hub and a client program, should give you an idea of how things are working. There are some minor issues left to be solved (Mainly status-reports), the code needs cleaning-up, but at least I can start designing a webpage to control the light-switches from.
Comments on how I coded things are welcome. Should you make improvements, please share!
Start the hub: ./hub_plcbus.pl
The client: ./client AB,ON (Switches on A11; Unit-code in HEX)
Download Attachment:
domoticaforum.eu/uploaded/Jfn/200861411 ... bus.pl.txt
Download Attachment:
domoticaforum.eu/uploaded/Jfn/200861411 ... bus.pl.txt
Als het niet gerepareerd kan worden dan is het niet kapot!