-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Refactored CULHandler lifecycle and configuration. #3885
Refactored CULHandler lifecycle and configuration. #3885
Conversation
7a9d418
to
f0e5a86
Compare
Also fixes #3910 |
@@ -270,6 +239,7 @@ protected void removeBindingProvider(FHTBindingProvider bindingProvider) { | |||
*/ | |||
@Override | |||
public void updated(Dictionary<String, ?> config) throws ConfigurationException { | |||
setProperlyConfigured(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked if it's true for AbstractBindings, but for AbstractActiveBindings it has side effects to setProperlyConfigured(false)
and then setProperlyConfigured(true)
. A different pattern could be:
if (config != null) {
boolean properlyConfigured = false;
try {
// parse and throw as needed...
properlyConfigured = true;
} finally {
setProperlyConfigured(properlyConfigured);
}
}
This looks like an impressive bit of refactoring and code size reduction. Thanks! Because the changes are so expansive, is it being heavily tested by other CUL users? Does it work on both 1.8 and 2.0 runtimes? Is it fully compatible with existing item and openhab.cfg configurations and the wiki docs? Sorry I'm not up on the subject myself. Will you leave this "in progress" to consider the other issues you mentioned above? Otherwise your changes look good. |
|
and I will adjust the code like you mentioned it, I somehow missed this, thanks |
Fixes openhab#3118, openhab#2358 Signed-off-by: Patrick Ruckstuhl <patrick@ch.tario.org> (github: tarioch)
f0e5a86
to
ad2a321
Compare
@watou updated setting the configured flag |
Any hints on getting the intertechno bindings to work in 2.0b2? |
I have it running with openhab 2. Are you using a version that has the feature for it or not? If you do it manually, there are some more dependencies. |
I was using the version you linked here: (1.9.0-pre1) The version that can be installed via paper ui did not work. To quickly tell you about my setup: When openhab starts it sometimes does so just starting the "CULIntertechno Refresh Service" and sometimes with: 11:57:59.501 [ERROR] [port.cul.internal.AbstractCULHandler] - Can't write report command to CUL
java.io.IOException: Stream closed
at java.io.BufferedWriter.ensureOpen(BufferedWriter.java:116)[:1.8.0_65]
at java.io.BufferedWriter.write(BufferedWriter.java:221)[:1.8.0_65]
at java.io.Writer.write(Writer.java:157)[:1.8.0_65]
at org.openhab.io.transport.cul.internal.AbstractCULHandler.requestCreditReport(AbstractCULHandler.java:296)[158:org.openhab.io.transport.cul:1.9.0.201602280212]
at org.openhab.io.transport.cul.internal.AbstractCULHandler.writeMessage(AbstractCULHandler.java:322)[158:org.openhab.io.transport.cul:1.9.0.201602280212]
at org.openhab.io.transport.cul.internal.AbstractCULHandler.access$0(AbstractCULHandler.java:309)[158:org.openhab.io.transport.cul:1.9.0.201602280212]
at org.openhab.io.transport.cul.internal.AbstractCULHandler$SendThread.run(AbstractCULHandler.java:62)[158:org.openhab.io.transport.cul:1.9.0.201602280212]
11:57:59.548 [ERROR] [port.cul.internal.AbstractCULHandler] - Can't write to CUL /dev/ttyUSB1
java.io.IOException: Stream closed
at java.io.BufferedWriter.ensureOpen(BufferedWriter.java:116)[:1.8.0_65]
at java.io.BufferedWriter.write(BufferedWriter.java:221)[:1.8.0_65]
at java.io.Writer.write(Writer.java:157)[:1.8.0_65]
at org.openhab.io.transport.cul.internal.AbstractCULHandler.writeMessage(AbstractCULHandler.java:316)[158:org.openhab.io.transport.cul:1.9.0.201602280212]
at org.openhab.io.transport.cul.internal.AbstractCULHandler.access$0(AbstractCULHandler.java:309)[158:org.openhab.io.transport.cul:1.9.0.201602280212]
at org.openhab.io.transport.cul.internal.AbstractCULHandler$SendThread.run(AbstractCULHandler.java:62)[158:org.openhab.io.transport.cul:1.9.0.201602280212] Even when it starts correctly i always get this message when trying to trigger a switch: 11:58:54.161 [WARN ] [org.apache.karaf.services.eventadmin] -
EventAdmin: Exception during event dispatch [org.osgi.service.event.Event [topic=openhab/command/Steckdose] | {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={event.topics=openhab/command/*, service.pid=org.openhab.culintertechno, component.name=org.openhab.binding.intertechno.binding, component.id=0, service.id=256, service.bundleid=10, service.scope=bundle} | Bundle(org.openhab.binding.intertechno_1.9.0.201601171404 [10])]
java.lang.NullPointerException
at org.openhab.binding.intertechno.internal.CULIntertechnoBinding.internalReceiveCommand(CULIntertechnoBinding.java:160)[10:org.openhab.binding.intertechno:1.9.0.201601171404]
at org.openhab.core.binding.AbstractBinding.receiveCommand(AbstractBinding.java:97)[151:org.openhab.core.compat1x:2.0.0.201602231517]
at org.openhab.core.events.AbstractEventSubscriber.handleEvent(AbstractEventSubscriber.java:42)[151:org.openhab.core.compat1x:2.0.0.201602231517]
at org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:415)[3:org.apache.karaf.services.eventadmin:4.0.3]
at org.apache.felix.eventadmin.impl.tasks.HandlerTask.runWithoutBlacklistTiming(HandlerTask.java:102)[3:org.apache.karaf.services.eventadmin:4.0.3]
at org.apache.felix.eventadmin.impl.tasks.SyncDeliverTasks.execute(SyncDeliverTasks.java:104)[3:org.apache.karaf.services.eventadmin:4.0.3]
at org.apache.felix.eventadmin.impl.tasks.AsyncDeliverTasks$TaskExecuter.run(AsyncDeliverTasks.java:163)[3:org.apache.karaf.services.eventadmin:4.0.3]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_65]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_65]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
11:58:54.179 [INFO ] [marthome.event.ItemStateChangedEvent] - Steckdose changed from NULL to OFF
11:58:59.504 [INFO ] [b.core.service.AbstractActiveService] - CULIntertechno Refresh Service has been shut down What am i doing wrong? -.-* |
Looks like you actually mixed two things. My refactoring requires both intertechno and cul to be taken from the jars. So it should be Features
Jars
Config for your stick should then be a file called device=serial:/dev/ttyUSB1
baudrate=38400
parity=NONE Please also be aware that there seems to be an issue for some on the raspberry pi, see |
Okay, thanks for your support. Any ideas where the the sources went? It seems like they're gone and i'm not really into this whole Maven stuff. |
Any chance of getting this merged? |
Okay to get some pace here again and to focus more on the openhab side of things. I'm now using the modified io.transport.serial mentioned in NeuronRobotics/nrjavaserial#60 and except the screen issue to get this whole thing started it runs smoothly. I am not using your JARs ATM. |
Can you try my JARs + modified nrjavaserial. With this hopefully everything should be working without a need for screen. |
where do I find the latest *.jars for further tests? The ones you've send me, didn't work in my setting, but I changed several things and will give it another try. |
As @watou suggested here https://community.openhab.org/t/pull-requests-and-time-to-get-in/8341/4 trying to summarize the current testing that went into this
myself
Risks/changes
|
@tarioch : Setup 1st Try:
Bindings in /addon folder
Bindings installed via feature:install
DOES NOT WORK Setup 2nd Try:
Bindings in /addon folder
Bindings installed via feature:install
WORKS |
Hm, something seems off in the first try, the line number of that error only matches in the old code (without my changes). Could there maybe be some caching or something (I don't know what) that still parts of the original jar is somehow picked up? |
I will try to look into this. But i won't have time until sunday. :-( |
@tarioch, it looked like this PR is still awaiting tester feedback? Does its working over serial require changes that aren't part of openHAB yet? Will the affected JARs continue to work on openHAB 1.8? Is all the relevant user documentation consistent with this PR? I've looked for answers but I'm sorry I'm not deep enough in the code and history to piece it together. Any others you could enlist to give any critical feedback? |
|
Thank you, @tarioch, for all of your wiki updates! |
Fixes #3118, #2358
Signed-off-by: Patrick Ruckstuhl patrick@ch.tario.org (github: tarioch)