[SOLVED] Astro Binding Offset no output with errors

Hardware: Intel Q9650 on Dell 0G261D motherboard
OS: Ubuntu 18.04.1 LTS
JRE: OpenJDK 1.8.0_192
OpenHAB 2.5.1-2

I’ve added some offset channels into an Astro thing:

Thing astro:sun:home [ geolocation="xx.xxx,-xx.xxx,xxx", interval=600 ] {
    Channels:
        Type rangeEvent : rise#event [
            offset=-40
            ]
        Type rangeEvent : set#event [
            offset=-30
            ]
}

The channels show in PaperIU but in the logs are the entries:

2020-02-17 18:43:39.668 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'astro.things'
2020-02-17 18:51:31.285 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'astro.things'
2020-02-17 18:51:31.319 [ERROR] [o.internal.handler.AstroThingHandler] - Can't update state for channel astro:sun:home:rise#event : org.openhab.binding.astro.internal.model.Range.getEvent()
java.lang.NoSuchMethodException: org.openhab.binding.astro.internal.model.Range.getEvent()
	at java.lang.Class.getMethod(Class.java:1786) ~[?:1.8.0_242]
	at org.openhab.binding.astro.internal.util.PropertyUtils.getPropertyValue(PropertyUtils.java:97) ~[?:?]
	at org.openhab.binding.astro.internal.util.PropertyUtils.getPropertyValue(PropertyUtils.java:100) ~[?:?]
	at org.openhab.binding.astro.internal.util.PropertyUtils.getPropertyValue(PropertyUtils.java:88) ~[?:?]
	at org.openhab.binding.astro.internal.util.PropertyUtils.getState(PropertyUtils.java:53) ~[?:?]
	at org.openhab.binding.astro.internal.handler.AstroThingHandler.publishChannelIfLinked(AstroThingHandler.java:155) ~[?:?]
	at org.openhab.binding.astro.internal.handler.AstroThingHandler.channelLinked(AstroThingHandler.java:228) ~[?:?]
	at org.eclipse.smarthome.core.thing.link.ThingLinkManager.lambda$0(ThingLinkManager.java:267) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_242]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_242]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_242]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_242]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_242]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_242]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]
2020-02-17 18:51:31.323 [ERROR] [o.internal.handler.AstroThingHandler] - Can't update state for channel astro:sun:home:set#event : org.openhab.binding.astro.internal.model.Range.getEvent()
java.lang.NoSuchMethodException: org.openhab.binding.astro.internal.model.Range.getEvent()
	at java.lang.Class.getMethod(Class.java:1786) ~[?:1.8.0_242]
	at org.openhab.binding.astro.internal.util.PropertyUtils.getPropertyValue(PropertyUtils.java:97) ~[?:?]
	at org.openhab.binding.astro.internal.util.PropertyUtils.getPropertyValue(PropertyUtils.java:100) ~[?:?]
	at org.openhab.binding.astro.internal.util.PropertyUtils.getPropertyValue(PropertyUtils.java:88) ~[?:?]
	at org.openhab.binding.astro.internal.util.PropertyUtils.getState(PropertyUtils.java:53) ~[?:?]
	at org.openhab.binding.astro.internal.handler.AstroThingHandler.publishChannelIfLinked(AstroThingHandler.java:155) ~[?:?]
	at org.openhab.binding.astro.internal.handler.AstroThingHandler.channelLinked(AstroThingHandler.java:228) ~[?:?]
	at org.eclipse.smarthome.core.thing.link.ThingLinkManager.lambda$0(ThingLinkManager.java:267) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_242]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_242]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_242]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_242]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_242]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_242]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]
2020-02-17 18:51:31.327 [INFO ] [enhab.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:sun:home
2020-02-17 18:51:31.337 [INFO ] [o.internal.handler.AstroThingHandler] - Scheduled Positional job astro:sun:home every 600 seconds
2020-02-17 18:51:31.358 [INFO ] [enhab.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:moon:home
2020-02-17 18:51:31.365 [INFO ] [enhab.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:sun:home
2020-02-17 18:51:31.367 [INFO ] [o.internal.handler.AstroThingHandler] - Scheduled Positional job astro:moon:home every 600 seconds
2020-02-17 18:51:31.391 [INFO ] [enhab.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:moon:home
2020-02-17 18:51:31.372 [INFO ] [o.internal.handler.AstroThingHandler] - Scheduled Positional job astro:sun:home every 600 seconds
2020-02-17 18:51:31.409 [INFO ] [o.internal.handler.AstroThingHandler] - Scheduled Positional job astro:moon:home every 600 seconds
2020-02-17 18:51:32.422 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'astro.things'

I’ve also created items off of the Range events in PaperUI and put them into the sitemap but I’m sure that’s not what’s contributing to the error…

You cannot successfully link Items to events. It would be nonsense; Items have states while events are moments in time.

1 Like

More clearly, I created them off of the Things:

DateTime         Sunrise_Time_Offset    "Sunrise Offset [%1$tH:%1$tM]"          { channel="astro:sun:home:rise#event" }
DateTime         Sunset_Time_Offset     "Sunset Offset [%1$tH:%1$tM]"           { channel="astro:sun:home:set#event" }

Those are event channels. They will not link to Items because they have no state. Items are not events.

Have another look at the Astro binding docs; channels are divided into two classes, the ordinary “stateful” channels can be linked to Items and supply states, like a time of day or an elevation. The event channels generate a transient event - “sunrise begins” etc.

Ok, that makes some sense. So I can use the channels directly in my rules for triggers and it should fire at the offset, correct?

Yep, use event channel directly for rule trigger. Examples in this forum. You’ll also find the events announce in your events.log

Good stuff, thanks @rossko57. It would be nice to display those offset channels in a site map, it would help my wife understand what’s going on. But as long as they work I’m a happy camper.

You can of course apply similar offsets to state channels and display the results in a sitemap.

Create the offset on the start or end channel and link that to an Item. I’m not sure which is the appropriate one though. I assume the event corresponds with the start.

Normally with advice like this I run off and find a good example in the community pages. But I can’t find an example of an offset on a channel or item as described. Could I ask for an example of how to do this? I can’t figure this one out.

I don’t use .things files nor do I recommend their use, so all I can provide is an example for doing so through PaperUI. But it should be *exactly# like you did for the #event, just replace #event with #start or #end depending on which time you want to offset.

In PaperUI

  • click the pencil icon next to the Channel you want to offset
  • enter the offset desired

image

If you don’t want to use the offset on each Channel, you can adjust the longitude. 15 degrees will move the events by one hour.

There are examples of both event offset and state offset in the binding docs. The hard part for many seems to grasping the difference between event/trigger channels and state channels.