tuck182 / harmony-java-client Goto Github PK
View Code? Open in Web Editor NEWJava client for communicating with a Harmony Hub
License: Other
Java client for communicating with a Harmony Hub
License: Other
It would be great to be able to use this project as a dependency in tools like maven. It doesn't have to be in maven central but at least as a "github" repository.
There are plug ins for maven like com.github.github:site-maven-plugin.
I'm not sure what is your preference (maven or gradle) but if you don't mind maven, i can do a pull request to enable this. I'm not familiar with gradle at all so I don't think I can be of much help.
You can find an example in one of my projects: https://github.com/lamarios/sparknotation
get_config
java.util.MissingFormatArgumentException: Format specifier '2f'
at java.util.Formatter.format(Formatter.java:2487)
at java.util.Formatter.format(Formatter.java:2423)
at java.lang.String.format(String.java:2790)
at net.whistlingfish.harmony.shell.ShellCommand.println(ShellCommand.java:12)
at net.whistlingfish.harmony.shell.GetConfigCommand.execute(GetConfigCommand.java:8)
at net.whistlingfish.harmony.shell.ShellCommandWrapper.execute(ShellCommandWrapper.java:20)
The simple fix is to stop using String.format for that output or pass the json data in as an arg (should also review uses of the println method to make sure inputs are cleaned up).
I believe the install is correct, however could be wrong.
the Execute the jar line 'HARMONY_HOST LOGITECH_USERNAME LOGITECH_PASSWORD' I've swapped out with IP address and username(email) and password, is this correct?
I have this error.
21:24:59.965 [main] DEBUG n.w.harmony.HarmonyClient - listener[net.whistlingfish.harmony.Main$1@544a2ea6] added
21:25:00.878 [main] DEBUG n.w.harmony.protocol.AuthService - auth token request returned: {"GetUserAuthTokenResult":null}
Exception in thread "main" java.lang.RuntimeException: Failed to parse response from Logitech auth service
at net.whistlingfish.harmony.protocol.AuthService.getLoginToken(AuthService.java:45)
at net.whistlingfish.harmony.HarmonyClient.connect(HarmonyClient.java:111)
at net.whistlingfish.harmony.Main.execute(Main.java:37)
at net.whistlingfish.harmony.Main.main(Main.java:27)
Caused by: us.monoid.json.JSONException: JSONObject["GetUserAuthTokenResult"] is not a JSONObject.
at us.monoid.json.JSONObject.getJSONObject(JSONObject.java:579)
at net.whistlingfish.harmony.protocol.AuthService.getLoginToken(AuthService.java:41)
... 3 more
Following the wiki I tried to build the jar with gradle, but got an error doing so:
FAILURE: Build failed with an exception.
Where:
Build file '/home/alex/Downloads/harmony-java-client-master/build.gradle' line: 132
What went wrong:
A problem occurred evaluating root project 'harmony-java-client-master'.
Could not find property 'MavenPublication' on Publication set.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Hi Matt, I think the title sums this up nicely ;-)
So I have four hubs, one original, one 2nd gen and two new ones.
As a refresher, when you send an IQ packet with the startActivity payload, you receive back a series of response IQ packets with the error code "100" (continue) as each device starts up, then finally a packet with an error code of "200" which means we are done. At least on the first gen device.....
On later models this has changed. Now when you send the start activity packet, you immediately get a response with the error code of "200"..... but now 2 things happen which are screwy. First is that you still receive the series of error code "100" packets AFTER the 200 packet, still in response to the original IQ message (so same iq id). Second, the mime type changes from "vnd.logitech.harmony/vnd.logitech.harmony.engine?startactivity" to "harmony.engine?startActivity" on these packets.
The result is that the library 1) throws up on the unknown mime type and 2) it thinks the activity is done starting before it is. Because it gets the 200 so soon, it quickly sends a getCurrentActivity, which will not get a reply until the activity is truly done starting, and so the client times out.
I have some hacks to get around this, but they are hacks and probably not a great long term solution. Below is a sample XML flow.
<iq id='8bC2B-48' from='1111/main' type='get'>
<oa xmlns="connect.logitech.com" mime="vnd.logitech.harmony/vnd.logitech.harmony.engine?startactivity">activityId=10609811:timestamp=135632</oa>
</iq>
<iq/>
<iq id="8bC2B-48" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='vnd.logitech.harmony/vnd.logitech.harmony.engine?startactivity' errorcode='200' errorstring='OK'></oa>
</iq>
<message content-length="635" />
<message from="[email protected]" to="ab903454-7bee-4410-9eea-bb5355bb667e">
<event xmlns="connect.logitech.com" type="connect.stateDigest?notify">
<![CDATA[{"sleepTimerId":-1,"contentVersion":70,"activityId":"10609811","syncStatus":0,"time":1426640265,"stateVersion":99,"tzOffset":"-25200","mode":3,"hubSwVersion":"4.3.48","tzoffset":"-25200","sequence":false,"discoveryServer":"https:\/\/svcs.myharmony.com\/Discovery\/Discovery.svc","activityStatus":1,"runningActivityList":"","tz":"PST8PDT,M3.2.0,M11.1.0","wifiStatus":1,"configVersion":76,"hubUpdate":false,"updates":{"106":"4.3.48"},"accountId":"5594045"}]]>
</event>
</message>
<iq id='8bC2B-50' from='1111/main' type='get'>
<oa xmlns="connect.logitech.com" mime="vnd.logitech.harmony/vnd.logitech.harmony.engine?getCurrentActivity"></oa>
</iq>
<iq/>
<iq id="8bC2B-50" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='vnd.logitech.harmony/vnd.logitech.harmony.engine?getCurrentActivity' errorcode='200' errorstring='OK'>
<![CDATA[result=-1]]>
</oa>
</iq>
<iq id="8bC2B-48" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='harmony.engine?startActivity' errorcode='100' errorstring='Continue'>
<![CDATA[done=1:total=13:deviceId=21715546]]>
</oa>
</iq>
<iq id="8bC2B-48" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='harmony.engine?startActivity' errorcode='100' errorstring='Continue'>
<![CDATA[done=2:total=13:deviceId=21715545]]>
</oa>
</iq>
<iq id="8bC2B-48" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='harmony.engine?startActivity' errorcode='100' errorstring='Continue'>
<![CDATA[done=3:total=13:deviceId=21715547]]>
</oa>
</iq>
<iq id="8bC2B-48" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='harmony.engine?startActivity' errorcode='100' errorstring='Continue'>
<![CDATA[done=4:total=13:deviceId=21715549]]>
</oa>
</iq>
<iq id="8bC2B-48" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='harmony.engine?startActivity' errorcode='100' errorstring='Continue'>
<![CDATA[done=5:total=13:deviceId=21715549]]>
</oa>
</iq>
<iq id="8bC2B-48" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='harmony.engine?startActivity' errorcode='100' errorstring='Continue'>
<![CDATA[done=6:total=13:deviceId=21715545]]>
</oa>
</iq>
<iq id="8bC2B-48" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='harmony.engine?startActivity' errorcode='100' errorstring='Continue'>
<![CDATA[done=7:total=13:deviceId=21715545]]>
</oa>
</iq>
<iq id="8bC2B-48" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='harmony.engine?startActivity' errorcode='100' errorstring='Continue'>
<![CDATA[done=8:total=13:deviceId=21715545]]>
</oa>
</iq>
<iq id="8bC2B-48" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='harmony.engine?startActivity' errorcode='100' errorstring='Continue'>
<![CDATA[done=9:total=13:deviceId=21715545]]>
</oa>
</iq>
<iq id="8bC2B-48" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='harmony.engine?startActivity' errorcode='100' errorstring='Continue'>
<![CDATA[done=10:total=13:deviceId=21715545]]>
</oa>
</iq>
<iq id="8bC2B-48" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='harmony.engine?startActivity' errorcode='100' errorstring='Continue'>
<![CDATA[done=11:total=13:deviceId=21715545]]>
</oa>
</iq>
<iq id="8bC2B-48" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='harmony.engine?startActivity' errorcode='100' errorstring='Continue'>
<![CDATA[done=12:total=13:deviceId=21715545]]>
</oa>
</iq>
<iq id="8bC2B-48" to="1111/main" type="get">
<oa xmlns='connect.logitech.com' mime='harmony.engine?startActivity' errorcode='401' errorstring='Bluetooth not paired'>
<![CDATA[done=13:total=13:deviceId=21715546]]>
</oa>
</iq>
Hi,
I am heavily using the harmony CLI from my scripts. Some days ago I have found my setup to be non-functional. A research did show me that Logitech has changed their APIs and OH1 bindings do not work anymore. But fortunately the binding has been back ported to OH1 from OH1 (discovery instead of User/Pass/IP). That seems to work but I cannot substitute activities from my scripts with activities configured in OH rules (missing functions/flaws). So I am really needing an update on this harmony-java-client to also work with discovery but IP/User/Pass. PLEASE!!!!
Thank you in advance for ANY help!
Thorsten
BTW: Just to make this clear: I'd go for activities defined in the OH rules but the harmony itself does not work correctly with my SAMSUNG: I cannot start the TV on HDMI nor can I switch the TV to HDMI (the GUI is broken). I can only switch to HDMI channels using the CLI here (which is not working anymore). So my complete setup stopped working now and I cannot fix it!
Hi,
when I want to turn off the devices, I send a startActivity with label "PowerOff". While this effectively turns off my devices, it immediately starts another activity, which happens to be the first one in my list in the app ("watch television"). Do you have any idea why this might be happening?
Kind regards
Hallo,
i tried to use your Library in an own application.
I compiled the src with gradle and added it to my Project.
Simplified Code:
private HarmonyClient client = new HarmonyClient();
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
client.addListener(new ActivityChangeListener() {
@Override
public void activityStarted(Activity activity) {
jLabel1.setText("activity changed: " + activity.getLabel());
}
});
client.connect("MyHubsIp", "myharmonyuser", "mypassword");
jLabel1.setText("Connected");
}
But all I get is
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at net.whistlingfish.harmony.HarmonyClient.connect(HarmonyClient.java:96)
at harmonyjavaapp.MainForm.jButton1ActionPerformed(MainForm.java:80)
The HarmonyClient.java:96 corresponds to:
* 16: invokespecial net/whistlingfish/harmony/HarmonyClient.createConnectionConfig:(Ljava/lang/String;I)Lorg/jivesoftware/smack/ConnectionConfiguration;
using the built-in shell works!
Any Help?
IDE: NetBeans 8.0.2 on MacOS Yosemite
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Thanks
Hi,
I cloned the repo and build it using gradle like described in the readme. But I got a NoClassDefFoundError during start
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/inject/Module
at net.whistlingfish.harmony.Main.main(Main.java:24)
Caused by: java.lang.ClassNotFoundException: com.google.inject.Module
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
I'm trying to compile this harmony client and having difficulty. Using a Mac OSX client (Yosemite).
Is this project still valid? Is this a code issue or my client/config?
$ gradle --stacktrace assemble
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> invalid source release: 1.7
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileJava'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
As you have probably heard, Logitech decided to kill local network access via Xmpp. Any chance you could change to the local websocket API?
Hi,
i'm trying to use you code in my android wear app but i didn't understand how to do.
Could you help me and give me some simple commands i have to add in my app to connect to the hub and send commands ?
thanks,
cyril
When device is in PowerOff and I send PowerOff activity to it by name, it powers on one of my devices (projector in my case).
When device is not in PowerOff, it powers off correctly and does not start that device.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.