Prerequisites
- OpenHAB 3
- The JRuby Scripting Language Addon
- This scripting library
Installation
Configure the openHAB JRuby Automation to install the openhab-scripting
Ruby gem and automatically insert the require
statement at the beginning of your scripts (optional).
From the user interface
- Go to
Settings -> Add-ons -> Automation
and install the jrubyscripting automation addon following the openHAB instructions - Go to
Settings -> Other Services -> JRuby Scripting
:- Ruby Gems:
openhab-scripting=~>4.0
- Require Scripts:
openhab
(openHAB 3.3+: recommended if you are using GUI scripting)
- Ruby Gems:
Using files
Configure JRuby OpenHAB services
Create a file called
jruby.cfg
in<OPENHAB_CONF>/services/
with the following content:org.openhab.automation.jrubyscripting:gems=openhab-scripting=~>4.0 # optional: uncomment the following line if you prefer not having to # insert require 'openhab' at the top of your scripts. # org.openhab.automation.jrubyscripting:require=openhab
This configuration with the openhab-scripting gem specified with pessimistic versioning will install any version of openhab-scripting greater than or equal to 4.0 but less than 5.0. On system restart if any (non-breaking) new versions of the library are available they will automatically be installed.
Edit
<OPENHAB_CONF>/services/addons.cfg
and ensure thatjrubyscripting
is included in an uncommentedautomation=
list of automations to install.
Upgrading
Depending on the versioning selected in the jruby.cfg
or the gems list in the user interface, file upgrading will either be automatic after a OpenHAB restart or manual. For manual upgrades select the version of the gem exactly, for example: org.openhab.automation.jrubyscripting:gems=openhab-scripting=4.0.0
Will install and stay at version 4.0.0, to upgrade to version 4.0.1, change the configuration: org.openhab.automation.jrubyscripting:gems=openhab-scripting=4.0.1
To automatically upgrade, it is recommended to use pessimistic versioning: org.openhab.automation.jrubyscripting:gems=openhab-scripting=~>4.0
This will install at least version 4.0 and on every restart will automatically install any version that is less than 5.0. This ensures that fixes and new features are available without introducing any breaking changes.