Window Heat Control: How to go on

Last modified by Christoph Nölle on 2017/02/04 14:36

In the previous step of the tutorial, we have created the Window Heat Control project, as an example of an already quite realistic management app. On this page you will learn about additional tools that are useful for the development and debugging process.

Data logging

We now have an application that turns down the thermostat setopint in a room when the window is opened, and takes into account a battery as well. In order to verify the functionality, it is important to track the time evolution of the different devices in the system. For this purpose, OGEMA offers the possibility to enable logging for indivudal value resources. This is explained in more depth on a separate page, for now we simply add the following code block to the constructor of the main controller:

new CountDownDelayedExecutionTimer(appMan, 10000) {
   public void delayedExecution() {
        List<Thermostat> thList = appMan.getResourceAccess().getResources(Thermostat.class);
       for(Thermostat th: thList) {
           if(th.temperatureSensor().settings().setpoint().isActive()) {
                   "ThermostatSetpoint", null, appMan);
           if(th.temperatureSensor().reading().isActive()) {
                   "ThermostatTemperatureMeasurement", null, appMan);
        List<DoorWindowSensor> sensList = appMan.getResourceAccess().getResources(DoorWindowSensor.class);
       for(DoorWindowSensor th: sensList) {
           if(th.reading().isActive()) {
                LogHelper.addResourceToRoomLog(th.reading(), "WindowSensor", null, appMan);

Essentially, we wait a couple of seconds after the system start, so that the backup app has time to import all resources (this is only relevant for the development system, in a productive system all resources should be loaded from the OGEMA database and hence be available before any app is started). Then we ask for all thermostats and window sensors, and activate logging for their value resources by means of the LogHelper class. The latter is a wrapper for the low-level OGEMA logging API and also creates a configuration for the schedule viewer, hence simplifying the visualisation of the data. For details see Data logging and analysis.

Now open the schedule viewer, whose icon on the home screen looks as follows:


In the upper left dropdown you can choose between the available configurations. Select the simulated room created earlier, then you will be able to see the plots of all quantities relevant to the window heat control app.


If at some point we want to distribute our app to a wider circle of users, we must enable it to run in a secured setting. OGEMA provides a security mechanism for this purpose, which we kept disabled in our development system so far, but which is always active in a productive system. Every app must declare the permissions that it requires for proper operation. Since our window heat control app does not requrire acceess to low-level system resources or external communication devices (like many hardware drivers do, for instance), it is not very critical from a security point of view. The main permissions we need to declare pertain to the access to OGEMA resources of different types.

The SDK actually provides us with a mechanism to generate the required permissions declaration automatically from the source code. Open the context menu of the project in the Package Explorer of the SDK (Eclipse). Go to OGEMA -> Update OGEMA permissions, which will update the file src/main/resources/OSGI-INF/permissions.perm. If your are interested to see what kind of permissions the app requests, take a look at the file in the Eclipse editor. More information about the content can be found at OGEMA Security. Now the app is ready to be tested in a secure environment. Follow these steps:

  1. rebuild the app
  2. start the default_build run configuration in the rundir (assuming you have already added the app to the config.xml file) - this will copy the jar files of all required bundles to the rundir's bin folder, which is required for secure operation in the next step.
  3. run the default_security_clean configuration. This will start OGEMA with security enabled.

If you have created a simulation configuration before and no errors occur, everything went fine. In order to verify that the permissions are actually required, you may want to delete one or the other permission from the permissions.perm file, proceed again with the three steps above, and look for exceptions in the Eclipse console. An alternative method to restrict the permissions of the app in a specific run configuration is described on the OGEMA security page.


Congratulations, you have successfully completed the OGEMA SDK tutorial, and you should now be in an excellent position to realize your own automation projects with OGEMA. As a last step, find out how to install the app on a productive OGEMA gateway. For further information on specific topics, consult the HowTo and Reference pages in the tutorial.

Created by Christoph Nölle on 2017/02/03 01:16