RPi + BroadLink Hub + Home Assistant: Multi-Position Slider Control
Adrian Biffen, Senior Partner
Please Note: This article series is NOT about the Google Assistant system.
As we have discussed in another article series, the BroadLink® RF-IR Blaster (seen at right) can directly control our roller shade motors and window openers with the excellent BroadLink® phone app. Many of our customers find that system to be all the automation they need.
In this article series, we are discussing how you can expand your automation horizon by using the Raspberry Pi® (a low cost, credit-card sized computer) combined with the excellent open source Home Assistant automation software, and the BroadLink® RF-IR Blaster.
We used the All-in-one installer for Raspberry Pi system to set up the powerful Home Assistant (HASS) software on a Raspberry Pi 3. This turns it into a very effective, low cost home automation system that will integrate over 600 different devices (and counting). You can see the entire collection of HASS supported components on this page.
We think the All-in-one installer for Raspberry Pi is the best way to install the HASS program on the Pi because it automatically installs extra components such as MQTT and Z-Wave. It also sets up a virtual environment that prevents other programs from interfering if they are updated with new libraries that could possibly break the HASS system.
The HASS software does not cripple the Pi for other functions either. It runs as a web server in the background, and you can still use it to send/receive email, browse the web, etc. All the general purpose software that comes with the Pi is still fully useable!
We actually use it in 'headless' mode (without dedicated monitor or keyboard/mouse). The Pi has VNC remote desktop software built into it, and we can log into it from any of the dozen machines we have here, which brings up the Pi desktop, just as if you had a local keyboard/monitor hooked up. We use the app built into Ubuntu (Remmina) to connect to the Pi, but the VNC Viewer software can be downloaded for any platform.
This is the third article in this series and if you missed the previous introduction to the RaspBerry Pi with Home Assistant, you might want to have a look at that first.
In this article we will discuss the creation of a multi-stop slider control in Home Assistant that can be used for our window blind motors and window openers. Many automation controllers only have the ability to command blinds or window openers to a fully opened or fully closed position, sometimes including a stop button.
We thought it would be a good demonstration of the power and flexibility of Home Assistant to write a short set of instructions that creates a multi-stop slider that can be adjusted to provide a selection of settings, with automation handling the actual deployment to the desired position.
Configuring the Home Assistant (HASS) Software
As seen in the previous article, the HASS program is controlled by a text file (configuration.yaml) that follows a specific type of data protocol called YAML, which uses a data structure known as key/value pairs.
You can download the actual file here. It should work right away if you have MQTT installed, which is a simple messaging system that is used to update the round status 'badges' above the slider panel. Please note that you will need to use the IP address of your Pi for the MQTT setup, and you will need to change the MAC address and IP of your BroadLink RF-IR blaster (and re-learn the blind commands).
The slider itself is on the line that says 'Theater Blackout', and it is sitting at the 1/4 position (25%) in the picture. We defined 5 positions for this application (0%, 25%, 50%, 75%, 100%) but you can change the code very easily if you want more stops (or less).
The file is relatively simple, but keep in mind that indentation is an important and critical feature, so please take care to observe that. This file already has the correct indentation, but If you get it wrong, the HASS system will let you know with error messages. Also, please note that lines with a '#' character in front are just comments that make the key/value pairs and headings more understandable.
You will have to edit this file and enter the IP and MAC address of the BroadLink hub you have on your system; the switch controls will not appear until you do this. You can get that information by logging into your router admin, or by using software to scan your network. We used arp-scan on Ubuntu to get our information.
There are a few important features we built into this program:
- Slider position is retained even if HASS is restarted or the Pi is rebooted.
- Slider is disabled as soon as it is moved to a new stop position. Once the deployment is completed, it will be enabled again. If you moved the slider while disabled, it will restore the end stop point.
- There are several delays programmed into the script; this gives you time to watch for the screen clues as things turn on and off. These can be removed by commenting with # or deletion.
- The script panel has been left exposed so you can see which one activates; you can hide it for normal use by un-commenting the code in the 'customize:' section near the top of the script
- The operation of this slider is based on time, so you ill need to enter the time required for full excursion; we used 30 seconds as the default time.
The sensor badges at the top help to report on various aspects of performance:
- Control STATUS: If the blinds (or window openers) have stopped moving, it will say DONE. If movement is in progress, it will say Moving
- Direction Travel: This will display OPEN or CLOSE, depending on which way it is moving
- Percent Travel: When you move the slider to a new position, this will display the percent of full travel that will occur
- Slider Started: This will display the position a movement cycle started from
- Slider Stopped: This will display the new position the slider was moved to
Buy These Products Online
Articles in this series:
Part 3: RPi + BroadLink Hub + Home Assistant: Multi-Position Slider Control for Blind Motors (you are here)
Where To Go From Here
See the follow-on series about our other companion devices: