Issues converting rules from 1.8 to 2.0

I am thinking about testing out OpenHab 2, but I wanted to check all my rules for errors under the new framework first. So I setup the latest Eclipse SmartHome Designer and viewed all of my rules. There are a few errors in particular that I want to ask about. I have not tested any of my rules in the new runtime yet. I am just asking about the errors found in the Designer.

The first error has to deal with creating a State variable. In my old rule I referred to “org.openhab.core.types.State” but I updated the class to the new location “org.eclipse.smarthome.core.types.State”. However, the line:

var State state = null

Yields the warning:

Access restriction: The type State is not accessible due to restriction on required project config

The next error has to do with using lambdas. For the statement:

val report = Battery.allMembers.filter([state instanceof DecimalType]).sortBy([state]).map[
name + “: " + state.format(”%d%%“)
].join(”\n")

I get the error:

Bounds mismatch: The type arguments <Item, State> are not a valid
substitute for the bounded type parameters <T, C extends Comparable<?
super C>> of the method sortBy(Iterable, Function1<? super
T, C>)

The final error I see is when I use sendMail:

sendMail(“xxxx@gmail.com”, “Dryer finished!”, message)

Error:

The method sendMail(String, String, String) is undefined

Any help with any of these errors would be great. Thanks!

I had the same error message in for sendMail and pushover but the rules worked. I think it is a problem with the designer. State didn’t work for me either so had to change my rules

Thanks, I was hoping this was the case for this error.

Just wanted to follow up with my own post. The errors from the Designer did not seem to impact the rules when run with OpenHab 2. SendEmail worked as Rod said it would and the lambdas worked fine as well.

This is correct, it is merely the Designer who is not aware of those actions, the runtime knows about them and executes those rules nicely.

I understand the problems importing the addons into the smart home designer.

Nevertheless is there an easy/quick workaround to at least get rid of the warnings?

Maybe something like:

#define external sendMail

1 Like