Issue with Astro binding after upgrade to Openhab 2.4 on FreeBSD

Hi all,

I have a problem with the Astro binding after upgrading to OH 2.4. I have been using OH for quite some time now without major problems (at first on a Raspberry PI 3, now in a FreeBSD jail on my FreeNAS server). Since I moved the OH installation to a new jail, the Astro binding does not give correct sunrise and sunset times anymore.

I have prepared a small test case.
File AstroTest.things:

    astro:sun:ffm [ geolocation="50.108240, 8.664207", interval=300 ]

File AstroTest.items:

DateTime FFM_Sunrise_Time "Sonnenaufgang Frankfurt [%1$tH:%1$tM]" { channel = "astro:sun:ffm:rise#start" }
DateTime FFM_Sunset_Time "Sonnenuntergang Frankfurt [%1$tH:%1$tM]" { channel = "astro:sun:ffm:set#start" }

This should give the sunrise and sunset times for Frankfurt (which are 08:22h and 16:34h for today).
Doing a “smarthome:status” for the two items in the OH console I get:

openhab> smarthome:status FFM_Sunrise_Time                                                                                      
2019-01-03T06:31:00.000+0100
openhab> smarthome:status FFM_Sunset_Time                                                                                      
2019-01-03T18:31:00.000+0100

which is obviously wrong. Needless to say that sunrise and sunset times have been working without problems in OH 2.2 before.

Does anybody have an idea what is going on here?

Further information about my environment:

root@gumihome:/usr/local/etc/openhab2 # uname -v
FreeBSD 11.2-STABLE #0 r325575+fc3d65faae6(HEAD): Thu Dec 20 16:12:30 EST 2018     root@nemesis.tn.ixsystems.com:/freenas-releng-final/freenas/_BE/objs/freenas-releng-final/freenas/_BE/os/sys/FreeNAS.amd64
root@gumihome:/usr/local/etc/openhab2 # date
Thu Jan  3 12:28:39 CET 2019
root@gumihome:/usr/local/etc/openhab2 # pkg info | grep openhab
openhab2-2.4.0                 Vendor and technology agnostic open source smart-home software
openhab2-addons-2.4.0          Addons for openhab2
root@gumihome:/usr/local/etc/openhab2 # pkg info | grep jdk
openjdk8-8.192.26_1            Java Development Kit 8
openhab> feature:list | grep astro
esh-binding-astro                           ? 0.10.0.oh240     ?          ? Started     ? openhab-addons-2.4.0    ?
openhab-binding-astro                       ? 2.4.0            ? x        ? Started     ? openhab-addons-2.4.0    ? Astro Binding
openhab> things show astro:sun:ffm
UID: astro:sun:ffm
Type: astro:sun
Label: Astronomische Sonnendaten
Status: ONLINE

No properties

Configuration parameters:
	interval : 300
	geolocation : 50.108240, 8.664207

Channels: ...

I would be glad if someone could help here, as I have been struggling with this for days (and even did a complete re-install of OH).

Best wishes,
Thomas.

Exactly the same setup as yours works for me:
image

The times are 1 hour difference because I am in the UK

Thanks for this information - that’s definitely good for you … :wink:

I am just wondering what you mean by “exactly the same setup”: Do you mean the same things and items configuration only or do you also have the same environment (FreeBSD 11.2, Openhab 2.4, etc.)?

This

I run Ubuntu server 18.04 / Openhab SNAPSHOT

That’s actually good for you too.
Now you know that it should work …

Well, I knew it should work - as it had already worked before.

Meanwhile, I have at least found the root cause of the problem: It seems that the Math.asin() method in the installed openjdk8 java implementation is broken. I wrote a short test programme:

public class CheckMathIssue {
	public static void main(String[] args) {
		System.out.println("Operating System: " + System.getProperty("os.name") 
			+ " " + System.getProperty("os.arch")
			+ " " + System.getProperty("os.version"));

		System.out.println("Java: " + System.getProperty("java.version") 
			+ " " + System.getProperty("java.vendor"));

		System.out.println("Java Specification: " + System.getProperty("java.specification.name") 
			+ " " + System.getProperty("java.specification.vendor")
			+ " " + System.getProperty("java.specification.version"));

		System.out.println("Java VM: " + System.getProperty("java.vm.version") 
			+ " " + System.getProperty("java.vm.vendor"));

		System.out.println("Java VM Specification: " + System.getProperty("java.vm.specification.name") 
			+ " " + System.getProperty("java.vm.specification.vendor")
			+ " " + System.getProperty("java.vm.specification.version"));

		double value1 = Math.asin(0.5);
		double value2 = Math.asin(-0.38147821481517075);
		double value3 = StrictMath.asin(0.5);
		double value4 = StrictMath.asin(-0.38147821481517075);
		System.out.println("asin(0.5)= " + value1);
		System.out.println("asin(-0.38147821481517075)= " + value2);
		System.out.println("StrictMath asin(0.5)= " + value3);
		System.out.println("StrictMath asin(-0.38147821481517075)= " + value4);
	}
}

and ran that on different platforms. The concatenated results look like this:

Operating System: FreeBSD amd64 11.2-STABLE
Java: 1.8.0_192 Oracle Corporation
Java Specification: Java Platform API Specification Oracle Corporation 1.8
Java VM: 25.192-b26 Oracle Corporation
Java VM Specification: Java Virtual Machine Specification Oracle Corporation 1.8
asin(0.5)= 0.5
asin(-0.38147821481517075)= -0.38147821481517075
StrictMath asin(0.5)= 0.5
StrictMath asin(-0.38147821481517075)= -0.38147821481517075

Operating System: FreeBSD amd64 11.2-STABLE
Java: 1.8.0_172 Oracle Corporation
Java Specification: Java Platform API Specification Oracle Corporation 1.8
Java VM: 25.172-b11 Oracle Corporation
Java VM Specification: Java Virtual Machine Specification Oracle Corporation 1.8
asin(0.5)= 0.5235987755982989
asin(-0.38147821481517075)= -0.391394915510742
StrictMath asin(0.5)= 0.5235987755982989
StrictMath asin(-0.38147821481517075)= -0.391394915510742

Operating System: Mac OS X x86_64 10.14.2
Java: 1.8.0_192 Oracle Corporation
Java Specification: Java Platform API Specification Oracle Corporation 1.8
Java VM: 25.192-b12 Oracle Corporation
Java VM Specification: Java Virtual Machine Specification Oracle Corporation 1.8
asin(0.5)= 0.5235987755982989
asin(-0.38147821481517075)= -0.391394915510742
StrictMath asin(0.5)= 0.5235987755982989
StrictMath asin(-0.38147821481517075)= -0.391394915510742

Operating System: Linux arm 4.14.78-2-osmc
Java: 1.8.0_191 Oracle Corporation
Java Specification: Java Platform API Specification Oracle Corporation 1.8
Java VM: 25.191-b12 Oracle Corporation
Java VM Specification: Java Virtual Machine Specification Oracle Corporation 1.8
asin(0.5)= 0.5235987755982989
asin(-0.38147821481517075)= -0.391394915510742
StrictMath asin(0.5)= 0.5235987755982989
StrictMath asin(-0.38147821481517075)= -0.391394915510742

The first result comes from my OpenHAB jail and is wrong. The other three are correct and come from different platforms: FreeBSD with an older JDK (openjdk8-172), MacOS 10.14 and Linux on a Raspberry PI.

2 Likes

Just if anybody wants to know: It was indeed a bug in the FreeBSD port of OpenJDK 8 and it turned out that the build setup for V8.192 was wrong (used Big Endian byte order instead of Little Endian for x86 cpus …).

This is now fixed with revision 492485 of the ports collection.

1 Like