Creating a custom binding

436 views
Skip to first unread message

Jonathan Giles

unread,
Jul 16, 2013, 2:17:01 AM7/16/13
to ope...@googlegroups.com
Hi all,

Sorry about the last message regarding missing posts - this will be the third time I've posted this message about creating a custom binding - the last two appear to have been gobbled up by Google. Because I've already written two long emails I'll keep this one brief, in case I lose this one too! :-)

In short, I need help getting a new binding to compile. I'm lost on how to get properly started. I note there is a maven archetype, but it fails for me with the following:

mvn archetype:generate -B -DarchetypeGroupId=org.openhab.archetype -DarchetypeArtifactId=org.openhab.archetype.binding -DarchetypeVersion=1.2.0-SNAPSHOT -Dauthor=jgiles -Dversion=1.2.0 -DartifactId=org.openhab.binding.opensprinklerpi -Dpackage=org.openhab.binding.opensprinklerpi -Dbinding-name=openpsrinklerpi
[INFO] Scanning for projects...
[ERROR] Internal error: java.lang.RuntimeException: Could not resolve target platform specification artifact org.openhab:targetplatform:target:openhab:1.3.0-SNAPSHOT -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: Could not resolve target platform specification artifact org.openhab:target
platform:target:openhab:1.3.0-SNAPSHOT
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:168)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:491)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.RuntimeException: Could not resolve target platform specification artifact org.openhab:targetplatform:target:openhab:1.3.0-SNAPSHOT
        at org.eclipse.tycho.core.resolver.DefaultTargetPlatformConfigurationReader.addTargetArtifact(DefaultTargetPlatformConfigurationReader.java:334)
        at org.eclipse.tycho.core.resolver.DefaultTargetPlatformConfigurationReader.setTarget(DefaultTargetPlatformConfigurationReader.java:288)
        at org.eclipse.tycho.core.resolver.DefaultTargetPlatformConfigurationReader.getTargetPlatformConfiguration(DefaultTargetPlatformConfigurationReader.java:71)
        at org.eclipse.tycho.core.resolver.DefaultTychoDependencyResolver.setupProject(DefaultTychoDependencyResolver.java:78)
        at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:77)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:274)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        ... 11 more
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/InternalErrorException

If I instead copy/paste the exec binding and make modifications, things work fine until I try to export the plugin, at which point I get error messages in my Manifest.mf file about "No available bundle exports package 'org.openhab.core.binding'". I've tried adding the relevant jar files from a downloaded openhab download, but to no avail. Personally I wonder whether there is a version descrepancy between 1.2.0 and 1.3.0?

Any pointers to get me started would be much appreciated - I've already built the OpenSprinkler Pi library, and I'm eager to get started on the higher level OpenHab binding.

Thanks!

Jonathan Giles

unread,
Jul 16, 2013, 5:14:27 AM7/16/13
to ope...@googlegroups.com
A quick status update: progress! :-)

Firstly, doing a 'mvn clean compile' from the openhab root directory (from the hg clone) gave me the ability to fully complete the maven archetype (once I changed the 1.2.0 references to 1.3.0).

I've also come to discover the IDE setup page (how did I miss that?!!?). I'm now working through installing that and hoping for the best.

-- Jonathan

Ben Jones

unread,
Jul 16, 2013, 6:39:44 AM7/16/13
to ope...@googlegroups.com
Nice one Jonathon - I am very interested to hear what you are planning to do with OpenSprinkler Pi. I have just ordered my fourth Pi which I intend to use as an irrigation controller interfacing with openHAB. I was planning to use my existing PiFace binding and write some GPIO-only python scripts to handle the events etc on the Pi, but would be interested to hear about you are intending to use the OpenSprinkler stuff.

Jonathan Giles

unread,
Jul 16, 2013, 4:17:16 PM7/16/13
to ope...@googlegroups.com
@All: Everything now compiles! The last trick was that the default Eclipse installed by yoxos had the compiler set to use javac 1.4, where obviously that should be 1.5 or greater (due to enums and other features being used). In my case I set it to 1.7 and everything compiled.

@Ben: There is a bunch of good software already written for the OpenSprinkler Pi (web interfaces particularly). In my case I'd rather have a simpler system that is integrated into OpenHAB (to interface with the rest of my house) than the more feature-filled options offered elsewhere. Therefore, my plan is to basically start with the ability to switch sprinkler stations open and closed, and then see where to go from there. I've already coded up the Java code to open / close the stations (it was simply a port of the C / python code available elsewhere, rewritten in Java and using the Pi4J library). Now I'm try to get a binding written, which shouldn't take long now that I've got the IDE set up. I'll keep posting to this forum as I have progress, although I should note that my OpenSprinkler Pi hasn't arrived yet, so the library and binding that I'm writing are all theoretically working at the moment - I don't imagine I'll have the actual OpenSprinkler Pi for another few weeks at least.

-- Jonathan

Ben Jones

unread,
Jul 16, 2013, 4:36:47 PM7/16/13
to ope...@googlegroups.com
Great - sounds good. And that is pretty much exactly my plan. I have purchased on of these (http://www.hobbyist.co.nz/?q=4-channel-relay-module) and intend to connect it directly to the GPIO pins on a stock standard RPi. I am hoping I should then be able to write a simple script, much like the scripts I wrote for my RPi with the PiFace board, and then use my existing PiFace binding for openHAB to update the relays.

Just mentioning this as it may save you a load of time and effort, since it sounds very similar to what you are doing.


--
You received this message because you are subscribed to a topic in the Google Groups "openhab" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openhab/r7Udy0ne_ro/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jonathan Giles

unread,
Jul 16, 2013, 4:39:39 PM7/16/13
to ope...@googlegroups.com
Yeah, I've got a similar 4 channel relay board here too, but I like that
the OpenSprinkler Pi abstracts away some of the electronic complexities.
I'm a software engineer, so software is easy for me, whereas electronics
are not :-)

I note you linked to a .co.nz domain - are you in New Zealand? I am too
- located in Palmerston North.

-- Jonathan

Ben Jones

unread,
Jul 16, 2013, 4:43:54 PM7/16/13
to ope...@googlegroups.com
Ha - classic - yeah down in ChCh.
Reply all
Reply to author
Forward
0 new messages