Enable outlet at sunset

Hi all. Beginner here trying to setup my first rule that will turn on a z-wave outlet at sunset, and turn it off at sunrise. The outlet works by itself via my sitemap’s on/off switch. I am also confident that Astro is configured properly, as I have a text item on my sitemap that prints the sunset time.

Here is my rule file:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

/**

  • Turn on outlet at sunset
    */
    when
    Item Sunset_Event received update ON
    then
    sendCommand(Outlet01_FF_Living, ON)
    end

/**

  • Turn off outlet at sunrise
    */
    when
    Item Sunrise_Event received update ON
    then
    sendCommand(Outlet01_FF_Living, OFF)
    end

Here is what the events log shows when I manually turn on the outlet:

2015-11-29 17:25:57 - Outlet01_FF_Living received command ON
2015-11-29 17:25:57 - Outlet01_FF_Living state updated to ON

Here is what the events log shows at sunset:

2015-11-29 16:30:00 - Sunset_Event state updated to ON
2015-11-29 16:30:00 - Sunset_Event state updated to OFF

Not really sure what I am missing here. I have both the binding and action jar files for Astro 1.7.1 in my addons folder (I am running OH 1.7.0 on an RPi2).

Thank you for reading!

I might be wrong, but I think the Astro ‘events’ only last momentarily. So you might need to set up a virtual item that gets changed when Astro sends out the ‘start’ message. As in, I think Astro says "Sunset Starting Start’ and then moments later ‘Sunset Starting Stop’. But clearly the actual real-world event of sunset is still taking place.

So I was thinking of having a rule that checked whether Astro said it was ‘daylight’. As everything else is either sunset/sunrise or night. So you’d need to set up a virtual item that got changed by Astro whenever the time of day ‘type’ got changed, looking out for the special exception called ‘daylight’

Does that make sense?

Makes sense, but I was kind of thinking I wouldn’t have to do that, given what the rule states. Rule is only waiting for the Sunset ON update to come in (the OFF update being received right after the ON would not matter) when it would then send the command to turn on the outlet. That is what I was thinking, at least. Perhaps I am way off?

[quote=“picarsqu3, post:1, topic:4629, full:true”]
Not really sure what I am missing here. I have both the binding and action jar files for Astro 1.7.1 in my addons folder[/quote]

A lot of people have problems with the astro binding functionality when binding and action jar files are in the addon folder: delete the action jar file and it should work …

Good luck.

Fixed! Complete noobie mistake on my part - I forgot to add rule "Enable Outlet" before each rule. :relieved: