Home Automation XML Representation

The main project objective is to see if we can extend and enhance our existing home control system into a generic piece of software that could be used in any home, by modelling and representing the house and its home automation elements in XML. Much of the configuration of our current system is stored in XML already. Other objectives are to:

  • Extend our knowledge of XML and its applications.
  • Show that home automation configuration and control can be separated from the underlying software, enabling anyone to do it.
  • Show that home automation can use technology abstraction to simplify configuration and control, regardless of the underlying technologies being used.

This project is not about the XML! We don't expect the average person to have to understand, interact or even see the XML as we have shown it here. A nice and simple graphical tool or wizard would enable this XML code to be generated very easily, so that anyone could set up both basic and advanced home automation in their home. These tools will be the subject of a later project.

This project is only possible because our hybrid technology Home Control System (HCS) has a simple process at its core which is an event driven state engine. The configuration is already loaded from an XML file but, this project aims to make it much more generic, so that it could be used in any home as the basis of any home automation system. This is also enabled by the fact that we use NOT DEFINED and hide the underlying technologies. The events themselves are simply modelled in a structured message (a string of human readable characters) and can be sent between processes using socket layer communications and other protocols and transport mechanisms. This simple design makes it also implementation technology agnostic and we have elements written in Java, JavaScript, PHP, LUA and other software languages. Similarly, it could run on a wide range of platforms and operating systems and as an example we have a project to port it to a Raspberry Pi board, to enable a tiny, low-cost and low power home automation system.

XML Modelling


We have assumed that any house will have an alarm system for security purposes and we have modelled this as generic capability with three elements, an internal alarm, external alarm and an external alarm strobe. It also has remote notification capability via IP networks, SMS messages, etc. The behaviour of the alarms are driven by the alarm status, which is either 'On' of 'Off' and the house status, which is one of 'In', 'Out' or 'Away'.

Alarms are triggered by sensors within zones. Triggers also have an associated value, so that a closing door doesn't trigger the alarm for example but, opening it does. This is useful when leaving the property, having set the alarm.


Our home is currently split into a number of zones and typically there is one for each room in the house. In addition we have a 'Global' zone for modelling environmental factors that may affect all the other zones. An example of this is our twilight sensor. We also have a 'Garage' zone and an 'Outside' zone. The latter is used for things like our garden gate and shed door, which have sensors on them.


Each zone has an associated set of one or more sensors and these have a name and type element. Each sensors inherits the zone in which it was created. The type allows us the sensor output to be validated, e.g. a contact sensor is either 'Open' or 'Closed'.


Sensors can also have a 'timeout' value (in seconds) assigned to them in the XML.

In the case of a contact sensor, when the door is opened the current date and time is stored. When the door is closed this value is cleared. If the door is left open for a period longer than the timeout value, then the sensor generates an Alarm event of the form:
Alarm,Garage,Garage Door,Timeout


Sensors can also have a 'minimum' value assigned, where it makes sense. In the case of a temperature sensor, the sensor will generate an Alarm event if the minimum value is met or crossed:
Alarm,Bathroom,Bathroom Temperature,Minimum


Sensors can also have a 'maximum' value assigned, where it makes sense. In the case of a temperature sensor, the sensor will generate an Alarm event if the maximum value is met or crossed:
Alarm,Bathroom,Bathroom Temperature,Maximum

Each sensor maintains a boolean flag as to whether it has alarmed or not. This avoids multiple/repeat alarms. The sensor class has a Reset() method, to reset this flag.


Some sensors are battery powered and these are marked as such within the XML. These sensors send the current battery level back as a separate event, following each door closure, PIR off, etc. A low battery level also causes the sensor to alarm.

Device Controllers

These are now covered in much more detail in a separate project. These are basically the main method of automating, scheduling and driving things by events, sensors and environmental conditions.

XML Processing In Java

Processing an XML file is quite easily achieved by using the Java DOM parser and this simple tutorial shows the basic of this working.


Based on our initial design work, we have written a new core HCS process in Java that starts from this new XML config file. We have taken this approach because it simplifies testing and allows our existing code to be used whilst we develop the new code. It is actually quite a simple bit of software though and most of the 'intelligence' is in designing the right set of Java classes. Many of these exist already as we have been using them for the last 8 years in some cases!


Just thinking about this project has proved very useful, both in terms of XML learning and in understanding how our home works and the elements and features within it. It has helped us realise that there are things missing and other things we can add. It has also shown us that most automation is quite simple and can easily be set up and controlled using something simple like this.

This project is an on-going journey of discovery! Our Home Control System (HCS) is using XML for configuration and already supports the rich set of features described here. As we add new hardware and software elements, we are extending the XML schema and updating our software to support these new features. This project page will be updated as we do this.

Further Reading

Share ...
We are on ...
Facebook Twitter
YouTube Flickr Follow us on Pinterest