element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Forget Me Not Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Forget Me Not Design Challenge
  • More
  • Cancel
Forget Me Not Design Challenge
Blog Cam-e-lot - Round 8 - Man vs Binding (1)
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: amgalbu
  • Date Created: 13 Sep 2014 12:27 PM Date Created
  • Views 1160 views
  • Likes 0 likes
  • Comments 9 comments
  • forget_me_not
  • iot_cam-e-lot
Related
Recommended

Cam-e-lot - Round 8 - Man vs Binding (1)

amgalbu
amgalbu
13 Sep 2014

This post probably starts the most interesting part of the project: interfacing the sensor with

OpenHAB through enOcean radio protocol

 

Hardware setup

The hardware setup is shown in picture below

 

image

 

The PC runs OpenHAB and sends command to the enOcean transceiver to the Raspberry Pi board using the USB300 USB dongle. The Raspberry Pi board, in turn, sends notifications to the OpenHAB.

 

Software setup

Software setup is not so easy. Our sensor requires the use of an enOcean profile that is currently not supported neither by OpenHAB not by EOLink library. The purpose of a profile in the enOcean communication standard is easily said. The profile makes the receiver able to understand the content of the telegrams sent out by a field device. As a matter of fact, enOcean is a protocol targeted to ultra-low-power devices. For this reason, the protocol has been designed to minimize the frame length sent out by the field devices. During the installation of the field device, a "teach" telegram is sent out by the device (typically this telegram is sent out on user request, for example by pressing a push button). The "teach" telegram contains information about the profile the field device adheres to. The receiver stores the device ID and the profile. In this way, no extra data is required in the normal telegrams, because the receiver already knows (thanks to the profile it stored during the learning process) how to interpret data in the telegrams.

 

So, we are facing a complex problem because  we need to

  1. 1.       setup a development environment to build and debug OpenHAB from source code
  2. 2.       Extend the current OpenHAB enOcean binding to implement a new custom enOcean profile
  3. 3.       modify the EOLink library to support a new custom profile (I talked about building the EOLink library from source code in round 1)
  4. 4.       configure OpenHAB to use the new profile
  5. 5.       handle commands and notifications  in the sensor application running on the Raspberry Pi board

Let's start with step 1...

Build OpenHAB from source code

Here are step-by-step instructions (I installed all this stuff on a virtual machine running Windows XP)

  1. 1.       Create a local clone of the openHAB repository by running

      git clonehttps://github.com/openhab/openhab

in a suitable folder (C:\Documents and Settings\Administrator\OpenHAB)

  1. 2.       Download and install oracle jdk 1.7
  2. 3.       Download and install the Yoxos Installer from  https://yoxos.eclipsesource.com/downloadlauncher.html
  3. 4.       Download and execute the file openHAB.yoxos from  http://dl.dropbox.com/u/15535378/openHAB.yoxos

(in Linux that can be done via command line ./yoxos openHAB.yoxos ). This will install you an Eclipse IDE with all required features to develop for openHAB. Alternatively, you can install all required plugins on top of an existing Eclipse 4.2.2 installation using this update site or download a full distribution from Yoxos if you register an account there.

  1. 5.       Create a new workspace.
  2. 6.       Choose "File" -> "Import" -> "General" -> "Existing Projects into Workspace", enter your clone repository directory as the root directory and press "Finish".
  3. 7.       After the import is done, you have to select the target platform by selecting "Window" -> "Preferences" -> "Plug-in Development" -> "Target Platform" -> "OpenHAB" from the main menu. Ignore compilation problems at this step.
  4. 8.       Now you need to run code generation for a few parts of OpenHAB. To do so, go to the project org.openhab.model.codegen and run the prepared launch files. For each .launch file, select "Run As->x Generate abc Model" from the context menu. Please follow the order given by the numbers. On the very first code generation, you are asked in the console to download an ANTLR file, answer with "y" and press enter on the console. (See https://groups.google.com/forum/#!topic/openhab/QgABTJAkHOg if you're getting "Could not find or load main class org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher")
  5. 9.       All your project in the workspace should now correctly compile without errors. If you still see error markers, try a "clean" on the concerned projects. If there are still errors, it could be that you use JDK 1.6 instead of JDK 1.7. If you still have problems try (as I did)  to delete the .project from org.openhab.archetype.action and org.openhab.archetype.binding
  6. 10.   To launch openHAB from within your IDE, go to "Run" -> "Run Configurations" -> "Eclipse Application" -> "OpenHAB Runtime"

 

Unfortunately I realized that the support for sending commands to enOcean actuators provided by the enOcean binding is very poor. But, thanks to the open source community, I found another implementation of the enOcean binding here

 

To install this new binding in the OpenHAB development environment, just "File" -> "Import" -> "Existing project into workspace". A project named org.openhab.binding.aleoncean will be created.

In the Ecplise IDE, right-click in the "Project explorer" window and click "Refresh". The new Aleoncean binding will be visible in the "Project explorer" and you should be able to build and run the OpenHAB runtime.

 

Making changes to OpenHAB

During the preliminary tests I found an issue in the current implementation of OpenHAB of the Contact item.

The "Contact" item does not support the On/Off values (just Open/Closed). Because I'd like to set contact status using On/Off values, I made the following change to the ContactItem.java file (in org.openhab.core.library project)

      private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();

       private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();

      

       static {

             //New code begins here

             acceptedDataTypes.add(OnOffType.class);

             //New code ends here

             acceptedDataTypes.add(OpenClosedType.class);

             acceptedDataTypes.add(UnDefType.class);

       }

      

       public ContactItem(String name) {

 

 

Making changes to Aleoncean binding

In the Aleoncean binding, I found an issue related to the ConverterFactory class. The getConverterFactory method of the ConverterFactory class always returns null because the checkTypeClass method looks for accepted commands, but a Contact item does not support any command. So I changed the checkTypeClass method as shown below

    private static boolean checkTypeClass(final Class<? extends StandardConverter> converterClass,

final List<Class<? extends State>> acceptedDataTypes,

final List<Class<? extends Command>> acceptedCommandTypes) {

        try {

            final Field fieldStateType = converterClass.getField(FIELD_STATE_TYPE_CLASS);

            final Field fieldCommandType = converterClass.getField(FIELD_COMMAND_TYPE_CLASS);

 

            final Class<? extends State> converterStateTypeClass = (Class<? extends State>) fieldStateType.get(null);

            final Class<? extends Command> converterCommandTypeClass = (Class<? extends Command>) fieldCommandType.get(null);

 

            //Old code

            //return acceptedDataTypes.contains(converterStateTypeClass) &&

            // acceptedCommandTypes.contains(converterCommandTypeClass));

            //New begins code

            return acceptedDataTypes.contains(converterStateTypeClass) &&

                    ((acceptedCommandTypes.size() == 0) ||

                        acceptedCommandTypes.contains(converterCommandTypeClass));

           //New code ends here

        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {

            return false;

        }

    }

 

This is just the start... the Aleoncean binding uses an external project to implement profiles and the actual communication with the USB300 dongle.

Next step will be to modify such external project to implement the enOcean profile we need...

  • Sign in to reply
  • Former Member
    Former Member over 10 years ago

    Hi,

     

    thank you for the quick reply.

    With FHEM I can manage to send On/Off queries (at least with the USB Dongle). With OpenHab this does not work so far, which is annoying as there are lots of actuators available on the market.

    I am trying to use the TCM320 transceiver as a sender - I this not working?

     

    Thank you for your help

     

    Kind regards

     

    Marc

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • bose
    bose over 10 years ago in reply to Former Member

    Hi,

     

    Actually EnOcean does not have any way to control the TCM320 module from either OpenHAB or from FHEM.

    The only way to do this is using EnOcean link driver with cross-compilation and add your own custom handler.

    Also there is no documentation available on any side that tells about how to get these frameworks to send out communications.

    The above tutorial tries to emulated outward communication but I could not get that part working either.

     

    I am still waiting for reply on my last queries from EnOcean guys. You can also try with them.

     

    Warm Regards,

    Bose

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago

    Hi Bose,

     

    Thank you you very much for your tutorials. It helped a lot!

    I am struggling with the binding when using it as a sender In combination with the Transceiver and the the PI.

    do you have any ideas if it is working?

     

    THank you you in advance for your help!

     

    best

    marc

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • amgalbu
    amgalbu over 10 years ago in reply to bose

    Hi bose

    sorry for the delay...

    I had some problems too at first.. For example, the first time I run this procedure (you can find the original version here https://github.com/openhab/openhab/wiki/IDE-Setup) Eclipse didn't ask me the question I mentioned at step 8... The only solution I found was to delete the workspace and start again... I know this is not an answer but honestly I don't know where the problem..

     

    Kind regards

    Ambrogio

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • bose
    bose over 10 years ago

    Hi,

     

    Thanks for the nice tutorials.

    I was trying out your above listed steps, I could run up to Step 7.

    But in Step 8 I get this error: "Error: Could not find or load main class org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"

    This occurs when I try to RunAs the First "1 Generate Items Model.launch" file as "1 1 Generate Items Model.launch"

    Not sure if we need to run this installation as a Administrator on Windows.

    Please let me know.

     

    Warm Regards,

    Abhijit

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube