lunedì 9 maggio 2016

Conclusions and future work

This is the first of a series of post explaining the experience of the JEMMA and Energy@home community with the OpenHAB framework. Find below links to all posts of the series:
  1. JEMMA and OpenHAB: a nice match (publication date: 18/4/2016)
  2. OpenHAB in theory: a short overview (publication date: 22/4/2016)
  3. OpenHAB in action: a quick example (publication date: 26/4/2016)
  4. The JEMMA - OpenHAB remote binding (publication date: 29/4/2016)
  5. The JEMMA - OpenHAB local binding (publication date: 3/5/2016)
  6. Conclusions and future work (publication date: 9/5/2016)

Conclusions and future work 

With this note we conclude our short series of posts describing our experiences evaluating feasibility of a binding to integrate JEMMA and OpenHAB.

It's very hard to not appreciate the flexibility and the open approach of the OpenHAB framework. The way actual devices/services can be abstracted makes it possible to have a unified representation of objects despite the high degree of possible heterogeneous configurations that we experience in devices across technologies.  Overall, this experience was quite interesting, and proved that developing a fully-fledged JEMMA openHAB binding is indeed possible.

Here some ideas that it would be definitely interested in exploring:
  • Extend and test the binding to cover the full set of Energy@home devices, going beyond simple Smart plugs;
  • Align the DAL definitions currently used in JEMMA to the correct classes adopted by the OSGi alliance;
  • Update JEMMA dependencies to the same versions used in OpenHAB to prevent version conflicts that may (will) occur when trying to import the full JEMMA set of bundles in the same OSGi runtime as OpenHAB.
  • Realize demonstrators to understand how OpenHAB GUIs and features (e.g. rule engine, etc) can play a part in Energy@home use cases.
Energy@home will definitely continue to look with interest at OpenHAB and its developments. If you are interested in turning the results of this small feasibility study them in full-fledged binding get in contact with the JEMMA community on the public mailing list.

If you are interested in discussing this in person with some Energy@home and OpenHAB contributors just drop us an e-mail on the JEMMA mailing list.

Authors

This series of posts has been prepared by Sandro Tassone, supported by Riccardo Tomasi(ISMB). Sandro holds a MSc in Computer Engineering from Politecnico di Torino. He is currently collaborating with ISMB and Energy@home on JEMMA and other OSGi-based projects. He is a Software and C++ enthusiast.&; This activity has been partially co-funded by Energy@home. Thanks to IOOOTA for providing initial ideas and support for the jemma remote binding component.

martedì 3 maggio 2016

The JEMMA - OpenHAB local binding

This is the first of a series of post explaining the experience of the JEMMA and Energy@home community with the OpenHAB framework. Find below links to all posts of the series:
  1. JEMMA and OpenHAB: a nice match (publication date: 18/4/2016)
  2. OpenHAB in theory: a short overview (publication date: 22/4/2016)
  3. OpenHAB in action: a quick example (publication date: 26/4/2016)
  4. The JEMMA - OpenHAB remote binding (publication date: 29/4/2016)
  5. The JEMMA - OpenHAB local binding (publication date: 3/5/2016)
  6. Conclusions and future work (publication date: 9/5/2016)

The JEMMA - OpenHAB local binding

This post cover the second case anticipated in our previous post.

Some theory first. Since version 0.9, JEMMA register devices according to a standard fashion specified in  namely the Device Abstraction Layer (formerly RFC-196, in the OSGi core 6 residential specifications).


The OSGi architecture is service-oriented, so this is the most natural way to proceed also for devices. If any local application is exposing devices, as a natural choice it should register in the OSGi framework a set of Device and Function services, which can be "read" via OSGI standard mechanisms (e.g. the Service Tracker).

The purpose of the ismb/jemma-local-binding is just to read these descriptions by using the standard OSGi service tracker and to register OpenHAB things accordingly. In order to run-it, just run the instructions for the jemma-remote-binding component.

This can be quickly tested e.g. by installing in your local OSGi runtime also all the fake devices project that we normally use for testing JEMMA features without connecting actual hardware.

Despite a few known limitations (mostly due to the demonstrative/PoC nature of this development), this is probably the best way to go for any future activities targeted at providing full interoperability between JEMMA and OpenHAB. The main advantage, is that, being a standard OSGi specification, the binding will be likely usable also to provide interoperability to devices implementing other technologies (e.g. z-Wave, enOcean, ...).

Important Note: both developments are provided as proof-of-concept to evaluate the feasibility of the proposed approaches. They are not meant as "professional" bindings - as much more work would be needed to use them reliably an in all cases. If you are interested in turning them in full-fledged binding - get in contact with the JEMMA community on the public mailing list.

The code of the developed solution is available in the ismb/jemma-local-binding repository.

Authors

This series of posts has been prepared by Sandro Tassone, supported by Riccardo Tomasi(ISMB). Sandro holds a MSc in Computer Engineering from Politecnico di Torino. He is currently collaborating with ISMB and Energy@home on JEMMA and other OSGi-based projects. He is a Software and C++ enthusiast.&; This activity has been partially co-funded by Energy@home. Thanks to IOOOTA for providing initial ideas and support for the jemma remote binding component.

venerdì 29 aprile 2016

The JEMMA - OpenHAB remote binding

This is the first of a series of post explaining the experience of the JEMMA and Energy@home community with the OpenHAB framework. Find below links to all posts of the series:
  1. JEMMA and OpenHAB: a nice match (publication date: 18/4/2016)
  2. OpenHAB in theory: a short overview (publication date: 22/4/2016)
  3. OpenHAB in action: a quick example (publication date: 26/4/2016)
  4. The JEMMA - OpenHAB remote binding (publication date: 29/4/2016)
  5. The JEMMA - OpenHAB local binding (publication date: 3/5/2016)
  6. Conclusions and future work (publication date: 9/5/2016)

The JEMMA - OpenHAB remote binding

After the preliminary study and the first tutorials explained in previous post, we moved to the implementation phase, so experience what does it means for real to bridge OpenHAB with JEMMA.

After some internal brainstorming, we found relevant uses for two main use cases:

  1. As a JEMMA user, I want to control their appliances via OpenHAB GUI or rules, keeping my own JEMMA gateway;
  2. As a system integrator, I want to embed devices compatible with Energy@home (read: ZigBee HA 1.2, but also newer wifi-enabled devices) inside a gateway running OpenHAB
Both cases seemed equally relevant, so we decided to attempt the development of two separate proof-of-concepts to evaluate the feasibility of both approaches.

Important Note: both developments are provided as proof-of-concept to evaluate the feasibility of the proposed approaches. They are not meant as "professional" bindings - as much more work would be needed to use them reliably an in all cases. If you are interested in turning them in full-fledged binding - get in contact with the JEMMA community on the public mailing list.

In this first post, we focus on the first case.

The overall architecture of the proposed solution looks like the following:


Setting up the JRB

Make sure to have an OpenHAB environment up and running otherwise setup a new one following this guide. If you haven't already one, set up a JEMMA gateway following this guide and execute it on your designed host machine.  
  
  1. 1. Clone the ismb/jemma-remote-binding repository in any local folder or add a new Git repository inside your Eclipse IDE.
  2. 2. From within the Eclipse IDE import the JEMMA binding project into the OpenHAB workspace.
  3. 3. In the OpenHAB run configuration select the JEMMA remote binding plug-in  


To make OpenHAB aware of JRB existence it is required to edit the demo.things configuration file typically in _demo-resources/src/main/resources/things_. Append a line which defines the Thing the framework has to instantiate and with what configuration parameters.  

```jemmaremotebinding:jemma:jemma1 [address="192.168.1.2", port="8080", username="admin", password="Admin"]```  

Make sure to replace the arguments reported in the previous sample line with information valid to your JEMMA instance.

Runtime configuration

Point your browser to the http://localhost:8080 address and select the the OpenHAB Paper UI - . If you have any appliance currently associated to your JEMMA gateway the discovery service implemented in the JRB will find it and put into the Inbo  ![](https://raw.githubusercontent.com/wiki/ismb/jemma-remote-binding/link-menu.png)  x of discovered results. By selecting the "+" button you can make the appliance available to OpenHAB and the associated ThingHandler to be instantiated.  

The appliance has been made available but it is not actually linked to any item of the OpenHAB's site map. By moving into the Configuration/Things section it is possible to have a view of all the things currently associated to the environment.  

1. Click on the thing representing the appliance you wish to link.  



2. Click on the button beside the channel you want to activate.
3. In the dialog select the item to which the appliance thing has to be linked i.e. the DemoSwitch.  


4. Navigate toward http://localhost:8080/basicui/app and locate the Toggle Switch inside the Widget Overview section

5. By interacting with this switch it is now possible to control the smart plug previously linked




The code of the developed solution is available in the ismb/jemma-remote-binding repository.

Authors

This series of posts has been prepared by Sandro Tassone, supported by Riccardo Tomasi(ISMB). Sandro holds a MSc in Computer Engineering from Politecnico di Torino. He is currently collaborating with ISMB and Energy@home on JEMMA and other OSGi-based projects. He is a Software and C++ enthusiast.&; This activity has been partially co-funded by Energy@home. Thanks to IOOOTA for providing initial ideas and support for the jemma remote binding component.

martedì 26 aprile 2016

OpenHAB in action: a quick example

This is the third of a series of post explaining the experience of the JEMMA and Energy@home community with the OpenHAB framework. Find below links to all posts of the series:
  1. JEMMA and OpenHAB: a nice match (publication date: 18/4/2016)
  2. OpenHAB in theory: a short overview (publication date: 22/4/2016)
  3. OpenHAB in action: a quick example (publication date: 26/4/2016)
  4. The JEMMA - OpenHAB remote binding (publication date: 29/4/2016)
  5. The JEMMA - OpenHAB local binding (publication date: 3/5/2016)
  6. Conclusions and future work (publication date: 9/5/2016)

OpenHAB in action: a quick example

The easiest way to implement a binding consists in creating a preliminar skeleton using the OpenHAB script dedicated to the purpose and then redefining the placeholders inside the code just created.

Writing a binding requires definition of the following constitutive elements:
The Handler is an entity tightly bound to a specific Thing, indeed it provides the implementation of the thing capabilities. In order to receive/send commands and status update from/to the item it is required to implement the HandlerThing interface and overriding the handleCommand and handleUpdate methods.

The role of the handler factory is pretty straightforward. It instantiates the implemented handler when the framework service requests it. This happens anytime a new Thing is added to the framework. The factory implements the ThingHandlerFactory and must provide methods to specify whether it manages a particular ThingHandler.

This is made possible by attempting to match against the ThingTypeUID given as argument in the supportsThingType method. In case a match has been found the framework service calls the createHandler method which returns a new ThingHandler instance.

As pointed out in the previous post, a Thing is the immanent representation of an Item and as such is required to be able to perform actions that mean something for the specific item. These capabilities should be adequately designed and hence described inside the related xml file.

Events such as sending a command and posting an update, once triggered, flow into the OpenHAB's event bus and the framework is in charge of delivering such events to the proper recipient.

If we start to trace back the chain of operations it is possible to identify a  link between an item and its handler. This connection is partially defined inside the .item file with a reference to a thing definition. The last branch of the link is identified by the association between the xml file describing the Thing and its relative Handler. The framework will nicely do the rest.

The links defined inside the framework are not necessarily point to point, there might be a one to many configuration where an event is delivered to multiple handler and the opposite is also true.

However the bus operates as a messages exchange based system and thus there is no guarantee that messages are delivered in order and without overlaps among different events. Cool down mechanisms can be implemented to perform a sort of debouncing to avoid manifestation of undesired situations.

Some XML headers ...

To better understand how the whole system works we tried to implement our own test binding i.e. an event logger to log events relative to a binary switch, following various tutorials on the openHAB website.

Once the Eclipse Smart Home environment has been set up, it is possible to exploit the script
mentioned in the previous section and create a new binding skeleton.

The skeleton project can now be imported inside eclipse and edited to best suit your needs. In our case, we start by editing the ESH-INF/binding/binding.xml to look like the following:
<?xml version="1.0" encoding="UTF-8"?>
<binding:binding id="customlogger"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:binding="http://eclipse.org/smarthome/schemas/binding/v1.0.0"
        xsi:schemaLocation="http://eclipse.org/smarthome/schemas/binding/v1.0.0 http://eclipse.org/smarthome/schemas/binding-1.0.0.xsd">       

    <name>CustomLogger Binding</name>
    <description>This is the binding for CustomLogger.</description>
    <author>your name here</author>

</binding:binding>

The most important field here is represented by the <binding:binding id="customlogger"> element whose value will be used to identify the binding inside the whole framework.

Afterwards, it is possible to start describing the Thing element.

<thing:thing-descriptions bindingid="customlogger" xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd">

    <!-- Sample Thing Type -->
    <thing-type id="logger">
        <label>PertLogger Binding Thing</label>
        <description>Sample thing for CustomLogger Binding</description>        
        <channels>
            <channel id="log" typeid="logType">
        </channel></channels>
    </thing-type>

    <!-- Sample Channel Type -->
    <channel-type id="logType">
        <item-type>Switch</item-type>
        <label>CustomLogger Binding Channel</label>
        <description>Log channel for CustomLogger Binding</description>
    </channel-type>

</thing:thing-descriptions>

In this phase it is possible to give an ID to our new Thing. This information will be used in a while inside the ThingHandlerFactory to infer whether the framework has requested an instantiation of the handler associated to a particular Thing. Thing capabilities are described inside the channel definition. In our case we just need the logger to export the log capability for event associated to a binary switch.

... and finally, the code.

The CustomThingHandlerFactory definition is simple as this:

public final static ThingTypeUID THING_TYPE_LOGGER = new ThingTypeUID(BINDING_ID, "logger");
    private final static Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_LOGGER);

    @Override
    public boolean supportsThingType(ThingTypeUID thingTypeUID) {

        return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);

    }

    @Override
    protected ThingHandler createHandler(Thing thing) {

        ThingTypeUID thingTypeUID = thing.getThingTypeUID();

        if (thingTypeUID.equals(THING_TYPE_LOGGER)) {
            return new CustomLoggerHandler(thing);
        }

        return null;
    }


Finally, we just need to hook the handleCommand implementation. Note: as log messages tends to grow exponentially when developing for OSGI framwork in the example we don't use simple calls to System.out but we rely on a standard sl4j or log4j logger.

private Logger logger = LoggerFactory.getLogger(CustomLoggerHandler.class);
    private static final String STRING_FORMAT = "CUSTOMLOGGER: ";
    public final static String CHANNEL_LOG = "log";

    @Override
    public void handleCommand(ChannelUID channelUID, Command command)
    {
        if (channelUID.getId().equals(CHANNEL_LOG))
        {
            if (command instanceof OnOffType)
            {
                switch ((OnOffType) command)
                {
                    case ON:
                        logger.info(STRING_FORMAT + "Light has been switched ON");
                        break;
                    case OFF:
                        logger.info(STRING_FORMAT + "Light has been switched OFF");
                        break;
                }

            } 
            else            
            {
                logger.info(STRING_FORMAT + "RECEIVED UNKNOWN COMMAND");
            }
        }
    }
Having defined such classes makes the binding ready to receive events relative to the logger Thing and for the associated Channel. In our specific case we are interested in OnOffType commands associated to the "log" channel. The extremely clever operations carried out by the logger consist in simply logging down the state of our switch. We are now ready to export our plugin and make it available to the OpenHAB runtime. To avoid trouble during the exporting process i suggest to close all test projects inside the Smart Home workspace in order to avoid circular dependencies.

OpenHAB configuration files

Once the export operation completes successfully we are now ready to switch to the OpenHAB context. Set up of the OpenHAB environment can be accomplished by following the instructions reported here. The first operation required consists in adding our brand new plug-in to the target platform dependencies of the runtime and then update the openhab2 run configuration to include our plug-in.


It finally came the time to edit the OpenHAB configuration files. Inside the demo-resources/src/main/resources/things folder it is possible to find a demo.things file where inside are defined the Thing objects that will be instantiated once the runtime started.

 Our thing instance should be declared in this file using the following representation:

bindingId:thingId:thingInstanceName     ["parameters"]
customlogger:logger:myLogger            []

It's now the turn of the "demo.item" file to be edited.

At the bottom of the file a list of them items is defined. Our goal is to update the line relative to the DemoSwitch and link it to the log channel provided by the CustomLogger Thing instance. To do so we just append the bindingconfig {channel="customlogger:logger:myLogger:log"} to the DemoSwitch line.

Switch DemoSwitch               "Switch" {channel="customlogger:logger:myLogger:log"}

The previous line will inform the OpenHAB framework that any command/update event associated to the DemoSwitch item must be delivered to our logger and to the channel indentified in the .item configuration file. The information related to the channel is attached to the event and will be used by the CustomLoggerHandler to establish what functionality has been requested and needs to be activated. What just done completes the chain of communication set up procedure.

Running the demo

If everything went fine it is possible to type the ss command inside the Eclipse console and see the list of active bundles and information associated to their current status. Scrolling the list you shuld be able to see something like this:

119 ACTIVE      org.eclipse.jetty.client_9.2.12.c20150709
120 ACTIVE      org.eclipse.smarthome.binding.customlogger_0.8.0.0.201602011529
121 RESOLVED    org.eclipse.jetty.osgi.alpn.fragment_1.1.2

It is now possible to see demo items by reaching http://yourhost:8080/basicui/app location in a browser or remotely inside a smartphone. By getting inside the Widget Overview category it is possible to examine the demo items defined in the associated configuration file.

The subsection containing Binary Widgets it is possible to notice the presence of our toggle switch.


I know it's hard to resist, thus you should definitely go for it and click the button.

What happens next is more or less what explained in the previous sections, hence we expect some events to ride all over around and hopefully to reach our binding.

By examining the eclipse console we should be able to se something very similar to the following:
[DEBUG] [.c.thing.internal.ThingManager:298 ] - Delegating command 'ON' for item 'DemoSwitch' to handler for channel 'customlogger:logger:mylogger:log'
[INFO ] [.b.p.handler.CustomLoggerHandler:73    ] - CUSTOMLOGGER: Light has been switched ON

This is exactly the output we prefigured out to see. The framework informs us that a command relative to our DemoSwitch item has been delegated to our Thing at a specific channel. The line that follows is the result generated by our logger class that behave as expected and log down the command reception.

Authors

This series of posts has been prepared by Sandro Tassone, supported by Riccardo Tomasi(ISMB). Sandro holds a MSc in Computer Engineering from Politecnico di Torino. He is currently collaborating with ISMB and Energy@home on JEMMA and other OSGi-based projects. He is a Software and C++ enthusiast.&; This activity has been partially co-funded by Energy@home. Thanks to IOOOTA for providing initial ideas and support for the jemma remote binding component.

venerdì 22 aprile 2016

OpenHAB in theory: a short overview

This is the second of a series of post explaining the experience of the JEMMA and Energy@home community with the OpenHAB framework. Find below links to all posts of the series:
  1. JEMMA and OpenHAB: a nice match (publication date: 18/4/2016)
  2. OpenHAB in theory: a short overview (publication date: 22/4/2016)
  3. OpenHAB in action: a quick example (publication date: 26/4/2016)
  4. The JEMMA - OpenHAB remote binding (publication date: 29/4/2016)
  5. The JEMMA - OpenHAB local binding (publication date: 3/5/2016)
  6. Conclusions and future work (publication date: 9/5/2016)

OpenHAB in theory: a short overview

OpenHAB has quite good documentation to help you getting started. As new OpenHAB adopters, right after the first practical tests, were especially interested in more "architectural" documentation. Luckily, also on this topic a good amount of resources are available, split among the OpenHAB and ESH repositories. We give you a short summary of the most interesting aspects in the following.

As anticipated in the previous post, one aspect that we like about OpenHAB is its model for abstracting devices resources.

From the application developers point of view, the whole framework relies on the concept of item (also explained here). Items are simple entities, which have a status and can be used through events. The overall amount of items is quite compact - and quite independent from any specific specific hardware capability. We did not have the chance to dig into the reasons for this design choice yet, but we can appreciate the fact that the amount of items is quite compact and generic, giving to application developers a controlled set of "virtual" objects to play with - which clearly simplifies the development of applications.

Going into more interesting models (at least from the device inter-operability perspective) the entity representing concrete devices (or services) is represented by a Thing component. Beyond keeping track of the status of the physical device (off-line, on-line, initializing, etc.) a Thing element models the device/service and its actual capabilities expressed by a collection of Channels. elements. Also in this case, the choice seems quite practical - and very similar to the OSGi Device Service/Device Abstraction Specifications, which we consider an example of a quite well-designed and flexible abstraction.

The communication "glue" among these two layers between these two components is provide by the OpenHAB *Event Bus * (see also here).

From the implementation view point, the life-cycle of Things and their respective capabilities are managed and exposed to the framework by implementing a Binding i.e. a bundle implementing a number of standard interfaces (normally ThingHandler, plus a separate channel interface for each specific capability, etc.).

Once the bindings have been imported into the OpenHAB framwork as addons, the mapping between Item and Binding can be defined just by providing proper configuration directives which looks like the following examples:

itemtype itemname           ["labeltext"] [<iconname>] [(group1, group2, ...)]      [{bindingconfig}]
Switch  Light_Floor         "Light at Floor"                                { knx="1/0/15+0/0/15" }
Switch  Presence            "I'm at home"                                   { bluetooth="123456ABCD" }
Switch  Doorbell            "Doorbell"                                      { serial="/dev/usb/ttyUSB0" }
Contact Garage              "Garage is [MAP(en.map):%s]"                    { zwave="21:command=sensor_binary,respond_to_basic=true" }
String  Error_Ventilation   "Error in Ventilation %s"                       { comfoair="error_message" }
Number  DiningRoomTemp      "Maximum Away Temp. [%.1f °F]"                 { nest="<[thermostats(Dining Room).away_temperature_high_f]" }

The syntax may look complex, but actually it's just one line for each item following a rather simple syntax.

Rules and Actions !

At this point, the best way to proceed is to play with the demo environment provided by OpenHAB.
After the demo environment is started, OpenHAB web interfaces should be reachable through at http://localhost:8080/openhab.app?sitemap=demo.

The framework provides a translation mechanism from the item configuration file to an HTML page making possible to interact with the several items in a more pleasant way. The shape given to the various items that populate the GUI is defined into proper .sitemap files.

The interaction with the GUI typically triggers different events, for example the on/off switching of a light sends a command and the associated status update over the event bus. If the items is bound to a Thing it is possible to receive the command together with the status update notification and behave accordingly, possibly by interfacing the the physical object and modifying its status.

One of the OpenHAB features we like best, it the possibility to define more complex behaviors or to trigger actions on specific time intervals by defining a specific Rule. Rules are written following a Xtend syntax and compliant with the following structure:

rule "rule name"
    when
        <TRIGGER CONDITION1> or 
        <TRIGGER_CONDITION2> or 
        <TRIGGER_CONDITION3>
        ...
    then
        <EXECUTION_BLOCK>
    end
The rule body is executed any time the when clause is met. Several activation methods are possible and they can all be grouped into the following:
  • Item(-Event)-based triggers: They react on events on the openHAB event bus, i.e. commands and status updates for items
  • Time-based triggers: They react at special times, e.g. at midnight, every hour, etc.
  • System-based triggers: They react on certain system statuses.
    The "then" clause contains actions to be performed when the rule is activated. Actions defined by the OpenHAB framework cover the majority of use cases, however actions with special purpose can be defined by extending the framework and implementing your own actions.

Authors

This series of posts has been prepared by Sandro Tassone, supported by Riccardo Tomasi(ISMB). Sandro holds a MSc in Computer Engineering from Politecnico di Torino. He is currently collaborating with ISMB and Energy@home on JEMMA and other OSGi-based projects. He is a Software and C++ enthusiast.&; This activity has been partially co-funded by Energy@home. Thanks to IOOOTA for providing initial ideas and support for the jemma remote binding component.

lunedì 18 aprile 2016

JEMMA and OpenHAB: a nice match

This is the first of a series of post explaining the experience of the JEMMA and Energy@home community with the OpenHAB framework. Find below links to all posts of the series:
  1. JEMMA and OpenHAB: a nice match (publication date: 18/4/2016)
  2. OpenHAB in theory: a short overview (publication date: 22/4/2016)
  3. OpenHAB in action: a quick example (publication date: 26/4/2016)
  4. The JEMMA - OpenHAB remote binding (publication date: 29/4/2016)
  5. The JEMMA - OpenHAB local binding (publication date: 3/5/2016)
  6. Conclusions and future work (publication date: 9/5/2016)

JEMMA and OpenHAB: a nice match

With the rise of the IoT vision, the Smart Home domain is thriving with new technologies, offers and services. In such a context, it's likely that a single "good-for-all" solution will not emerge at least in the short term. For this reason, as of today, we need to find smart ways to provide smart home functionalities building upon a set of interoperabile eco-systems.

Open solutions can make things much smoother in such a context and are inherently better in enabling privacy-savvy smart home solutions which leave users more "in control" of their devices e.g. avoiding problems such as customer lock-in (or worse).

As a promoter of open standards and eco-systems, Energy@home has been looking with interest for several months at other open frameworks, trying to investigate the best pragmatic strategies to allow JEMMA and devices compatible with Energy@home specifications (ZigBee HA 1.2) to inter-operate within other solutions.

After a careful study, the JEMMA community has almost immediately found a great match in terms of philosophy, visions and technologies with Eclipse Smart Home/OpenHAB at many levels. First of all, OpenHAB vendor-neutral approach is much in line with Energy@home strategy. Secondly, many of the adopted core technologies are the same (OSGi, above all) are the same. Moreover, both project share compatible device modeling and description approaches, thus making ideally possible to think about ways to automatically bridge access to device properties and functionalities in programmatic fashion.


In the last weeks, Energy@home has co-funded a small activity to learn more about OpenHAB and to verify in practice how much correct our expectations were (spolier: expectations confirmed!).

In the next posts, we'll try to give an overview of the journey we made, starting from the first exploration tutorials to the prototype developments we made to make first JEMMA-OpenHAB interoperability happen.

Stay Tuned!

Authors

This series of posts has been prepared by Sandro Tassone, supported by Riccardo Tomasi(ISMB). Sandro holds a MSc in Computer Engineering from Politecnico di Torino. He is currently collaborating with ISMB and Energy@home on JEMMA and other OSGi-based projects. He is a Software and C++ enthusiast.&; This activity has been partially co-funded by Energy@home. Thanks to IOOOTA for providing initial ideas and support for the jemma remote binding component.

lunedì 7 marzo 2016

Using JEMMA with the Freescale KW24D512 ZigBee Dongle

The USB-KW24D512 is a development platform based on MKW24D ARM MCU which embeds a low power IEEE 802.15.4 2.4 GHz radio frequency transceiver. This board comes with a pre-installed firmware able to operate as ZigBee traffic flow sniffer and can be directly used with the BeeKit Wireless Connectivity Toolkit freely downloadable from NXP. This toolkit provides among other functionalities the possibility to modify the firmware to best suite developers needs.

1. Prerequisites

In this particular case it is required the board to operate as a ZigBee dongle so that making possible to reach remote devices operating ZigBee based communications. To accomplish this purpose a programmer supporting the MKW2x ARM processors family is required.

In our case we used a SEGGER J-Link EDU (note: this is a cheaper version of the full J-Link product, which only allows non-for-profit use). Tje J-Link allows to debug end reprogram among others this particular Freescale board. The J-Link provides a 20-pin 0.1" JTAG socket therefore a J-Link 9-pin Cortex-M Adapter is required in order to interface the board. Before attempting to modify board's firmware, it is advisable to update J-Link debugger otherwise the board might not be correctly identified. It is possible to update the debugger's firmware by downloading the J-Link Configurator tool included in the SEGGER J-Link software pack.
Flash the board


2. Flash the firmware

  1. Open Test Tool application. Go to Tool 12Tool.exe
  2. Select Firmware Loaders --> Kinetis Firmware Loader option.
  3. Connect a J-Link Flash programmer to the mini-JTAG connector on the USB-KW24D512 board.
  4. Browse and select the KW24D512USB_BlackBox_ZigBeePro srec file to upload to the board
  5. Click on the "Upload" button and specify the board about to be updated
From this point on the Freescale USB-KW24D512 will operate as ZigBee dongle.

3. Set up and launch the runtime

To set up and launch the JEMMA runtime please refer to this guide. As pointed out in the guide, it is required to specify the port name assigned by the operating system to the zigbee dongle in the configuration/config.ini file. For linux users this is something similar to /dev/ttyACM0.

Authors

Sandro Tassone holds a MSc in Computer Engineering from Politecnico di Torino. He is currently collaborating with ISMB and Energy@home on JEMMA and other OSGi-based projects. He is a Software and C++ enthusiast. Thanks to Vito Monterosso (Gemino), for providing the initial instructions and support.