Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No transformation service available #128

Closed
sipvoip opened this issue Mar 15, 2017 · 26 comments
Closed

No transformation service available #128

sipvoip opened this issue Mar 15, 2017 · 26 comments

Comments

@sipvoip
Copy link

sipvoip commented Mar 15, 2017

Found an issue when migrating to openHAB 2, it looks like transformation are not working at least with the serial binding. I think it has to do with 1x compatibility layer because it works fine in 1.8.3.

Item:
Number Septic_Level_Sensor {serial="/dev/ttyPort3,REGEX(.?([0-9]+).)"}

Seeing:
2017-02-25 16:28:10.896 [ERROR] [binding.serial.internal.SerialDevice] - No transformation service available!

I have REGEX transform installed according to paper.

@marekhalmo
Copy link

Hello, i have the same issue.. Any ideas on why this is a problem?

@marekhalmo
Copy link

I have been looking in to this issue.
@csowada has made the change in the code that uses the service instead of pattern matcher. Maybee he could help
@csowada could you please explain how the transformation service is set during startup?

@csowada
Copy link

csowada commented Apr 25, 2017

So I have looked into this issue. There is simply no compat delegator for the transformation service. But there is a Helper Class that should work without declarative services.

https://github.com/openhab/openhab1-addons/blob/1.8/bundles/core/org.openhab.core.transform/src/main/java/org/openhab/core/transform/TransformationHelper.java

@marekhalmo
Copy link

Hello,
thank you for the super fast response.
I tried the TransformationHelper but it still does not work
The error is: "Cannot get service reference for transformation service of type REGEX"

@marekhalmo
Copy link

I also have been looking in to this and it seems that this is OH 1.x vs OH2 compatibility issue.
There are interfaces of Transformation service with the same name in both projects but they have a different package:

org.eclipse.smarthome.core.transform.TransformationService org.openhab.core.transform.TransformationService

So the serial binding with regex transformation will work for OH1 but won't for OH2
I can't change the transformation service to OH2 because OH1 addons project does not have (and will never have) a OH2 dependency to the required.

What to do now? Is it necessary to migrate the serial binding to OH2?

@csowada
Copy link

csowada commented Apr 25, 2017

Have you checked that a TransformationService is available from your Karaf console? I think the TransformationHelper class is the best solution.

@marekhalmo
Copy link

It won't ever be possible. Th interface types specified in osgi xml don't match..

@marekhalmo
Copy link

The RegexTransformationService for OH2 implements interface org.eclipse.smarthome.core.transform.TransformationService. The RegexTransformationService for OH2 specified in serialBinding requires implementation of interface org.openhab.core.transform.TransformationService.

Because there is no way of including org.eclipse.smarthome.core.transform.TransformationService in the OH1 addons and OH2 will never have org.openhab.core.transform.TransformationService regex implementation, you can't possibly have OH2 binding.

There are multiple solution to this.
a) Migrate serial binding to OH2
b) Implement logic to SerialBinding that if you don't provide TransformationService, it will use a basic regex as in the original commit. The basic regex could be wrapped in a custom TransformationService implementation

I guess i would go for b) just to keep the code of serial binding at the same place for OH1/2.. Should i do this?

@marekhalmo
Copy link

Hm.. i also found out that the previous implementation with pattern matching was better because it could handle fast serial port updates.
For example imagine you wanted to parse temperature update in format
Tmp: 10deg

If the device sends the temperature twice fast you get a partial string e.g.
Tmp: 10deg\r\nTmp: 11deg\r\n

With the old code you will match both 10deg and 11deg.. -> Values fine.
If you use the new code you will only match the first string and the rest will be ignored.
E.g. > You get 10deg and ignore the correct value 11deg coming second.

It is also very unpredictable so hard to find the issue..

You can also in theory have a partial data (e.g. Tmp: 1) which will ignore everything completely.. So without definition of next data separator the serial binding is kinda useless

@sipvoip
Copy link
Author

sipvoip commented Apr 25, 2017

So can we move back to the old way? I have some fast devices so I also run into this issue. How much time do you think it would take to fix the serial binding for openHAB2?

@marekhalmo
Copy link

Hm... i have a partial fix done locally but it just fixes the issue with TransactionService not available in OH2.

I can create a pull request tomorrow but it won't fix the rapid command issue.

Now what?

@marekhalmo
Copy link

@sipvoip are you experiencing message drops when using serial binding with regex and OH1?

@marekhalmo
Copy link

Ok i have been thinking about this for a while and i think i will have a good solution tomorrow. I will create a fix and a pull request asap (i also need this be in release soon)

The fix will be following:

  1. i will take code from OH2 regex transformation and adapt it to form of old code
  2. I will modify md file to comply with the changes

This way the code will be able to parse multiple commands as the old version and won't depend on the transformation service and OH version. It also won't break compability with regex syntax. I think that the transformations are meant to be used in rules only so there should be no issue from architectural point of view.

Binding depending on another component that has to be installed manually can only lead to confusion

@marekhalmo
Copy link

marekhalmo commented Apr 26, 2017

Implemented, just need to wait for the this pull request to be merged so i can create a branch for the fix.

It will work according to the new RegexTransformationService described here

I will let you know when there will be official branch..

@sipvoip
Copy link
Author

sipvoip commented Apr 28, 2017

Is there a .jar I can try?

@marekhalmo
Copy link

not yet

@marekhalmo
Copy link

I still have a bit trouble with the repeating patterns (or fast commands)..

The RegexTransformation uses ^REGEX_PATTERN$ with DOTAL to find the group.. that is fine if you want to extract number from simple string like "Temp: 10\n"... but if you get two responses it looks like "Temp: 10\nTemp: 10\n".. the pattern match just wont match the string because the ^ and $ and DOTAL means that the whole string has to be matched in order to get the group... so in that case the whole received string gets ignored.

Could anyone help with this? I would post sniplets of code so you could see what's going on

@9037568
Copy link
Contributor

9037568 commented Apr 28, 2017

What does DOTAL mean? Never heard of it before.

If you're implementing a new/pseudo transformation service, you should be able to use whatever pattern works; no need to stick with the one you're quoting, is there?

@marekhalmo
Copy link

A great explanation can be found (here) [ http://docs.oracle.com/javase/tutorial/essential/regex/pattern.html] ...

The new REGEX matcher has to comply with the existing functionality so we don't break the config files of everybody that uses it.

@9037568
Copy link
Contributor

9037568 commented Apr 29, 2017

Yes, but remember it's the output from the transformation that matters. How that output is produced doesn't.

@marekhalmo
Copy link

marekhalmo commented May 3, 2017

Hello guys, i committed the full patch for this here (sorry for the double linking)

A jar for everybody to test can be found here
Just put it in your adons folder and it should work

@marekhalmo
Copy link

Hello, anyone tried the provided JAR?

@csowada
Copy link

csowada commented May 15, 2017

No, sorry but I not use this binding anymore.

@marekhalmo
Copy link

Okay.. the fix was merged.. you can expect this working in next release... until the you can use the provided jar...

Thanks everyone for your support.

@kaikreuzer
Copy link
Member

So if I get it right, this issue here can be closed. Thanks @marekhalmo for dealing with it in the serial binding!

@marekhalmo
Copy link

@kaikreuzer glad i could help :)

Rosi2143 pushed a commit to Rosi2143/openhab-core that referenced this issue Dec 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants