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))
log.info("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?
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.
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.
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.
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.
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.
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…