Astro binding issue?

I cant decide from reading this if there Astro2 binding is missing stuff e.g. events, or if we are still waiting on the new rule trigger types to be implemented.

From my use thus far, it appears that events aren’t implemented. That said there are ways to work around that.

Hi all – I am new to OpenHAB and dove right into using OH2, moving things over from OpenRemote. Can anyone provide some guidance on how to implement the Astro 2 binding to turn on a switch at sunset and off at sunrise? There is a lot of info out there for Astro 1 but I am failing to understand how to do this appropriately in Astro 2. An example would be great!

I have Astro working in my OH2. I have astro installed, with my lat and long set in the astro.cfg.

Then in my home.items I define a sunset event (this goes back to the earlier points of not updating, I found this was the only way I could get Astro to update itself at night - haven’t tested without it recently)

DateTime Sunset_Time “Sunset [%1$tH:%1$tM]” { channel=“astro:sun:local:set#start” }

I know from some other discussions that the ‘:local’ might vary. I looked at my log files to get the correct one for mine.

Then this is the rule I have for Sunset (similar for sunrise). I found if I didn’t move the var definition to inside the If/Then it would quit updating after a few days of running: I think I read in OH2 that we can drop the imports but haven’t experimented with that yet. Also at some point want to experiment with replacing the timer with just a conversion of Sunset time to a cron time.

// Imports
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.joda.time.*
import org.openhab.model.script.actions.Timer

// Global Variables
var Timer tSunset

// lights on at sunset
rule "Sunset"
when
Time cron "0 0 16 * * ?"
then
if(tSunset!=null) {
tSunset.cancel()
}
var DateTime SunSetTime = new DateTime((astro_sun_local_set_start.state as DateTimeType).calendar.timeInMillis)
tSunset = createTimer(SunSetTime) [
sendCommand(Light_GF_Dining_Table, ON)
]
end

Hi Mike,

as afr as i understand there is no direct Switch support in Atsro 2 anymore compared to Astro 1, because the plan ist implement some more rule triggers in the future. At this moment you have to check on a regular basis if the desired time has reached.

Have the same Problem, but no solution yet

Thomas

Hello,

I’m using the following rule to check the sunset:

rule "Donker Buiten"
when Item zon_stand changed
then
if(zon_stand.state > 0){
if(donker_buiten.state!=OFF){
logInfo(“Daylight”, “Sun is crossing the horizon, switching to daylight mode”)
donker_buiten.sendCommand(OFF)
}
} else {
if(donker_buiten.state!=ON) {
logInfo(“Daylight”, “Sun is crossing the horizon, switching to night mode”)
donker_buiten.sendCommand(ON)
}
}
end

FYI: zon_stand is the sun elevation. And donke_buiten is a switch that tells me when the sun has set. This rule will update everytime when the elevation changes.

The rule works, but my astro binding is broken :-s https://community.openhab.org/t/astro-binding-not-refreshing/11268/2

Best regards,
Wouter

Hi Wouter,

does this really work? As far as i understand all Astro value are calculated at midnight and you item will change at midnight. Could you please post the Item.

Thanks
Thomas

If you check the link in my message it used to work.

In the Sun Thing you can issue an refresh parameter, I had it set on 5min. And it refreshed the item every 5 min. So the elevation was working. But since one week I can’t get it to refresh anymore. :disappointed:

I think there is something wrong with the items, because I can’t remove them using paper ui. It give an 404 error not found.
But they are there, if I add another item, it refreshes the existing ones for 1 time.

Greetz

Just to chime in, I know I raised an issue on GitHub for the 2.0 Astro binding where it doesn’t schedule the nightly updates after startup, but only after you link an item. So for my setup, if I restart OH for some reason, I just go back and unlink/relink the Astro items.

Small update:

By unlinking and relinking items I can get it to refresh manually. But If I see the next morning, all values are gone. I think the nigthly job removed them.

I’m going to enable debugging and hope that I can see something going wrong.

I had the same problem with the Astro OH2 binding stopped working. It appears that now either the Paper UI, or Habmin sets everything up that you need when you enable the binding. I had previously defined a Thing in my configs, thus there were two Astro Things & Items in my environment. I went back and removed both and then added the Astro binding through the Paper UI. converted my rules and sitemap variables over to the astro_sun_local_position_elevation item (work around suggested above) and all is working again.

Cheers!

So it sounds like there are two issues then?

  1. The sunset / sunrise times aren’t getting automatically updated on a nightly basis.
    – However @Toneus has advised he doesn’t have this problem if he builds them in Paper UI instead of the flat files.
  2. There is no event trigger built into Astro.
    – I am confused as to why this is a problem? Why can’t we just parse the date from the linked Sunset time item and schedule a command based on that time?

Indeed,

For item 2 there are workarounds.

For the first question: I don’t get nightly updates. But also the periodic updates, like sun elevation are not working. In the binding you can set the update period (default 300 sec I think). I use this value to check If the sun has set. It is a positive value if the sun is risen and negative when it has set. And changes continuously, so only midnight updates are not the answer.

I’m starting to think that my internal database if fucked and need to start over. If I delete the items (either via HABmin or paper) then delete the thing and add it again the items are back. The option to automatically create items is turned off. And the items are named lik the ones I deleted (custom names in dutch), so I think they are not getting deleted correctly.

If I have time I will start over. The problem is all my z-wave devices are also created in the internal database, so I will have to redo them as wel :frowning:

Greetings!

Ok, after checking the log today, it is working again???

13:10:34.915 [INFO ] [marthome.event.ItemStateChangedEvent] - zon_stand changed from 61.40 to 61.61 13:10:34.915 [INFO ] [ipse.smarthome.model.script.Daylight] - Sun is crossing the horizon, switching to daylight mode 13:10:34.916 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'donker_buiten' received command OFF 13:15:34.907 [INFO ] [marthome.event.ItemStateChangedEvent] - zon_stand changed from 61.61 to 61.78 13:15:34.908 [INFO ] [ipse.smarthome.model.script.Daylight] - Sun is crossing the horizon, switching to daylight mode 13:15:34.908 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'donker_buiten' received command OFF 13:20:34.902 [INFO ] [marthome.event.ItemStateChangedEvent] - zon_stand changed from 61.78 to 61.93 13:20:34.903 [INFO ] [ipse.smarthome.model.script.Daylight] - Sun is crossing the horizon, switching to daylight mode 13:20:34.906 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'donker_buiten' received command OFF 13:25:34.902 [INFO ] [marthome.event.ItemStateChangedEvent] - zon_stand changed from 61.93 to 62.04 13:25:34.903 [INFO ] [ipse.smarthome.model.script.Daylight] - Sun is crossing the horizon, switching to daylight mode 13:25:34.903 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'donker_buiten' received command OFF

zon_stand is the elevation off the sun.

Maybe the binding got updated??

Let’s see if it keeps working :slight_smile:

EDIT: after restarting it is broken again… :frowning:

Is there an active issue filed for this in github? I feel like this happened to me as well. My solution was unlinking, deleting and then re-linking new items.

See here: https://github.com/openhab/openhab2-addons/issues/726

Hi Kai - Thanks again for the great framework!!

Has there been progress on the events for DateTime channels? Is this already implemented in the 2.0 release?

Thanks!

No, still waiting for https://github.com/eclipse/smarthome/issues/1043 to be done first.

Dear all,

Updated again 2 days ago and apparently it started working again!! Don’t know whats changed, but Thanks :slight_smile:

now in my log:
2016-07-23 21:25:12.372 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro DailyJob at midnight for thing astro:sun:local
2016-07-23 21:25:12.375 [INFO ] [ding.astro.handler.AstroThingHandler] - Scheduled astro PositionalJob with interval of 303 seconds for thing astro:sun:local

The second row was always missing, now its back!!

Best regards,
Wouter

Would you be able to give an estimate on how long this may take? This topic is now almost one year old and seems to hit a lot of users, especially coming from openHAB1. Maybe it would be a good idea overall to reimplement astro events, at least for now? Only if @gerrieg thinks the effort would be acceptable!?

In both cases I would suggest to update the astro docs article.

@Woutch: Thanks for the update, I had the same problem but didn’t get around to check it out in the last few days.