Astro binding throwing exceptions for moon since 00:00 this morning

Tags: #<Tag:0x00007fc8ef2b5d80>

Astro binding has been working fine for me, but since midnight last night (this morning?) I’ve been getting java exceptions in openhab.log every 5 minutes.

Presumably, since this only started at midnight, some variable or other is overflowing and causing an error condition.

I’m running the 2.4.0 snapshot build #1308

Here’s a typical log entry:
> 2018-07-13 11:14:16.840 [ERROR] [ding.astro.handler.AstroThingHandler] - Can’t update state for channel astro:moon:local:phase#ageDegree : null
> java.lang.NumberFormatException: null
> at java.math.BigDecimal.(BigDecimal.java:494) [?:?]
> at java.math.BigDecimal.(BigDecimal.java:383) [?:?]
> at java.math.BigDecimal.(BigDecimal.java:806) [?:?]
> at org.eclipse.smarthome.binding.astro.internal.util.PropertyUtils.getState(PropertyUtils.java:62) [205:org.eclipse.smarthome.binding.astro:0.10.0.201806271317]
> at org.eclipse.smarthome.binding.astro.handler.AstroThingHandler.publishChannelIfLinked(AstroThingHandler.java:156) [205:org.eclipse.smarthome.binding.astro:0.10.0.201806271317]
> at org.eclipse.smarthome.binding.astro.handler.AstroThingHandler.publishPlanet(AstroThingHandler.java:139) [205:org.eclipse.smarthome.binding.astro:0.10.0.201806271317]
> at org.eclipse.smarthome.binding.astro.handler.MoonHandler.publishPositionalInfo(MoonHandler.java:60) [205:org.eclipse.smarthome.binding.astro:0.10.0.201806271317]
> at org.eclipse.smarthome.binding.astro.internal.job.PositionalJob.run(PositionalJob.java:45) [205:org.eclipse.smarthome.binding.astro:0.10.0.201806271317]
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
> at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]
> at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]
> at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
> at java.lang.Thread.run(Thread.java:748) [?:?]

Have you tried clearing the cache?

I hadn’t … just tried that and the problem is still occurring. Note that I hadn’t done any updates for days - the problem only started at midnight.

Depending where your midnight is, that may have coincided with new moon. So there might be an issue with moon phase computations. The first error line agrees with that suspicion: “Can’t update state for channel astro:moon:local:phase#ageDegree : null”.

So the question is not whether you have updated in the last few days only, but if you updated any time after last new moon before yesterday.

2018-07-13 11:14:16.840 [ERROR] [ding.astro.handler.AstroThingHandler] - Can’t update state for channel astro:moon:local:phase#ageDegree : null

This really should not be logged as an error. It’s a thoroughly expected condition. It should be an INFO at most.

Interesting. Why is a null expected. Zero of course, but null?

Null in Java is frequently used to indicate no valid response. Some APIs are designed to never return null, but most that I see aren’t.

Which means most code needs to be prepared to handle null as a returned value.

I see.

I still would say the correct response for new moon should be a value of zero, because in an astronomical sense a valid value always exists for this property.

Or the problem is not the new new moon at all, which is also possible, of course, but something else preventing a valid numerical response.

I’m getting the exact same error now all of a sudden, since midnight. I haven’t done any updates.

I see the problem is reported here too: https://github.com/eclipse/smarthome/issues/6808

Would it be best to report the issue to the binding maintainer? Or is there an alternative to fix for it from an OpenHAB 2.4 point of view (work around)?

Hi @chubber,

There is an additional issue (https://github.com/eclipse/smarthome/issues/6693) which sounds very similar. Did you see that too? The issue could be related to a wrong item configuration.

If it does not fit, it would be appreciated if you can open an issue in the openHAB 2 Add-ons issue tracker for it.

1 Like

I will set-up a test scenario in my environment. And try to reproduce it. Unfortunately we have to wait a little bit next new moon will be in four weeks.

I see the same error every month. It is appearing in the log every minute for the whole day. Instead of 0 (or no value), it throws null exception. Here is one example:

java.lang.reflect.InvocationTargetException: null
at sun.reflect.GeneratedMethodAccessor1634.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.eclipse.smarthome.binding.astro.internal.util.PropertyUtils.getPropertyValue(PropertyUtils.java:98) ~[211:org.eclipse.smarthome.binding.astro:0.10.0.oh240]
at org.eclipse.smarthome.binding.astro.internal.util.PropertyUtils.getPropertyValue(PropertyUtils.java:100) ~[211:org.eclipse.smarthome.binding.astro:0.10.0.oh240]
at org.eclipse.smarthome.binding.astro.internal.util.PropertyUtils.getPropertyValue(PropertyUtils.java:88) ~[211:org.eclipse.smarthome.binding.astro:0.10.0.oh240]
at org.eclipse.smarthome.binding.astro.internal.util.PropertyUtils.getState(PropertyUtils.java:53) ~[211:org.eclipse.smarthome.binding.astro:0.10.0.oh240]
at org.eclipse.smarthome.binding.astro.handler.AstroThingHandler.publishChannelIfLinked(AstroThingHandler.java:156) [211:org.eclipse.smarthome.binding.astro:0.10.0.oh240]
at org.eclipse.smarthome.binding.astro.handler.AstroThingHandler.publishPlanet(AstroThingHandler.java:139) [211:org.eclipse.smarthome.binding.astro:0.10.0.oh240]
at org.eclipse.smarthome.binding.astro.handler.MoonHandler.publishPositionalInfo(MoonHandler.java:60) [211:org.eclipse.smarthome.binding.astro:0.10.0.oh240]
at org.eclipse.smarthome.binding.astro.internal.job.PositionalJob.run(PositionalJob.java:45) [211:org.eclipse.smarthome.binding.astro:0.10.0.oh240]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.lang.NumberFormatException
at java.math.BigDecimal.(BigDecimal.java:494) ~[?:?]
at java.math.BigDecimal.(BigDecimal.java:383) ~[?:?]
at java.math.BigDecimal.(BigDecimal.java:806) ~[?:?]
at org.eclipse.smarthome.core.library.types.QuantityType.(QuantityType.java:109) ~[?:?]
at org.eclipse.smarthome.binding.astro.internal.model.MoonPhase.getAgePercent(MoonPhase.java:161) ~[?:?]
… 18 more

I’m using the latest version of Openhab. You can try to simulate the issue by changing system date to 3rd June 2019 temporarily to see the issue in action instead of waiting several weeks.

Great idea. Thanks for the hint. It was possible for me to reproduce the exception immediately. Now I have a very good setup for testing. I will prepare a fix for it.

I submitted a fix. Thanks everyone for helping.