Distributed, coordinated, reasoning control

I am a master student in Essen, also working for the chair, embarking on the enterprise to bring a new aspect to the great openHAB2 project as my master’s thesis.
The details are a bit complicated to explain, but I will try to here, also I’ll be at the eclipseCon in three weeks, hoping to be able to meet with at least you @Kai and talk a bit about the approach.
I’m writing here now, because I need a little guide where and how to start in terms of code, also to make you all aware of the idea and get your suggestions.

We want to take a somehow different approach in applying the smart home system, which is modeled and controlled by ESH/openHAB2.
Until now, there is (as far as I understand it, please correct me) a rule engine, which can determine which commands to execute based on basic sensor data, state, variables and external service data.

We propose an option to connect multiple instances of openHAB, each of them possibly in the separate flats of a house or in the separate houses of a street or neighborhood. Those independent instances could then communicate with each other to influence the local control of the smart home, e.g. arrange an agreement, when exactly each instance starts it’s washing machine.

This could be an important contribution to implement load shifting on electricity networks: If every washing machine in a neighborhood starts at the same time, it means a huge load (ca. 2000W/machine) on the net. If the smart homes coordinate, it would mean a great help for keeping stability and reliability. Also, this way electricity might be usable in times, where it is easily available and cheap (at night or noon).

To implement this, a technique called MAS - multi agent system, specifically the FIPA compliant JADE framework (https://en.wikipedia.org/wiki/Java_Agent_Development_Framework), would be used. Each smart home would run at least one agent, acting as an interface between the own openHAB instance and the other agents in the geographical vicinity/community.

This way, not someone else controls your washing machine, but only your own agent acts on your behalf within the presets of freedom you grant to him, e.g. “washing can start from 08:00 and should be finished between 15:00 and 18:00 pm”. Within this boundaries, the agent might pause washing at certain points (e.g. when the machine is not currently filled with water). You wouldn’t need a new “smart” machine, but only a switchable socket (every modern machine will simply continue the program after a power loss). Privacy and security can be maintained.

To convey an understanding of energy and such to the agent and to model the context, the Energy Option Model (EOM) would be used (see http://www.agent-hygrid.net/en/publications/).

After this long background story:
What would be the best point in the code too hook into? Would it be best situated at org.eclipse.smarthome.automation (github.com/eclipse/smarthome/tree/master/bundles/automation)? Also, there is documentation about developing a binding (which I suspect this approach won’t be?!) but I didn’t find anything regarding implementing a “Service” or “System Integration” or a “Misc”“Extension”/“Add-On”.

I successfully set up a openHAB development environment guided by docs.openhab.org/developers/development/ide.html and one guided by eclipse.org/smarthome/documentation/development/ide.html, I am an intermediate Java programmer with experience Vanilla Java, JADE Agents and Android development but will have to get myself familiar with OSGi.
Also I have set up a openHAB2 instance on a RaspberryPi2 with a ZME_UZB1 Z-Wave stick and a connected Greenwave Powernode 310-F switchable/meterable socket, which is able to switch and meter the washing machine.

Is this interesting for you? Can you help me? :slight_smile:

friesenkiwi/Hanno - Felix Wagner
Universität Duisburg-Essen

A binding is an Add-On. The two are sometimes erroneously used interchangeably. From your description I would think that an Action would be a natural fit. In a rule to turn on the washing machine I could see a command to the agent to go out and ask permission to run, it would negotiate that permission while the call blocks, and once permission is received and the right time has occurred the Action would return and allow the Rule to run.

I’m not fully up on the OH/ESH code base, but I believe the only addon extension points the architecture is built to support are:

  • Bindings: interface to a technology that can be represented as Things/Items
  • Actions: interface to a technology that gets called directly from a rule
  • Persistence: interface to DB technologies for storing Item states
  • UIs: User interfaces that work with the REST API to build displays

Hopefully someone more knowledgeable will be able to chime in and tell me I’m wrong. I usually am.

Hi Felix,

Sounds like an interesting approach to me!
If I understand it correctly, I would agree with @rlkoshak that what you are looking for is a “rule action”, i.e. some piece of complex logic that determines what it would like to do (in your case also using information that it receives from some external service). You should directly go for the new rule engine as this allows you a lot of flexibility in terms of configuration options for your agent. Depending on your scenarios, you might also want to consider to implement triggers, conditions or complete templates. This would allow you to re-combine those building blocks quickly for new use cases. E.g. you could have a trigger like “energy is cheap for the next 60 minutes” and users could decide by themselves, what kind of action they want to execute on such an information.

Looking forward to meeting you at EclipseCon Europe.

Thank you both for your responses and suggestions. I will look into rule actions, triggers, conditions and templates.
I’m not fully confident, that those match 100 % to the dynamic, autonomous and proactive nature of software agents (each one runs in an own thread etc.), but it might as well be the best way to take a first step. I had the suspicion, that the approach I had in mind was a kind of alternative implementation to the rule engine, but that might be a bit too big chunk for the first sections of the learning curve in OSGi / ESH / openHAB… :wink:


OK, so after much trial-and-error experimenting, I managed to find and run the example “Welcome Home Application” mentioned at https://www.eclipse.org/smarthome/documentation/development/rules/sample.extension.java.html, so with

osgi> smarthome automation listRules AirConditionerSwitchOnRule

on the eclipse osgi console, it lists the details of the rule.
This might probably a good way to get going. I would change some code in the org.eclipse.smarthome.automation.sample.extension.java project, shutdown and restart the whole SmartHome Runtime and see what happens. Or can I quickly replace a running bundle for a newly changed and compiled one?

Unfortunately, the /classicui/app and /basicui/app have been started and working, also the /basicui/CMD and /classicui/CMD have been started and at least don’t show any error, same with /chart. /esh/automation/restdemo/index.html also warks. But /ui (also not with /app or /index.html) doesn’t work, i was expecting the PaperUI, because the log shows

17:04:27.571 INFO o.e.s.u.p.internal.PaperUIApp[:31] - Started Paper UI at /ui
All of this is on my Linux Mint laptop running Java 8.
There is however an error early in running

osgi> 17:04:25.905 WARN  o.e.j.util.resource.Resource[:121] - java.net.URISyntaxException: Illegal character in path at index 91: file:/opt/eclipse/esh/smarthome-master/ws/.metadata/.plugins/org.eclipse.pde.core/SmartHome Runtime Sample Rules/org.eclipse.osgi/87/0/.cp/jettyhome/etc/jetty.xml
17:04:25.906 WARN  o.e.j.o.b.i.s.ServerInstanceWrapper[:157] - File does not exist file:/opt/eclipse/esh/smarthome-master/ws/.metadata/.plugins/org.eclipse.pde.core/SmartHome Runtime Sample Rules/org.eclipse.osgi/87/0/.cp/jettyhome/etc/jetty.xml; BadResource=java.net.URISyntaxException: Illegal character in path at index 91: file:/opt/eclipse/esh/smarthome-master/ws/.metadata/.plugins/org.eclipse.pde.core/SmartHome Runtime Sample Rules/org.eclipse.osgi/87/0/.cp/jettyhome/etc/jetty.xml
java.lang.IllegalStateException: No such jetty server config file: file:/opt/eclipse/esh/smarthome-master/ws/.metadata/.plugins/org.eclipse.pde.core/SmartHome Runtime Sample Rules/org.eclipse.osgi/87/0/.cp/jettyhome/etc/jetty.xml; BadResource=java.net.URISyntaxException: Illegal character in path at index 91: file:/opt/eclipse/esh/smarthome-master/ws/.metadata/.plugins/org.eclipse.pde.core/SmartHome Runtime Sample Rules/org.eclipse.osgi/87/0/.cp/jettyhome/etc/jetty.xml

But the jetty.xml looks quite OK to me (it only has 91 lines).

Do you maybe have any idea, what is up there?

The other thing are the JADE agents. There is a add on and little tutorial for using JADE in OSGi:
I also managed to compile this and deploy the bundle in a vanilla equinox runtime, it runs fine, starts an agent container and an agent. So now I need to introduce it to ESH…

Would I just create a new project in eclipse perhaps by copying the org.eclipse.smarthome.automation.sample.extension.java project to perhaps org.eclipse.smarthome.automation.agents, then change the meta files (pom.xml and the like) and include it as a plugin in the run configuration?

Thank you already for your help! :slight_smile:


What comes up when you just go to http://<host>:8080? That should give you a menu of all of the UIs you have installed. Based on all the customizations and rooting around in the console I don’t know if something got accidentally disabled or something like that.

Thank you for the quick reply! :slight_smile:
No, at / or /start/index I also only get
Problem accessing /start/index. Reason:
ProxyServlet: /start/index
Powered by Jetty://
I know the page you mean, it shows up on the “production” installation of openHAB on my RaspberryPi2, but not on the development instance of Eclipse SmartHome started from the Eclipse IDE on my laptop.

Felix, I would actually suggest to use the openHAB 2 IDE, not the ESH IDE setup - this makes things easier as you have all you need available in the target platform and you do not need the ESH projects in your workspace.
Additionally, this will have the openHAB Dashboard, so that you also so something at http://:8080 :slight_smile:

I managed to get rid of the errors in the ESH setup runs by changing the name of the example launch file to SmartHome-Runtime-Sample-Rules.launch (using dashes instead of blanks), also changed some Workspace/Target Platform plugins to resolve some conflicts. Paper UI didn’t show up.
That’s when I read @Kai s comment and switched back over to openHAB IDE. As mentioned in the guide, I had to close some projects with errors, but mostly .test ones.
The Dashboard and the PaperUI are now accessible. But now there’s some other problems :slight_smile:
In the console it shows (in red):

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.  

which I wouldn’t suspect to be harmful?

In the Extensions section, all the Names of Addons are gibberish like

AGSga Binding
binding3 - 1.0

or dcdnK, fdiDn, FftJS etc.

Also, there are only three tabs, Bindings, User Interfaces, Persistence Services but my production system (and also a test snapshot run on the Laptop) shows Action, Transformation, Voice, Misc additionally.

Under Configuration->System, there are only the sections Item Linking, Locale, Persistence but Extension Management is missing, so I can’t activate “Include Experimental Extensions” and therefore not the Rule Engine.

What went wrong and how can I fix this?

And lastly, I thought, https://www.eclipse.org/smarthome/documentation/development/rules/sample.extension.java.html would be a good start to understand the rule engine? But now, in the openHAB IDE, the org.eclipse.smarthome.automation.sample.extension.java project isn’t loaded. Can I just copy it over and activate it in the launch configuration -> Plug-ins (Workspace and Target Platform) so I have a place to start?

Wow, this is a steep learning curve. Sorry for all the questions… :frowning:


Hey, I just wanted to check back here after eclipseCon last week.
@Kai it was nice meeting you and thank you for the suggestions!
Sadly I missed the opportunity to show you the problems mentioned above live, but I am still stuck with them.
I cannot activate (or even see) the rule engine, so it’s very hard for me to get familiar with it and develop own Actions, Triggers or Templates.
Is there any idea or suggestion on how to debug this?