Astro Binding - Offset ignored by thing action

Hi,

OH3.3
For sun_set I have defined an offset of 30 min (within the trigger channel, but also in the start & end datetime channel).
Thats working fine, as per the logs I can see that the trigger is at the correct time / similar to the corresponding item:

2022-10-26 18:46:00.002 [INFO ] [openhab.event.ChannelTriggeredEvent ] - astro:sun:local:set#event triggered START
2022-10-26 18:50:00.003 [INFO ] [openhab.event.ChannelTriggeredEvent ] - astro:sun:local:set#event triggered END

However, if I want to get sun_set start / end time via thing action, the offset is ignored.
As I have this for some rules as a condition (only run before / after sun_set), these rules are not running correctly.

Thats the output of the thing action:

2022-10-26 19:53:03.505 [INFO ] [org.openhab.rule.557a41d053         ] - SUN_SET START will happen at: 2022-10-26T18:16+02:00[Europe/Berlin]
2022-10-26 19:53:03.524 [INFO ] [org.openhab.rule.557a41d053         ] - SUN_SET END will happen at: 2022-10-26T18:20+02:00[Europe/Berlin]
Code
var things = Java.type('org.openhab.core.model.script.actions.Things');
var zdt = Java.type('java.time.ZonedDateTime'); 
var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);

var sunEvent = "SUN_SET";
 var sunActions = things.getActions('astro', 'astro:sun:local');
 var today = zdt.now();
 var sunEventTime = sunActions.getEventTime(sunEvent,today,"START");
 
logger.info("{} START will happen at: {}", sunEvent, sunEventTime.toString());
sunEventTime = sunActions.getEventTime(sunEvent,today,"END");
logger.info("{} END will happen at: {}", sunEvent, sunEventTime.toString());

Question:
Is this expected behavior, that the offset of the channel is ignored when using the thing action?
Do I miss something?

Thanks in advance for any feedback

Not sure; but do note that many channels like Sunset effectively incorporate three elements.
Start and Stop datetimes (which can be linked to an Item, these might be in the future or past for today)
Trigger (which is a transient event with START and END payloads)

Relevant here is that any offsets for the two Start/Stop elements are set separately and independently of the Trigger rangeEvent offset.

I think we’ll need to know precisely what you have done, preferably by showing us the code version of your channel configs.

I would say it is doing what you asked.
Your workaround would be to link the datetime channels to Items, where the offset will be applied (and may or may not be anything like the event offset), and use the Item in your condition.

Thabks for your print feedback.

As mentioned I have set the same offset to all three elements…

I wanted to do it, but the channel configuration of the item is not part of the code, if you configure the channel via UI

Sure; but have you done it correctly? We cannot comment.

Items do not have channel configurations, channels do.

Have a look at the parent Thing.

That’s why I have shared

  • one log record showing the sunset without offset (based on the thing action where my question is about)
  • one log record showing the sunset event being triggered 30 min later (=offset is working as expected)
  • one screenshot of the item linked to the datetime channel (also including the offset)

Sorry, that was a typo. I wanted to say, that the code view of the thing is not including the individual channel configurations, but it’s only showing what’s configured on the “thing” tab.

That’s what I get via developer tools / rest API (removed the non-relevant channels). You can see that an offset is configured, but as per the initial post the thing-action returns the sunset start / end date without offset:

{
  "channels": [
    {
      "linkedItems": [
        "Draussen_Wetter_Set_Start"
      ],
      "uid": "astro:sun:local:set#start",
      "id": "set#start",
      "channelTypeUID": "astro:start",
      "itemType": "DateTime",
      "kind": "STATE",
      "label": "Startzeit",
      "description": "Die Startzeit des Ereignisses",
      "defaultTags": [],
      "properties": {},
      "configuration": {
        "offset": 30,
        "earliest": "00:00",
        "latest": "00:00"
      }
    },
    {
      "linkedItems": [],
      "uid": "astro:sun:local:set#end",
      "id": "set#end",
      "channelTypeUID": "astro:end",
      "itemType": "DateTime",
      "kind": "STATE",
      "label": "Endzeit",
      "description": "Die Endzeit des Ereignisses",
      "defaultTags": [],
      "properties": {},
      "configuration": {
        "offset": 30,
        "earliest": "00:00",
        "latest": "00:00"
      }
    },
    {
      "linkedItems": [],
      "uid": "astro:sun:local:set#duration",
      "id": "set#duration",
      "channelTypeUID": "astro:duration",
      "itemType": "Number:Time",
      "kind": "STATE",
      "label": "Dauer",
      "description": "Die Dauer des Ereignisses",
      "defaultTags": [],
      "properties": {},
      "configuration": {}
    },
    {
      "linkedItems": [],
      "uid": "astro:sun:local:set#event",
      "id": "set#event",
      "channelTypeUID": "astro:rangeEvent",
      "kind": "TRIGGER",
      "label": "Range Event",
      "description": "Range event",
      "defaultTags": [],
      "properties": {},
      "configuration": {
        "offset": 30,
        "earliest": "00:00",
        "latest": "00:00"
      }
    }
  ],
  "statusInfo": {
    "status": "ONLINE",
    "statusDetail": "NONE"
  },
  "editable": true,
  "label": "Astro Lokale Sonnendaten",
  "configuration": {
    "useMeteorologicalSeason": false,
    "interval": 300,
    "geolocation": "XXX"
  },
  "properties": {},
  "UID": "astro:sun:local",
  "thingTypeUID": "astro:sun"
}

Alright, those offsets look good. Which brings us back to

but intended or not, it’s what you get today. By all means seek clarification, I would think best done by creating a Github issue on the binding.

Meantime

Another workaround:
Use two rules to toggle a Switch Item, The rules are triggered by

Channel 'astro:sun:local:set#event' triggered START

and

Channel 'astro:sun:local:rise#event' triggered START

Now you can check whether the Item is set to ON or OFF.
It’s up to you, how the item is used… An item IsNight would be switched to ON at sunset, IsDay would be switched ON at sunrise…

But keep in mind that this item will only be switched through the rule, so there has to be one of the events to take place, before the item status is correct.

Thanks both @rossko57 and @Udo_Hartmann for your feedback.
For me most importantly it seems that nothing is going wrong on my installation, but this behavior is more as designed. If it makes sense or not, is maybe a different question.

As I already have a datetime item linked to the channel I will use this item to check if current time is before or after sunset, therefore not a big deal to find a workaround.