Automatically shut your blinds after sunset with Openhab and Shelly 2.5

In this post I am going to show you how you can use Openhab and a Shelly 2.5 to lower your blinds after sunset. This is pretty convenient because then you do not have to do it yourself :)

You can read how to setup your Shelly 2.5 here.

In order to get the sunset (and sunrise) information you need to install the astro binding for Openhab.

Once you have installed the astro binding you can start adding astro things. This can be done like this in your *.things file:

astro:sun:home  [ geolocation="lat,long,alt", interval=3600 ]

I have set the interval to one hour, as this is enough for me. You can of course change to a higher frequency. It will not make a big impact for this use case though.

For the rule you will wait for the sunset start event and then shut the blinds. In case you do not want to shut the blinds directly when the sunset starts, you can add an offset to the thing:

astro:sun:home_offset  [ geolocation="lat,long,alt", interval=3600 ]
{
    Channels:
        Type start : set#start [
            offset=15
        ]
}

The last step now is to create a rule which listens to the start event of the sunset and then shuts the blinds. You can do this by adding the following rule to your *.rule file:

rule "Sunset started"
when
    Channel "astro:sun:homeoffset:set#event" triggered START
then
    logInfo("Astro", "Sunset with offset is trigged")
    gShutters.sendCommand(100);
end

In this example you see that once the sunset event is started then all blinds in the group gShutters are closed (for a Shelly 2.5 100 is closed and 0 is open).

I hope this will help you set it up for yourself.