Getting the roller blinds running

Let's get this party started ...

Z-Wave and RaZberry

Z-Wave was the first protocol that I used in our smarthome. Good thing about Z-Wave is that it is reliable (my oldest Fibaro devices are running for over 6yrs without a glitch) and gets no interference from other networks. Contrary to Zigbee I never had any problems with the distance between the devices being too long for Z-Wave.
On the other hand, Z-Wave is a proprietary protocol (I don't like proprietary) and the devices are pretty expensive. This is why I later started using WiFi MQTT and Zigbee devices, but more about that in a later blog post :)!

Today to get the Z-Wave running on the Raspberry Pi with Domoticz you can use different USB Sticks and stuff, but back then in 2013 the RaZberry card was the only option. In my opinion it is still a good option! My card is still running and remained compatible after multiple updates of Raspberry Pi it was attached to.
To get the RaZberry up and running, here is a good explanation. I think there are some minor tweeks that needed to be done after following this guide with a Raspberry Pi 3, but I do not remember what :)! When hitting an error, I know that the internet had a answer at hand ...

Get the roller blinds dancing up and down

It is needles to say, that you need roller blinds that are run be an electrical motor. If you do not, get help from your local dealer. The apartment we moved into already had the electrical roller blinds but they only had normal up/down switches attached to them. In order to get these blinds remotely controlled I got a couple of relays from Fibaro. They are nice and small, so they fit perfectly in the space behind the switch in the wall socket.

CAUTION!! I am an electrical engineer and do know my way around 220V. Do not try to install these relays on your own if you do not know what are you doing. Get a licensed electrican, so that you do not get into any trouble.

After getting the relays installed in the socket and including all of your devices in the Z-Wave network (the RaZberry installation explanation above will give you clues on how to do this), you can then run the roller blinds completely up (0%) and down (100%).
In order to be able to tell them only to go partially down, e.g. to 50%, you first need to calibrate the roller blinds. For this to be done go to the settings of the relay in the RaZberry menu and set the parameter Forced Roller Shutter calibration to Start calibration process. The roller blind will now go completely up and down 3 times in a row. After this, you can use the dimmer of the "Blinds Percentage" device to set the roller blind to what ever position you want.

How do we now automate everything?

You can use the in-built Domoticz timer option on each of the roller blind devices and set it to whatever you need (e.g. 30% at sunrise on weekends, 55% at sundown on Monday ...). Very flexible and powerful!

Timer screenshot

I find it easier to group the devices into scenes. Creating new scenes in Domoticz is really easy. Just go to the Scenes Tab and choose "Add scene". Give the new scene a name and after it is created you can add the devices to it. For every device you can set a different level, which will get sent to the device when the scene gets activated. You can also trigger scenes using the in-built timer, so go and have your fun ...

Scenes screenshot

If you want to go a step further, then let us introduce the first DzVents script!

I will publish all my scripts on codeberg as we go along. To use my scripts as a starting point, go to Settings/More Options/Events and create a new DzVents script by using the '+' sign. Now delete everything that gets put in by default (you can study that later) and copy the content of my script inside. Then hit save.

I decided to use my actual scripts and put them on codeberg. This is easier for me and you can see real scripts and not something generic or made up. Some of my scripts also include stuff, which I needed to do to get them running with my devices. Some of the devices have their quirks and need workarounds to work well. If you do not need my workarounds, then simply delete them. Sooner or later you will stumble upon a device that needs special attention, you can then take a peek if I already have a workaround for something like that.

The first script that we need is RollerBlindsDayNight.

    return {
        on = {
            timer = {
                '10 minutes after sunset', -- Time at which roller blinds should go down
                '10 minutes after sunrise on mon, tue, wed, thu, fri', -- Time at which roller blinds should go up
                'at 08:00 on sat, sun' -- Time at which roller blinds should go up on weekends
            }
        },
        
        execute = function(domoticz, item)
            if (domoticz.time.isNightTime and not domoticz.time.matchesRule('at 08:00 on sat, sun')) then
                domoticz.log('Es ist Nacht, Rollladen runter.')
                if (domoticz.devices('Tuer_Balkon').state == 'Locked') then
                    domoticz.scenes('Rollladen_Nacht').switchOn()
                else
                    domoticz.scenes('Rollladen_Nacht_ohne_Balkon').switchOn()
                end
                domoticz.devices('Rollladen_Eltern').dimTo(60).afterMin(2) -- Correct the position of the roller blinds in the bedroom.
            elseif ((domoticz.time.isDayTime or domoticz.time.matchesRule('at 08:00 on sat, sun')) and domoticz.devices('LazyDay').state == 'Off') then
                domoticz.log('Es ist Tag, Rollladen hoch.')
                domoticz.scenes('Rollladen_Tag').switchOn()
            end
        end
    }

The timer part of the script is self explanatory, I have different rules for working days and on the weekends.
You need to change the names of the scenes to match those in your setup.
This part here:


domoticz.devices('Rollladen_Eltern').dimTo(60).afterMin(2)}

is the first workaround. One of the devices, Rollladen_Eltern, behaves differently than the other. In order to position this roller blind correctly, it first needs to get down completely. After that, you can issue the positioning command. When the scene gets triggered, then the device is first sent the On command. This completely closes the roller blind. The workaround above basicaly gives the blind 2 minutes to get down (more then enough :)) and then sends 60% to the device.

Now the second interesting part:

if (domoticz.devices('Tuer_Balkon').state == 'Locked') then
                    domoticz.scenes('Rollladen_Nacht').switchOn()
                else
                    domoticz.scenes('Rollladen_Nacht_ohne_Balkon').switchOn()
                end

I have a door sensor Tuer_Balkon mounted on my balcony door. If this door is open I want to keep this one roller blind up, to be able to come back when I am outside and the script gets triggered. So there are two scenes to choose from, one with and the other one without the balcony door roller blind.

Additional scripts and concluding words ...

I also have a couple of additions to my control of the roller blinds:

  • RollerBlindsHot controls the blinds according to the temperature inside and outside of the apartment.
  • RollerBlindsVentilation opens one roller blind when the balcony door gets open, so that we can go out or ventilate.

I won't explain these scripts in detail, because the blog post would become too long to read. If you have questions, you can find me on Mastodon.

This shows you the first nice things that can be done with a couple of devices and few lines of code. Feel free to use and edit the scripts to your needs.

Happy Hacking!!