Using Astro Action from jsr223 library

Tags: #<Tag:0x00007f616f7e39e8>

I have been using jsr223 since the very beginning, and especially the Astro Binding has been used. I am in progress with a major cleanup / rework of my library. I plan to share it as a jsr223 community script. My problem is that the Astro binding seems to cause problems recently. The sample on the jsr223 pages seems to fail (at least on my Windows box):

Shows an example of using the `core.actions` module to access an Action.
Requires the Astro action.

from core.actions import Astro
from core.log import logging, LOG_PREFIX
from java.util import Date

log = logging.getLogger("{}.action_example".format(LOG_PREFIX))"Sunrise: [{}]".format(Astro.getAstroSunsetStart(Date(2017, 7, 25), 38.897096, -77.036545).time))

What is the recommondations, should I rather go for the approach with a channel trigger rule? Or is it just me that are doing something wrong?

You have the prequisites installed?

  • Astro 1.x binding
  • Astro Action
  • Jyrhon Helper Libraries
1 Like

Do you see an error in the logs?

Could you link an Item to the Channel and use it’s value instead of the action?

A Channel trigger looks like it might work too.

You may also want to look into incorporating Time of Day into your rules.

1 Like

Only on the machine where it works :slight_smile: I was unsure if the Astro Binding from openHAB 2.x supports this approach. I guess it is not?

Yes, it says that Astro is not found. So my guess is that either namespace has changed, or this does only support Astro Actoion from openHAB 1?

I guess I will look into the channel triggering, as it seems a bit more robust in may case.

TMK, there are no actions in the 2.x Astro binding, so you will need to install the 1.x Astro Actions to get this working with the code in your example.

Another friendly nudge… take a look at using Time of Day. Here is an example using scripted automation (Jython) and the helper libraries, but I use it more as a Mode than a solar position reference. This example is used heavily in Area Triggers, which may also be helpful for you to look at.

1 Like

Thanks for the clearification :slight_smile:

I will take a look at your suggestions

1 Like

I have also updated the helper library documentation (yet to push) to clarify Binding or Action and version (e.g. Astro Action (v1), MQTT Binding (v2), etc.) to hopefully avoid the confusion in the future.

1 Like

Sorry, I didn’t get the Point. What do I have to Change? How can I change the version of Astro Action?

To use the Astro Action you must install and configure the Astro 1.x binding, the Astro Action, and use the example shown in the Helper Library docs:

Can you Elaborate, how I install the Astro 1.x action?
Within PaperUI I only see Astro under “Add-ons / Bindings” as binding-astro_2.5.0.
But I don’t see any action-astro.

Enable 1.x addons in addons.cfg or Paper UI…

Wow, sometimes it is just so easy.

Thanks a lot!!!

1 Like

To use the Astro Action you must install and configure the Astro 1.x binding, the Astro Action, and use …

So, now I have uninstalled binding-astro_2.5.0 and installed binding-astro1 - 1.14.0.
I can’t find a way for configuring Astro 1.x binding nor can I find Astro Action anywhere.

I don’t see it listed in PaperUI any more either. Perhaps it got removed. You can download it from and put it into the addons folder.

Ok, I’ve got the action-astro installed and a python script using from core.actions import Astro no longer throws errors.

But I can’t even configure binding-astro via PaperUI nor can I set up items or channels.
I’ve tried also to set up Astro in .things and .items file, but the created items do not show up in PaperUI.

Correct, it’s a 1.x binding. You can’t do anything with 1.x bindings from PaperUI. And 1.x version bindings don’t have Things. Read the documentation for the v1 Astro binding (link above) for how to configure it and configure the Items that use it.

now I’ve got it working. @5iver and @rlkoshak many thanks for your help and for being Patience with me :wink:

Does anyone know, if JSR223 will be officially part of OpenHAB in the future?
if yes, such obstacles should be sorted out before.

1 Like

It will become the default.

They will. V1 bindings will not be supported in OH 3. And your difficulties had nothing to do with using Python. They would have occurred just the same in Rules DSL

The details are still being worked through, but yes, the old rule engine will be swapped out with the new one. There are several things I hope to see cleaned up before then. BTW, when writing scripts, the terminology used is scripted automation, not JSR223. The installation of the languages will be through bundles, and the one for Jython is out in the wild…