Is there a way to create functions/routines in openhab?

Not like you want, yet. This is a key feature of the new Rules engine that is currently experimental in OH 2.

For the default Rules DSL your only options are:

  • scripts, though you can’t pass anything out get a return value (not positive about that jar part) to them so they are of limited use

  • lambdas, though they are limited to being called by rules in the same file.

  • separation of behaviors design pattern
    Design Pattern: Separation of Behaviors