Astro binding and timezones?

559 views
Skip to first unread message

peter...@gmail.com

unread,
May 6, 2014, 10:17:51 AM5/6/14
to ope...@googlegroups.com
I've been testing the Astro binding to give me sunrise and sunset times. It's giving me some weird results that look to me like they're timezone related.

I'm in Sydney Australia, UTC+10. I run OpenHAB on a Linux server that has its timezone set to Australia/Sydney and is synced via NTP. I've configured the Astro binding with my correct latitude and longitude, and added the example items on the wiki page.

At midnight last night Astro updated and logged the following in the event.log:

2014-05-06 00:00:00 - Sunrise_Time state updated to 2014-05-05T21:34:00
2014-05-06 00:00:00 - Noon_Time state updated to 2014-05-06T02:51:00
2014-05-06 00:00:00 - Sunset_Time state updated to 2014-05-06T08:10:00

Checking against timeanddate.com shows that in Sydney sunrise today was at 6:34 and sunset at 17:10 - Astro is giving me times 9 hours behind, or UTC+1. Unfortunately, OpenHAB then treats these as local time, so I got the SUNSET switch firing at 8:10 this morning, and the SUNRISE one never fires at all, because when the sun actually comes up Sunrise_Time is set to yesterday evening.

Any suggestions for what could be going wrong? As a workaround, is it possible to create a rule to add ten hours to a DateTime event?

Thanks,
-- 
Pete

Ben Jones

unread,
May 6, 2014, 3:44:32 PM5/6/14
to ope...@googlegroups.com, peter...@gmail.com
Not sure about your Astro binding sorry Pete, but it is very easy to add a period to a DateTime variable. 

    var DateTime in10HoursTime = now.plusHours(10)

openHAB uses the Joda time libraries, so check out http://www.joda.org/joda-time/ for more details.

kas...@gmail.com

unread,
May 13, 2014, 5:45:07 PM5/13/14
to ope...@googlegroups.com, peter...@gmail.com
You can change the timezone for JVM using the following command line option: -Duser.timezone="Europe/Budapest"
The ASTRO binding is working properly only if Java has the proper timezone information.

gerrieg

unread,
May 14, 2014, 8:40:48 AM5/14/14
to ope...@googlegroups.com, peter...@gmail.com
Hi Pete!

I am the developer of the Astro binding and saw your post today. I looked at the code and found a bug in the timezone offset calculation. So i want to ask you if you can check the attached build if it works now and give me some feedback.

Thanks!

BR,
Gerhard
org.openhab.binding.astro-1.5.0-SNAPSHOT.jar

peter...@gmail.com

unread,
May 14, 2014, 9:07:44 AM5/14/14
to ope...@googlegroups.com, peter...@gmail.com
Hi Gerhard.

I was planning on finding some time soon to take a look at the binding source myself, but I'm glad you saw my message first. :-)

I shut down openhab on my server, copied your updated binding in, moved the server time forward to 23:55 so astro's scheduled task would kick in, and started openhab back up. And now it's posting times in my local timezone:

2014-05-15 00:00:00 - Sunrise_Time state updated to 2014-05-15T06:40:00
2014-05-15 00:00:00 - Noon_Time state updated to 2014-05-15T11:51:00
2014-05-15 00:00:00 - Sunset_Time state updated to 2014-05-15T17:02:00

Much better! Thanks for your work.
-- 
Pete

Bernd Pfrommer

unread,
Jul 14, 2014, 5:24:56 PM7/14/14
to ope...@googlegroups.com, peter...@gmail.com
Gerhard,

Has this fix made it into the main line of code? I seem to have astro binding timezone issues with the latest version 1.6.0, directly pulled from the main repository.

Bernd

Bernd Pfrommer

unread,
Jul 14, 2014, 5:39:52 PM7/14/14
to ope...@googlegroups.com, peter...@gmail.com
Found the root of my "timezone" problems: had the sign wrong for the longitude: need a negative sign for the Western hemisphere.
Still would like to know if the above mentioned fix is in the main line repository.

Thanks!

Thomas E.-E.

unread,
Jul 14, 2014, 6:46:54 PM7/14/14
to ope...@googlegroups.com, peter...@gmail.com
Hi Bernd,

there is no pending PR regarding the Astro binding so far.

Best, Thomas E.-E.

Gerhard R.

unread,
Jul 15, 2014, 2:03:19 AM7/15/14
to ope...@googlegroups.com, peter...@gmail.com
Hi Bernd!

Yes, the fix is included in 1.5.0.

Regards,
Gerhard

Reply all
Reply to author
Forward
0 new messages