Post by papa on Mar 8, 2017 21:31:06 GMT
When I installed OpenHAB 2 on an old Linux laptop, I made necessary changes in OH 1 files (items, rules, etc) for OH 2 & made considerable additions. Then the old Linux laptop running OH 2 started acting flaky so I saved the OH 2 config files while I could. So I ported the OH 2 config files to a Raspberry PI running OH 1 & needed to convert the configs that direction.
My experience migrating from OH 2 to OH 1 might be useful to those still using OH 1 who see some OH 2 programming they'd like to use.
Generally speaking, you could apply in reverse the OH 1 to OH 2 Tutorial, especially the Necessary Changes section.
OH 2 .cfg file entries
OH 2 puts addons configs into separate files (like mqtt.cfg) with the addons' names on them.
For OH 1, generally put an [addon].cfg settings into the addons section in openhab.cfg
For example, put OH 2 mqtt.cfg entries into the # MQTT Transport # section of OH 1's openhab.cfg
.items changes
items using the astro & ntp bindings use "things" in OH 2 & don't use them with OH 1. For OH1, follow the syntax in the OpenHAB 1 astro binding wiki.
.scale transforms in OH 2 use [minbound..maxbound] For OH 1 change to [minbound,maxbound]
So a line in a OH 2 .scale file might read [0,150]=very dry. For OH 1 change it to [0..150]=very dry
.rules changes
OH 2 rule files require much fewer imports. To use a .rules file written for OH 2, you may need to add or activate key imports, like ...
import org.openhab.core.library.types.*
Caution: If you use more than one .rules file, be sure EACH rule file has the imports its rules need. (Again needing fewer imports, an OH 2 rules file might omit some needed for OH 1)
Where OH 2 uses if(MyItem.state == NULL) OH 1 uses (MyItem.state == Undefined)
My experience migrating from OH 2 to OH 1 might be useful to those still using OH 1 who see some OH 2 programming they'd like to use.
Generally speaking, you could apply in reverse the OH 1 to OH 2 Tutorial, especially the Necessary Changes section.
OH 2 .cfg file entries
OH 2 puts addons configs into separate files (like mqtt.cfg) with the addons' names on them.
For OH 1, generally put an [addon].cfg settings into the addons section in openhab.cfg
For example, put OH 2 mqtt.cfg entries into the # MQTT Transport # section of OH 1's openhab.cfg
.items changes
items using the astro & ntp bindings use "things" in OH 2 & don't use them with OH 1. For OH1, follow the syntax in the OpenHAB 1 astro binding wiki.
.scale transforms in OH 2 use [minbound..maxbound] For OH 1 change to [minbound,maxbound]
So a line in a OH 2 .scale file might read [0,150]=very dry. For OH 1 change it to [0..150]=very dry
.rules changes
OH 2 rule files require much fewer imports. To use a .rules file written for OH 2, you may need to add or activate key imports, like ...
import org.openhab.core.library.types.*
Caution: If you use more than one .rules file, be sure EACH rule file has the imports its rules need. (Again needing fewer imports, an OH 2 rules file might omit some needed for OH 1)
Where OH 2 uses if(MyItem.state == NULL) OH 1 uses (MyItem.state == Undefined)