The basic idea is to have centralized server which provides an information service and a callback registration.
The information service can be used to request information about the current state of the apartment / home / ... Stuff like "What's the current temperature of sensor #2?" or "Is light #1 currently on?".
It would also provide general information of the layout of the system, queries like "Get the name and description of light #4." or "How many temperature sensors are there?".
The callback registration would be used to register your rule for a callback, if sensor information changes. You could register for information categories or specific sensors. This could be anything from Temperature sensors, to IR codes or button presses.