Astro binding to move switches at sunset/sunrise

I can’t remember any issues where the trigger did not trigger at all like in @Dries case . There have been several issues with the astro binding lately, to find out which one made it into a snapshot you may look at:

https://hudson.eclipse.org/smarthome/job/SmartHomeDistribution-Stable/changes

and

Thanks. Will try to do that this weekend. But I’m not sure which conclusions I could draw from that. Suppose that would work, what does it learn me?

[EDIT]
Ok, I decided to give it one more try. In the issue I reported on GitHUB, @triller-telekom provided a new Astro-jar.
This is what I did:

  • I delete the things “local sun” and “local moon”;
  • I removed the Astro binding installed via PaperUI;
  • I stopped OpenHAB;
  • I deleted the contents of /cache and /tmp;
  • I upgraded to the latest build (#1028);
  • I started OpenHAB;
  • I added the jar-file to the addons-file;
  • Two things where found in PaperUI - I added them. Latitude/longitude were prefilled nicely.
  • In openHAB.log I see:
2017-08-31 12:37:58.883 [INFO ] [thome.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:moon:local
2017-08-31 12:37:58.893 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled Positional job astro:moon:local every 300 seconds
2017-08-31 12:37:59.106 [INFO ] [thome.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:moon:local
2017-08-31 12:37:59.114 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled Positional job astro:moon:local every 300 seconds
2017-08-31 12:38:02.297 [INFO ] [thome.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:sun:local
2017-08-31 12:38:02.315 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled Positional job astro:sun:local every 300 seconds
2017-08-31 12:38:03.263 [INFO ] [thome.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:sun:local
2017-08-31 12:38:03.283 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled Positional job astro:sun:local every 300 seconds

Now fingers crossed! I hope it makes a difference.

This way you may find out if your openHAB instance is the problem or your setup regarding the astro binding.

Steps could be:

  • new clean openHAB install
  • only astro binding installed
  • check the channel triggers, if okay: add your items and rules
  • check the triggers, if okay: look for problems in your original openHAB install. If rules do not trigger: look for problems in your astro items and rules.

Ok, clear.
However… the sun has just set 10 minutes ago where I live. And this is what I’ve got:

2017-08-31 20:25:00.178 [INFO ] [eclipse.smarthome.model.script.Astro] - De zon gaat onder, slaapwel.

Meaning the rule got triggered using the Astro Jar mentioned on Github.

Finally! :fireworks:

Thanks for your help!

1 Like

Very odd this I noticed.

In build #1030, the issue should be solved (according to @Kai).

So I removed the Astro Jar mentioned on Github, upgraded to #1031 and installed the Astro binding via PaperUI. Unfortunately… my problem returned (sunrise/set not triggered)…

With the standard, PaperUI binding, I get this in openhab.log:

2017-09-03 13:35:46.997 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro job-daily-sun at midnight for thing astro:sun:local
2017-09-03 13:35:47.239 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro job-daily-moon at midnight for thing astro:moon:local
2017-09-03 13:35:47.907 [INFO ] [thome.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:moon:local
2017-09-03 13:35:48.360 [INFO ] [thome.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:sun:local

In the Karaf console, I see:

openhab> bundle:list|grep -i astro
177 | Active   |  80 | 0.9.0.201706170545     | Astro Binding
openhab> feature:list|grep -i astro
esh-binding-astro                           | 0.9.0.SNAPSHOT   |          | Started     | addons-2.2.0-SNAPSHOT   |
openhab-binding-astro                       | 2.2.0.SNAPSHOT   | x        | Started     | addons-2.2.0-SNAPSHOT   | Astro Binding

When I uninstall Astro via PaperUI and put back the Astro JAR in the Addons-folder:

I get this in openhab.log:

2017-09-04 12:52:54.030 [INFO ] [thome.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:sun:local
2017-09-04 12:52:54.070 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled Positional job astro:sun:local every 300 seconds
2017-09-04 12:52:54.372 [INFO ] [thome.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:moon:local
2017-09-04 12:52:54.374 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled Positional job astro:moon:local every 300 seconds
2017-09-04 12:52:54.902 [INFO ] [thome.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:sun:local
2017-09-04 12:52:54.919 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled Positional job astro:sun:local every 300 seconds
2017-09-04 12:52:55.550 [INFO ] [thome.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:sun:local
2017-09-04 12:52:55.559 [INFO ] [thome.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:moon:local
2017-09-04 12:52:55.566 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled Positional job astro:sun:local every 300 seconds
2017-09-04 12:52:55.576 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled Positional job astro:moon:local every 300 seconds
2017-09-04 12:52:55.831 [INFO ] [thome.binding.astro.internal.job.Job] - Scheduled Astro event-jobs for thing astro:moon:local
2017-09-04 12:52:55.845 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled Positional job astro:moon:local every 300 seconds

So the 300-seconds thing is different.

In Karaf console:

openhab> bundle:list|grep -i astro
210 | Active   |  80 | 0.9.0.201708310751     | Astro Binding
openhab> feature:list|grep -i astro
esh-binding-astro                           | 0.9.0.SNAPSHOT   |          | Uninstalled | addons-2.2.0-SNAPSHOT   |
openhab-binding-astro                       | 2.2.0.SNAPSHOT   |          | Uninstalled | addons-2.2.0-SNAPSHOT   | Astro Binding

So I guess that means that the fix is not in the latest release. Correct?

Nope, see here:
https://hudson.eclipse.org/smarthome/job/SmartHomeDistribution-Stable/changes

With the #1031 build the triggers are - still - working fine.

It seems that your installation is still messed up somehow. This is what I get when I do

openhab> bundle:list|grep -i astro
186 │ Active   │  80 │ 0.9.0.201709011622     │ Astro Binding

Nothing more, nothing less.

You should have one “active” astro binding, not several which are “started” or “uninstalled”, the binding needs to be active.

Still the same recommendation: set up a quick test system, only install the astro binding, see what happens … or at least do a clean up of your tmp and chache folders …

Edit: ahhh, now I see, you used an additional command I’ve never seen before, so let’s compare again:

openhab> feature:list|grep -i astro
esh-binding-astro                           │ 0.9.0.SNAPSHOT   │          │ Started     │ addons-2.2.0-SNAPSHOT   │
openhab-binding-astro                       │ 2.2.0.SNAPSHOT   │ x        │ Started     │ addons-2.2.0-SNAPSHOT   │ Astro Binding

This is definitely wrong: when upgrading to #1031, you should see a binding version date
201709011622 and not
201706170545

Thx! So indeed, when installing Astro via PaperUI, somehow an old version of the Astro binding got installed.

So I was looking in the OpenHAB folder structur, and in the folder “/var/lib/openhab2/kar” I’ve located two subfolders:
openhab-addons-2.1.0-SNAPSHOT
openhab-addons-2.2.0-SNAPSHOT
I think they got there because in the past I had the OpenHAB addons packages installed. I uninstalled it (using apt-get), but I guess the packages stayed.

Would it be safe to delete those two subfolders? Do you have something similar in that /kar folder?

Thanks,

Dries

Try to remove them with

sudo apt-get purge openhab2-addons

If they are not gone delete the two openhab-addons-2* files.

No, my /kar folder is empty, but I did never install the addons package.

Also delete the contens of the tmp and cache folder to clean up any mess (restart will take slightly longer after that, because all bindings have to be downloaded again).
Then restart openHAB and install the new “fresh” astro binding.

Good luck.

1 Like

Thanks for your help (again).

The apt-get purge didn’t help (“Package ‘openhab2-addons’ is not installed, so not removed”).
I stopped OpenHAB, deleted the contents of the /kar, /tmp and /cache folder.
I started OpenHAB. I had some various error messages at first boot. I did nothing more than reboot a few times and now they are gone.

Now I get:

openhab> bundle:list|grep -i astro
207 | Active   |  80 | 0.9.0.201709011622     | Astro Binding

So I expect the trigger will run fine when the sun sets. :slight_smile:
Thanks!

1 Like

So, what happened to the Dutch sunset/sunrise? :grinning:

I tried a lot of what was suggested and found astro too much hard work for what it should have been. I mean all i wanted to do was to turn a light on around the time it went dark so how hard could that be? :slight_smile: In the end i popped for a different approach using MQTT and a command line tool called sunwait. http://www.risacher.org/sunwait/

Assuming MQTT already set up i did the following…

  • Download and compile sunwait then copy to /usr/local/bin
  • Add cron entries (sudo crontab -e) that would trigger MQTT events at the right time for sun rise and sun set (can add offsets here too)
00 01 * * * /usr/local/bin/sunwait sun up +0:00:00 <lat>N <long>W; echo 0 | /usr/bin/mosquitto_pub -u <user> -P <pass> -t home/night -l -q 2
00 01 * * * /usr/local/bin/sunwait sun down -0:10:00 <lat>N <long>W; echo 1 | /usr/bin/mosquitto_pub -u <user> -P <pass> -t home/night -l -q 2
  • This starts a wait at 1am every day that when triggered calls the MQTT pub message for sun up/down events
  • Then i bound an item to this in openhab…
Switch Lights_NightTime "Night Time" <moon> {mqtt="<[mosquitto:home/night:state:MAP(binary.map)]"}

Seems reliable and i can control offset nicely. Given the pages of information ive read about astro, it seems a lot simpler if you have MQTT set up too.

for reference i tied the switch to a rule which turned on all lights in a group at sundown -10 and turned them off at 10pm

rule "Evening Lights On"
when
    Item Lights_NightTime changed to ON
then
    logInfo( "Lights", "Turning on evening lights...")
    LightsEvening_Group.members.forEach[s | s.sendCommand(ON)]
end

rule "Evening Lights Off"
when
    Time cron "0 0 22 ? * MON-SUN"
then
    logInfo("Lights", "Turning off evening lights...")
    LightsEvening_Group.members.forEach[s | s.sendCommand(OFF)]
end

Nice work, but in my opinion a little bit complicated for a lot of users.
Installing the astro binding and do some mouse clicks to configure it is a lot easier … :sunglasses:

1 Like

Hi @sihui. Sorry for the late reply, I was offline for several days.

I had some unforgettable sunsets. :wink:

Thanks!

Given the list of problems here and on other threads its clearly not quite as simple as we would all like it to be quite yet. Maybe 2.2 will fix that of course.

Very much of the opinion that astro is a bit of sledgehammer to crack a nut. Id love to see a nice simple “night time” binding that provides a switch when its light / dark with some optional offsets so i didn’t have to do what i did. Taking 2.2 daily snapshots is not something i wanted to do either given the variety of success in this thread and other issues that could bring.

1 Like

I’m with @sihui. What you did is very clever but I fail to see how it is any less complicated or any less of a sledge hammer than using Astro.

I’m sure many users would welcome such a binding. Do you plan on implementing it?

Having a new “simpler” nightime binding won’t fix this problem. Bugs happen, they get fixed in the newer versions, the project moves on. This is true for all add-ons.

True, but i guess the main difference is that it works reliably now in 2.1, which astro does not. Ive not plucked up the courage to try 2.2 snapshots as that seems a bit bleeding edge for me and any issues will lower the wife acceptance factor.

im pretty new to the community having lingered for a short while but Im tempted to have a go as the scope seems very simple so it may be a nice introduction.

True, maybe im just a bit impatient and like things to work. This thread has been going for 9 months so change is very slow. I really love openhab and the architecture so far and am bought in for the long run :slight_smile:

It is indeed an older thread but to be fair, the bug in Astro was fixed within a week or two, if not sooner, from when the problem was reported. In an ideal world, the problem would have been detected during the beta period test but for whatever reason, it was not.

If you don’t want to be on the bleeding edge but still get it to work, I think you can choose a specific version of the SNAPSHOT. Just choose one that isn’t too far past when the 2.1 release occurred.

Were it almost any other binding, you could also upgrade just that one binding. But I think Astro is now managed directly under the Eclipse Smarthome project and I don’t think it is as easy to get it as a separate jar file as the other bindings are.

For the record, I’ve been running on build 988 very stably for over 8 weeks now. It absolutely does not have the bug with Astro.

Thanks for the guidance, very tempted to give that a go now.