Harmony binding issue

I’m having issues with my Harmony binding, which I believe is connection related. The problem is that the binding seams to report “PowerOff” every now and then, which is OK if the activity is “PowerOff”.

However, since I’m using the activity state change for powerring off my entire home cinema and start ventilation and put the lights on, it is rather (mildly speaking!!!) irritating when this happens during a movie as you can imagine. :scream:

So first I wanted to see if anyone else has experienced this, and secondly if it sounds reasonble that this is related to connection? I guess it could also be the Hub that restarts and that it defaults to PowerOff.

I know that I get the PowerOff activity event, and without triggering this from the remote, but I don’t know much else, but I at some point saw tcp broken socket in the logs which looked to be related.

If this is the case, wouldn’t it be better to set the activity to ‘Unknown’ or similar (I’m presuming it defaults to PowerOff).

I guess a workaround for now, is to start at timer and wait to see if the Activity is still PowerOff after a few seconds.

I’ve been using Harmony with Openhab for my home theater, and haven’t had any random behavior. It’s usually me accidentally sitting on a remote that screws things up. I also wouldn’t think that the hub would default out anything if it rest. Do you have any rules set up that could be triggering things? I have 2 other hubs in other rooms and haven’t had any of that happen either.

Yesterday, I decided to enable this again, since it would be nice to power off the compelete room with the remote. But after some hours, I had the problem again, and it seams that if Harmony binding looses connection with the Hub, there’s a short moment while restarting a new socket, that a Power Off event is reported from the binding;

2016-09-03 20:40:24.613 [WARN ] [.whistlingfish.harmony.HarmonyClient] - Send heartbeat failed
java.lang.RuntimeException: Failed communicating with Harmony Hub
	at net.whistlingfish.harmony.HarmonyClient.sendOAPacket(HarmonyClient.java:270)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at net.whistlingfish.harmony.HarmonyClient.sendOAPacket(HarmonyClient.java:259)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at net.whistlingfish.harmony.HarmonyClient.sendPing(HarmonyClient.java:332)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at net.whistlingfish.harmony.HarmonyClient$2.run(HarmonyClient.java:174)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_92]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)[:1.8.0_92]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)[:1.8.0_92]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)[:1.8.0_92]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_92]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_92]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_92]
Caused by: org.jivesoftware.smack.SmackException$NoResponseException
	at net.whistlingfish.harmony.HarmonyClient.getNextPacketSkipContinues(HarmonyClient.java:282)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at net.whistlingfish.harmony.HarmonyClient.sendOAPacket(HarmonyClient.java:268)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	... 10 more
2016-09-03 20:40:48.737 [WARN ] [.jivesoftware.smack.tcp.PacketWriter] - Exception writing closing stream element
java.net.SocketException: Broken pipe
	at java.net.SocketOutputStream.socketWrite0(Native Method)[:1.8.0_92]
	at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)[:1.8.0_92]
	at java.net.SocketOutputStream.write(SocketOutputStream.java:153)[:1.8.0_92]
	at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)[:1.8.0_92]
	at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)[:1.8.0_92]
	at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)[:1.8.0_92]
	at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)[:1.8.0_92]
	at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)[:1.8.0_92]
	at java.io.BufferedWriter.flush(BufferedWriter.java:254)[:1.8.0_92]
	at org.jivesoftware.smack.tcp.PacketWriter.writePackets(PacketWriter.java:190)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at org.jivesoftware.smack.tcp.PacketWriter.access$000(PacketWriter.java:40)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at org.jivesoftware.smack.tcp.PacketWriter$1.run(PacketWriter.java:77)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
2016-09-03 20:40:48.739 [WARN ] [rg.jivesoftware.smack.XMPPConnection] - Connection closed with error
java.net.SocketException: Connection reset
	at java.net.SocketInputStream.read(SocketInputStream.java:209)[:1.8.0_92]
	at java.net.SocketInputStream.read(SocketInputStream.java:141)[:1.8.0_92]
	at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)[:1.8.0_92]
	at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)[:1.8.0_92]
	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)[:1.8.0_92]
	at java.io.InputStreamReader.read(InputStreamReader.java:184)[:1.8.0_92]
	at java.io.BufferedReader.fill(BufferedReader.java:161)[:1.8.0_92]
	at java.io.BufferedReader.read1(BufferedReader.java:212)[:1.8.0_92]
	at java.io.BufferedReader.read(BufferedReader.java:286)[:1.8.0_92]
	at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:2992)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at org.xmlpull.mxp1.MXParser.more(MXParser.java:3046)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1144)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at org.jivesoftware.smack.tcp.PacketReader.parsePackets(PacketReader.java:279)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at org.jivesoftware.smack.tcp.PacketReader.access$000(PacketReader.java:47)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at org.jivesoftware.smack.tcp.PacketReader$1.run(PacketReader.java:81)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
2016-09-03 20:40:54.615 [WARN ] [.whistlingfish.harmony.HarmonyClient] - Send heartbeat failed
java.lang.RuntimeException: Failed communicating with Harmony Hub
	at net.whistlingfish.harmony.HarmonyClient.sendOAPacket(HarmonyClient.java:270)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at net.whistlingfish.harmony.HarmonyClient.sendOAPacket(HarmonyClient.java:259)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at net.whistlingfish.harmony.HarmonyClient.sendPing(HarmonyClient.java:332)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at net.whistlingfish.harmony.HarmonyClient$2.run(HarmonyClient.java:174)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_92]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)[:1.8.0_92]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)[:1.8.0_92]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)[:1.8.0_92]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_92]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_92]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_92]
Caused by: org.jivesoftware.smack.SmackException$NoResponseException
	at net.whistlingfish.harmony.HarmonyClient.getNextPacketSkipContinues(HarmonyClient.java:282)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	at net.whistlingfish.harmony.HarmonyClient.sendOAPacket(HarmonyClient.java:268)[204:org.openhab.binding.harmonyhub:2.0.0.201608100106]
	... 10 more
2016-09-03 20:41:00.932 [INFO ] [clipse.smarthome.model.script.Scenes] - Harmony state changed to PowerOff
2016-09-03 20:41:01.996 [INFO ] [clipse.smarthome.model.script.Scenes] - Harmony state changed to Visa filmer

The last two lines are my ony rule that is listening on events from the Harmony binding;

rule "Act on Harmony changes"
when 
Item Harmony_Activity changed 
then
  var state = "Harmony state changed to " + Harmony_Activity.state
  logInfo("Scenes", state)
  if( Harmony_Activity.state == "PowerOff" )
  {
  	Thread::sleep(1*1000)
  	sendCommand(GF_Cinema_Active_Scene,OFF)
  }
end

In my case, I guess I could just start a trigger and wait a couple of seconds before triggering the cinema power off and check just before sending the poweroff, that the state is still power off.