I’ve migrated from OH1 to OH2 using the text configuration approach. As far as I understand from other posts on this forum there are no actions in OH2, but you can use existing Actions from OH1 bindings. This however does not work for me using an action from the Astrology 1.x binding:
I’m using this code in my rules file (I’ve also included imports):
rule "SystemStarted - Calculate some values"
Item SystemStarted received command ON
logInfo("SystemStarted", "Calculating astrology values")
var Date current = now.toDate
var DateTime currentDate = now.toDateTime
var double lat = 52.0
var double lon = 6.0
var DateTimeType sunrise = new DateTimeType(getAstroSunriseStart(current, lat, lon))
Rule 'SystemStarted - Calculate some values': An error occured during the script execution: The name 'getAstroSunriseStart(<XFeatureCallImplCustom>,<XFeatureCallImplCustom>,<XFeatureCallImplCustom>)' cannot be resolved to an item or type.
Any idea on how to call Actions from the astro1 binding? The 1.x binding documentation has some clear examples (https://github.com/openhab/openhab/wiki/Actions#astro-actions), but the migration docs (http://docs.openhab.org/tutorials/migration) say nothing specific, other then to add the action to your addons.cfg, which looks like this:
# A comma-separated list of actions to install (e.g. "mail,pushover") action = nma,mail,astro1,mqtt,xbmc
and of course to change the imports, which I’ve done.
I don’t think the Astro actions will work under OH2 unless you do a number of things.
- First, there is no
openhab-action-astro1. If it existed at all (which it doesn’t seem to), it would be
openhab-action-astro. So remove
astro1 from your
action = line in
- The 1.x Astro action bundle depends on the 1.x Astro binding bundle. You can get the JARs for both of them from here and dump them into your
addons directory. Or just the action bundle and install the legacy 1.x Astro binding via the normal path.
- You will need to create an astro.cfg file in your
conf/services directory as documented here for openhab.cfg, but without the
astro: prefixes. I think just
longitude are needed.
- I haven’t tested this, there might be problems, and it’s not currently expected to be supported.
- I wish there were an Astrology binding, bit sadly it’s only an Astronomy binding.
Thank you for your response.
This is what I’ve done:
- I’ve removed astro1 from my
action = row in
- I’ve also removed astro1 from my
binding = row in
addons.cfg, as it claims it was already installed (
org.apache.felix.fileinstall ] - A bundle with the same symbolic name (org.openhab.binding.astro) and version (220.127.116.11701030211) is already installed. Updating this bundle instead.)
- I already had a proper astro.cg in
Now it works . The strange part is that other actions (
nma, mail, mqtt, xbmc) work when they are added to
action = row in
services/addons.cfg, but for the astro action it requires me to add the binding and action jar’s manually. Thank you for your help!
Careful if you have an
action = or
binding = line, as that means that only those actions or bindings will be installed. I know that the action JAR had to be added manually since no feature is currently defined for it, but I think you had two instances of the binding installed somehow, and however it gets installed (once) should be OK. The action JAR has code dependencies on the binding JAR, so that’s why it needs to be installed as well as the action JAR.
I will see if I can add a feature for the Astro action to the legacy features.